Gobra源代码安全审计
前言: 2025年各位师傅新年快乐!祝各位事业有成!
Gobra源代码安全审计
CLI模式
「Examples」
# 扫描一个文件夹的代码$ python cobra.py -t tests/vulnerabilities# 扫描一个Git项目代码$ python cobra.py -t https://github.com/FeeiCN/grw.git# 扫描一个文件夹,并将扫描结果导出为JSON文件$ python cobra.py -t tests/vulnerabilities -f json -o /tmp/report.json# 扫描一个Git项目,并将扫描结果JSON文件推送到API上$ python cobra.py -f json -o http://push.to.com/api -t https://github.com/FeeiCN/vc.git# 扫描一个Git项目,并将扫描结果JSON文件发送到邮箱中$ python cobra.py -f json -o feei@feei.cn -t https://github.com/FeeiCN/grw.git# 扫描一个文件夹代码的某两种漏洞$ python cobra.py -t tests/vulnerabilities -r cvi-190001,cvi-190002# 开启一个Cobra HTTP Server,然后可以使用API接口来添加扫描任务$ python cobra.py -H 127.0.0.1 -P 8888# 查看版本$ python cobra.py --version# 查看帮助$ python cobra.py --help# 扫描一个Git项目,扫描完毕自动删除缓存$ python cobra.py -t http://github.com/xx/xx.git -dels# 扫描gitlab全部项目,配置好config中private_token,gitlab_url,cobra_ip$ python git_projects.py# 自动生成Cobra扫描周报发送至指定邮箱,需要配置好config中的SMTP服务器信息$ python cobra.py -rp
「Help」
➜ cobra git:(master) ✗ python cobra.py --helpusage: cobra [-h] [-t <target>] [-f<format>] [-o<output>] [-r <rule_id>] [-d] [-sid SID] [-H <host>] [-P<port>] ,---. | | ,---.|---.,---.,---. | | || || ,---| `---``---``---`` `---^ v2.0.0GitHub: https://github.com/WhaleShark-Team/cobraCobra isa static code analysis system that automates the detecting vulnerabilities and security issue.optional arguments: -h, --help show this help message andexitScan: -t <target>, --target <target>file, folder, compress, or repository address -f<format>, --format <format> vulnerability output format (formats: json, csv, xml) -o<output>, --output <output> vulnerability output STREAM, FILE, HTTP API URL, MAIL -r <rule_id>, --rule <rule_id> specifies rules e.g: CVI-100001,cvi-190001 -d, --debugopendebugmode -sid SID, --sid SID scan id(API) -dels, --dels del target directory True or False -rp, --report automation report Cobra dataRESTful: -H <host>, --host <host> REST-JSON API Service Host -P<port>, --port <port> REST-JSON API Service PortUsage:python cobra.py -t tests/vulnerabilitiespython cobra.py -t tests/vulnerabilities -r cvi-190001,cvi-190002python cobra.py -t tests/vulnerabilities -f json -o /tmp/report.jsonpython cobra.py -t https://github.com/ethicalhack3r/DVWA -f json -o feei@feei.cnpython cobra.py -t https://github.com/ethicalhack3r/DVWA -f json -o http://push.to.com/apipython cobra.py -t https://github.com/ethicalhack3r/DVWA -delspython cobra.py -H 127.0.0.1 -P8888
API接口
1. 添加扫描任务
请求接口接口:/api/add方法:POST类型:JSON
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2. 查询扫描任务状态
请求接口接口:/api/status方法:POST类型:JSON
请求参数
|
|
|
|
|
|---|---|---|---|
|
|
|
|
|
|
|
|
|
响应例子
{"code": 1001, # 状态码为1001则表示逻辑处理正常"result": {"msg": "success", # 消息"not_finished": 0, # 未完成的项目数"report": "http://127.0.0.1/?sid=ae3ea90pkoo5", # 扫描报告页"sid": "ae3ea90pkoo5", # 扫描的任务ID"allow_deploy": true, # 是否允许发布上线"statistic": { # 高中低危漏洞数量"high": 5,"medium": 18,"critical": 0,"low": 28 },"status": "done", # 扫描状态"still_running": {}, # 正在扫描的项目"total_target_num": 1, # 扫描任务的项目总数 }}
完整的例子
启动HTTP服务python cobra.py -H 127.0.0.1 -P 8888添加扫描任务# 添加一条任务curl -H"Content-Type: application/json" -X POST -d '{"key":"your_secret_key", "target":"https://github.com/FeeiCN/grw.git:master", "rule": "cvi-130003,cvi-130004"}' http://127.0.0.1:8888/api/add# 添加多条任务curl -H"Content-Type: application/json" -X POST -d '{"key":"your_secret_key", "target":["https://github.com/WhaleShark-Team/cobra.git:master", "https://github.com/FeeiCN/grw.git:master"]}' http://127.0.0.1:8888/api/add查询任务状态curl -H"Content-Type: application/json" -X POST -d '{"key":"your_secret_key","sid": "a938e29vdse8"}' http://127.0.0.1:8888/api/statusWeb 报告页http://127.0.0.1:8888/?sid=afbe69p7dxvaWeb 指定时间段漏洞统计http://127.0.0.1:8888/report
夜雨聆风