尧图网站设计 尧图网站设计YAOTU DESIGN
ARTICLE DETAIL

资讯详情

深耕网站设计与一线实操的经验洞察。

BBOT 高级用法完全指南:Python 库集成与命令行深度解析

BBOT 高级用法完全指南:Python 库集成与命令行深度解析 BBOT 高级用法完全指南Python 库集成与命令行深度解析【免费下载链接】bbotThe recursive internet scanner for hackers. 项目地址: https://gitcode.com/GitHub_Trending/bb/bbot本文以 docs/scanning/advanced.md 为骨架系统讲解 BBOTThe recursive internet scanner for hackers的两大进阶能力一是将 BBOT 作为 Python 库嵌入自己的代码同步/异步两种模式二是对完整命令行接口CLI进行逐组拆解。读完本文你将能够用几行 Python 代码驱动一次完整扫描、按需消费事件流并精确控制目标、模块、输出与依赖安装等全部命令行参数。一、把 BBOT 当作 Python 库使用BBOT 的核心入口是Scanner类源码位于 bbot/scanner/scanner.py它代表一次独立的扫描。通过 Python 库方式使用 BBOT你可以把子域名枚举、端口扫描、指纹识别等能力嵌入自己的脚本、CI/CD 流水线或安全自动化平台。Scanner的构造函数接受与命令行等价的参数目标可变数量、presets、modules、output_modules、config、scan_name等。源码注释中的示例给出了基本用法# 多目标 多模块 my_scan Scanner(evilcorp.com, 1.2.3.0/24, modules[portscan, sslcert, httpx]) # 自定义配置 config {http_proxy: http://127.0.0.1:8080, modules: {portscan: {top_ports: 2000}}} my_scan Scanner(www.evilcorp.com, modules[portscan, httpx], configconfig)1.1 同步模式start()最简单的集成方式是使用Scanner.start()它返回一个同步生成器逐条产出扫描过程中发现的事件from bbot.scanner import Scanner if __name__ __main__: scan Scanner(evilcorp.com, presets[subdomain-enum]) for event in scan.start(): print(event)1.2 异步模式async_start()在 asyncio 环境中推荐使用async_start()异步生成器。每个事件对象可以通过.json()序列化为结构化数据便于后续落库或转发from bbot.scanner import Scanner async def main(): scan Scanner(evilcorp.com, presets[subdomain-enum]) async for event in scan.async_start(): print(event.json()) if __name__ __main__: import asyncio asyncio.run(main())1.3 不消费事件start_without_generator()如果你的目的是跑完一次扫描而不是逐条处理事件例如事件由输出模块负责写文件、推送到 SIEM可以使用无生成器变体。源码 scanner.py 显示这些方法是相互转化的def start(self): for event in async_to_sync_gen(self.async_start()): yield event def start_without_generator(self): for event in async_to_sync_gen(self.async_start()): pass async def async_start_without_generator(self): async for event in self.async_start(): pass即同步版start()本质上是async_start()经async_to_sync_gen适配后的包装start_without_generator()与async_start_without_generator()则是只管启动、丢弃事件流的快捷方式。测试 bbot/test/test_step_1/test_python_api.py 验证了这些用法例如用output_modules[json]扫描127.0.0.1后会在扫描目录下生成output.json、scan.log、debug.log且每次扫描的日志写入各自独立的目录。1.4 与命令行参数一一对应库 API 与 CLI 参数是同一套抽象CLI 最终也走Scanner(presetpreset)这条路径见 bbot/cli.py。常用的构造函数参数包括库参数对应 CLI说明*targets-t扫描目标支持 DNS 名称、IP、IP 段、端口、URL、邮箱、ORG/USER 桩等presets-p启用预设如[subdomain-enum]modules-m显式启用扫描模块output_modules-om指定输出模块默认csv、json、python、txtexclude_modules-em排除指定模块flags/require_flags/exclude_flags-f/-rf/-ef按标志批量启用/约束模块config-c自定义配置字典等效于keyvaluescan_name-n扫描名称决定~/.bbot/scans/名称下的输出目录strict_scope--strict-scope严格作用域参数校验逻辑也值得注意无效的目标、模块名、输出模块名、标志都会抛出ValidationError并给出Did you mean纠错提示。例如Scanner(asdf:::asdf)会报Unable to autodetect data type from asdf:::asdfScanner(modules[json])会报Could not find scan module json——这些行为都有对应测试用例见 test_python_api.py说明 Python 库与 CLI 共享同一套严格校验集成时可以放心依赖异常语义。二、命令行接口CLI完整参考bbot命令的帮助信息由 bbot/cli.py 中的参数解析器生成。以下是完整的 usage 与全部参数组usage: bbot [-h] [-t TARGET [TARGET ...]] [-w WHITELIST [WHITELIST ...]] [-b BLACKLIST [BLACKLIST ...]] [--strict-scope] [-p [PRESET ...]] [-c [CONFIG ...]] [-lp] [-m MODULE [MODULE ...]] [-l] [-lmo] [-em MODULE [MODULE ...]] [-f FLAG [FLAG ...]] [-lf] [-rf FLAG [FLAG ...]] [-ef FLAG [FLAG ...]] [--allow-deadly] [-n SCAN_NAME] [-v] [-d] [-s] [--force] [-y] [--fast-mode] [--dry-run] [--current-preset] [--current-preset-full] [-mh MODULE] [-o DIR] [-om MODULE [MODULE ...]] [-lo] [--json] [--brief] [--event-types EVENT_TYPES [EVENT_TYPES ...]] [--exclude-cdn] [--no-deps | --force-deps | --retry-deps | --ignore-failed-deps | --install-all-deps] [--version] [--proxy HTTP_PROXY] [-H CUSTOM_HEADERS [CUSTOM_HEADERS ...]] [-C CUSTOM_COOKIES [CUSTOM_COOKIES ...]] [--custom-yara-rules CUSTOM_YARA_RULES] [--user-agent USER_AGENT]命令行参数可分为六个组下面逐一说明。2.1 Target目标与作用域参数说明-t, --targets用于种子化扫描的目标可指定任意多个支持文件路径可混合 CLI 与文件-w, --whitelist定义何为在作用域内默认与--targets相同-b, --blacklist完全排除这些资源优先级最高甚至高于白名单--strict-scope不把目标/白名单的子域名视为在作用域内关于目标类型与作用域Scope Distance、通配符检测等的完整说明参见 docs/scanning/index.md。注意--strict-scope只作用于目标与白名单、不作用于黑名单——即使开启严格作用域放入黑名单的internal.evilcorp.com的所有子域名也都会被排除。2.2 Presets预设与配置参数说明-p, --preset启用 BBOT 预设如subdomain-enum、kitchen-sink-c, --config以keyvalue形式指定自定义配置如modules.shodan.api_key1234也可传入 YAML 文件-lp, --list-presets列出可用预设预设是 BBOT 组织常用扫描组合的方式。关于预设文件格式modules、blacklist、config等字段可参考 docs/scanning/presets.md仓库中的实际预设样例位于 bbot/presets例如subdomain-enum.yml、kitchen-sink.yml。配置加载顺序为全局配置~/.config/bbot/bbot.yml→ 预设 → 命令行-c覆盖优先级最高详见 docs/scanning/configuration.md。2.3 Modules模块管理参数说明-m, --modules启用指定模块可选模块全集见下-l, --list-modules列出所有可用模块-lmo, --list-module-options显示所有模块的配置选项-em, --exclude-modules排除指定模块-f, --flags按标志启用模块如-f subdomain-enum-lf, --list-flags列出所有可用标志-rf, --require-flags仅启用带有这些标志的模块如-rf passive-ef, --exclude-flags禁用带有这些标志的模块如-ef aggressive--allow-deadly允许使用高度激进deadly的模块可选的扫描模块-m的 choices包括affiliates, ajaxpro, anubisdb, apkpure, asn, aspnet_bin_exposure, azure_tenant, baddns, baddns_direct, baddns_zone, badsecrets, bevigil, bucket_amazon, bucket_digitalocean, bucket_file_enum, bucket_firebase, bucket_google, bucket_microsoft, bufferoverrun, builtwith, bypass403, c99, censys_dns, censys_ip, certspotter, chaos, code_repository, credshed, crt, crt_db, dehashed, dnsbimi, dnsbrute, dnsbrute_mutations, dnscaa, dnscommonsrv, dnsdumpster, dnstlsrpt, docker_pull, dockerhub, dotnetnuke, emailformat, extractous, ffuf, ffuf_shortnames, filedownload, fingerprintx, fullhunt, generic_ssrf, git, git_clone, gitdumper, github_codesearch, github_org, github_usersearch, github_workflows, gitlab_com, gitlab_onprem, google_playstore, gowitness, graphql_introspection, hackertarget, host_header, httpx, hunt, hunterio, iis_shortnames, ip2location, ipneighbor, ipstack, jadx, leakix, legba, lightfuzz, medusa, myssl, newsletters, ntlm, nuclei, oauth, otx, paramminer_cookies, paramminer_getparams, paramminer_headers, pgp, portfilter, portscan, postman, postman_download, rapiddns, reflected_parameters, retirejs, robots, securitytrails, securitytxt, shodan_dns, shodan_idb, skymem, smuggler, social, sslcert, subdomaincenter, subdomainradar, telerik, trickest, trufflehog, url_manipulation, urlscan, vhost, viewdns, virustotal, wafw00f, wayback, wpscan。可用标志-f的 choices包括active, affiliates, aggressive, baddns, cloud-enum, code-enum, deadly, download, email-enum, iis-shortnames, passive, portscan, safe, service-enum, slow, social-enum, subdomain-enum, subdomain-hijack, web-basic, web-paramminer, web-screenshots, web-thorough。每个模块都带有若干标志如securitytrails是passive、safe、subdomain-enum标志组合是精细控制扫描面最有效的手段。完整标志与模块对应关系见 docs/scanning/index.md 的List of Flags表格。从 bbot/cli.py 的源码可见启用 deadly 模块ffuf、legba、lightfuzz、medusa、nuclei、vhost时会强制要求--allow-deadly这是防止误用高度侵入性模块的硬性保护。2.4 Scan扫描行为参数说明-n, --name扫描名称默认随机生成-v, --verbose更详细的输出-d, --debug启用调试输出-s, --silent静默模式--force即使存在条件违规或模块设置失败也继续扫描-y, --yes跳过扫描确认提示--fast-mode只扫描给定目标、不做额外发现尽可能快--dry-run在执行扫描前中止--current-preset以 YAML 格式显示当前预设--current-preset-full以完整形式含默认值显示当前预设-mh, --module-help显示指定模块的帮助关于扫描名称每次扫描默认获得一个随机的趣味名称如demonic_jimmy输出与截图保存在~/.bbot/scans/名称最近 20 次扫描会被保留。-n指定名称后输出会落到当前目录下同名文件夹配合-o。交互式终端中扫描开始前会要求回车确认运行期间输入kill module可热停某个模块、直接回车可切换日志级别并查看模块状态——这些逻辑都在 bbot/cli.py 中实现。2.5 Output输出控制参数说明-o, --output-dir扫描结果输出目录-om, --output-modules指定输出模块可选asset_inventory, csv, discord, emails, http, json, mysql, neo4j, nmap_xml, postgres, python, slack, splunk, sqlite, stdout, subdomains, teams, txt, web_parameters, web_report, websocket-lo, --list-output-modules列出所有可用输出模块--json, -j以 JSON 格式输出扫描数据--brief, -br只输出数据本身--event-types选择显示哪些事件类型--exclude-cdn, -ec过滤掉 CDN/WAF 上不想要的开放端口仅保留 80、443输出模块负责把事件投递到不同目的地文件、数据库、Webhook、SIEM 等默认启用human、json、csv三种。各输出模块的配置项如modules.json.siem_friendly、modules.mysql.host、modules.discord.webhook_url可通过-c或配置文件设置完整清单见 docs/scanning/configuration.md 与 docs/scanning/output.md。2.6 Module dependencies模块依赖管理模块可能依赖 OS 包如openssl、外部二进制如nuclei或 Python 库如wappalyzer。启用模块时其依赖会在运行时通过 Ansible 自动安装详见 docs/scanning/index.md 的 Dependencies 一节以及模块编写指南 docs/dev/module_howto.md。命令行提供五个互斥参数参数说明--no-deps不安装模块依赖--force-deps强制安装所有模块依赖--retry-deps重试安装失败的依赖--ignore-failed-deps即使依赖失败也运行模块--install-all-deps为所有模块安装依赖适合在渗透测试工作机上提前预置依赖失败时的默认行为是中止扫描可通过deps.behavior配置改为retry_failed、ignore_failed或disable见 bbot/defaults.yml。--install-all-deps在 bbot/cli.py 中的实现是创建一个包含全部模块的虚拟扫描仅执行依赖安装与模块 setupdeps_onlyTrue完成后清理临时目录非常适合批量预装环境。2.7 Misc杂项参数说明--version显示 BBOT 版本并退出--proxy HTTP_PROXY所有 HTTP 请求走该代理-H, --custom-headers自定义请求头格式headervalue可多个-C, --custom-cookies自定义 Cookie格式cookievalue可多个--custom-yara-rules, -cy为 excavate 添加自定义 YARA 规则--user-agent, -ua设置所有 HTTP 请求的 User-Agent三、开箱即用的实战示例原文档在 CLI 帮助末尾给出了经过验证的常用命令组合这里完整保留并逐条注释# 子域名枚举 bbot -t evilcorp.com -p subdomain-enum # 仅被动子域名枚举不主动连接目标系统 bbot -t evilcorp.com -p subdomain-enum -rf passive # 子域名 端口扫描 Web 截图指定扫描名与输出目录 bbot -t evilcorp.com -p subdomain-enum -m portscan gowitness -n my_scan -o . # 子域名 基础 Web 扫描 bbot -t evilcorp.com -p subdomain-enum web-basic # Web 爬虫限制连续跟进链接数spider_distance2与目录深度spider_depth2 bbot -t www.evilcorp.com -p spider -c web.spider_distance2 web.spider_depth2 # 全功能扫描kitchen-sink 预设 bbot -t evilcorp.com -p kitchen-sink # 列出模块 / 输出模块 / 预设 / 标志 bbot -l bbot -lo bbot -lp bbot -lf # 查看指定模块的帮助 bbot -mh module_name注意spider_distance与spider_depth是全局web配置项默认分别为0和1-c直接以点分路径覆盖相关配置还有web.spider_links_per_page默认 25。完整的web、dns、scope、engine等全局配置项与默认值见 bbot/defaults.yml 及 docs/scanning/configuration.md。四、进一步阅读扫描基础概念目标类型、模块分类、标志、依赖、作用域与 Scope Distance、DNS 通配符检测docs/scanning/index.md配置体系配置文件优先级、全局/模块级配置项全表docs/scanning/configuration.md事件模型与输出docs/scanning/events.md 与 docs/scanning/output.md预设文件格式与内置预设列表docs/scanning/presets.md 与 docs/scanning/presets_list.md全部模块清单及说明docs/modules/list_of_modules.md编写自定义模块含依赖声明方式docs/dev/module_howto.mdPython API 实测用例bbot/test/test_step_1/test_python_api.py至此你既可以在 Python 脚本中以同步/异步方式驱动 BBOT 并消费事件流也能熟练运用命令行六大参数组精确控制每一次递归扫描。两条路径共享同一套Scanner/Preset抽象从原型验证平滑迁移到自动化平台时无需重写逻辑。【免费下载链接】bbotThe recursive internet scanner for hackers. 项目地址: https://gitcode.com/GitHub_Trending/bb/bbot创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表