Closed leojay233 closed 3 years ago
感谢提出这个问题,该问题的原因是 pocsuite3 无法正确处理依赖版本,目前已经在最新的 1.8.1 版本中修复,pip 安装最新版即可 :)
对于一个 PoC,我们需要给他提供待检测目标,有多种方式,比如 -u 指定目标 url,-f 指定一个目标列表,或者使用其他插件加载目标。_options 方法只是用来提供额外参数的,比如登陆的用户名和密码等。
Target:
At least one of these options has to be provided to define the target(s)
-u URL [URL ...], --url URL [URL ...]
Target URL (e.g. "http://www.site.com/vuln.php?id=1")
-f URL_FILE, --file URL_FILE
Scan multiple targets given in a textual file
-r POC [POC ...] Load POC file from local or remote from seebug website
-c CONFIGFILE Load options from a configuration INI file
附上一个修改后的 PoC:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import redis
from pocsuite3.api import Output, POCBase, register_poc
class RedisSec(POCBase):
vulID = '' # ssvid ID 如果是提交漏洞的同时提交 PoC,则写成 0
version = '1' # 默认为1
author = 'Jason Wang' # PoC作者的大名
vulDate = '2021-08-25' # 漏洞公开的时间,不知道就写今天
createDate = '2021-08-25' # 编写 PoC 的日期
updateDate = '2021-08-25' # PoC 更新的时间,默认和编写时间一样
references = ['https://www.cnblogs.com/xiehong/p/13186290.html'] # 漏洞地址来源,0day不用写
name = 'Redis未授权漏洞利用工具' # PoC 名称
appPowerLink = 'https://redis.io/g/' # 漏洞厂商主页地址
appName = 'rediss' # 漏洞应用名称
appVersion = 'All' # 漏洞影响版本
vulType = 'Command Execution' # 漏洞类型,类型参考见漏洞类型规范表
desc = '''
redis在安装后,没有设置密码,导致可以未授权访问执行命令
''' # 漏洞简要描述
samples = [] # 测试样列,就是用 PoC 测试成功的网站
install_requires = ["redis~=4.5.3"] # PoC 第三方模块依赖,请尽量不要使用第三方模块,必要时请参考《PoC第三方模块依赖说明》填写
dork = {'zoomeye': 'service:"redis"'}
pocDesc = ''' pocsuite3 '''
def _verify(self):
result = {}
host, port = (self.url.split('://')[-1].split('/')[0].split(':') + ['6379'])[0:2]
port = int(port)
r = redis.Redis(host=host, port=port, db=0)
try:
if 'redis_version' in r.info():
result["Stdout"] = "存在未授权访问"
except Exception:
pass
return self.parse_output(result)
def _attack(self):
return self._verify()
def _shell(self):
return self._verify()
def parse_output(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('Internet nothing returned')
return output
register_poc(RedisSec)
比如使用 -u 指定单个目标:
在 pocsuite3 1.7.7 版本之后,如果 poc 中定义了 dork 字段, 那么 也可以不指定目标,pocsuite 会自动解析 dork 并调用相应插件(比如 zoomeye )加载。
遇到类似情况,我发现异常都被pocsuite吞了,如果poc逻辑中有异常,比如某个类型转换错误。运行pocsuite的时候,只会显示faild,而不会显示具体因为什么而faild。
这种情况在使用pocsuite开发的时候,调试该怎么去调试呢?我希望能在开发poc的时候,能够通过断点去调试,但我没有在文档中找到相关章节。当我尝试配置debug启动参数去运行,类似这样:<cli.py的绝对路径> -r <编写的poc文件绝对路径> -u <待检测的url>
,发现会报错。
我为该问题提了一个新的issue请见:https://github.com/knownsec/pocsuite3/issues/211
我在poc的编写中,引入了第三方模块,是一个redis的客户端,pip中的包名就叫redis。 我按照文档要求,加入了
install_requires = ["redis==3.5.3"]
但我在运行poc的时候,pocsuite却报错了,提示:异常都被Pocsuite吞掉了,没有异常信息让我很困惑,无从下手。 贴上我的poc代码:
补充:运行poc的时候,redis库和pocsuite3已安装。