基本信息
lab地址:
https://www.hackthebox.eu/home/machines/profile/219
端口扫描

80端口closed,直接访问失败
8080


提示源代码在某个目录的’SuperSecureServer.py’ 中。
扫一下目录,是develop,得到源码:


代码注入
注意这里直接使用了exec:

直接exec我们可控的path,那么我们就可以在path注入python代码得到reverse shell
reverse shell
代码注入,得到www-root权限的shell:


接下来我们需要切到robert用户:

decrypt
robert用户目录存在一个加密程序,out.txt是check.txt加密后的文件, 查看下代码就知道加密算法只是异或,我们就可以用这个程序解出来key:
1 | python3 SuperSecureCrypt.py -i out.txt -o /tmp/key.txt -k "$(cat check.txt)" -d |

然后使用这个key解密passwordreminder.txt:
1 | python3 SuperSecureCrypt.py -i passwordreminder.txt -o /tmp/pass.txt -k alexandrovich -d |

user flag
然后使用这个密码,以robert用户登录,得到user.txt:

BetterSSH 条件竞争
在BetterSSH中有一个python文件,会读取shadow,把password写到tmp之后进行校验,并且有一个sleep,我们可以尝试在sleep的时候去读取tmp,条件竞争

这里我们使用两个SSH session
1 | while sleep 0.1; do cat /tmp/SSH/* 2>/dev/null; done # session 1 |


1 | root |
解出来root密码是mercedes:

root flag
root不能直接SSH登录,使用su切换到root,得到root.txt:

参考链接
https://github.com/Tatik07/Hackthebox/blob/master/Obscurity-Shell.py
Hackthebox Obscurity - YouTube
https://www.youtube.com/watch?v=0qXFSkPeNuo