简介
theHarvester 是一款简单易用但功能强大的工具,专为红队评估或渗透测试的侦察阶段而设计。它执行开源情报 (OSINT) 收集,以帮助确定域名的外部威胁态势。该工具利用多种公共资源收集名称、电子邮件、IP、子域名和 URL,这些资源包括:
被动模块
- anubis:Anubis-DB - https://github.com/jonluca/anubis
- bevigil:CloudSEK BeVigil 扫描移动应用程序中的 OSINT 资产(需要 API 密钥,见下文)- https://bevigil.com/osint-api
- baidu:百度搜索引擎 - www.baidu.com
- bing:微软搜索引擎 - https://www.bing.com
- bingapi:微软搜索引擎,通过 API(需要 API 密钥,见下文)
- brave:Brave 搜索引擎 - https://search.brave.com/
- bufferoverun:(需要 API 密钥,见下文)https://tls.bufferover.run
- censys:Censys 搜索引擎将使用证书搜索来枚举子域名并收集电子邮件(需要 API 密钥,见下文)https://censys.io
- certspotter:Cert Spotter 监控证书透明度日志 - https://sslmate.com/certspotter/
- criminalip:专业网络威胁情报 (CTI) 搜索引擎(需要 API 密钥,见下文)- https://www.criminalip.io
- crtsh:Comodo 证书搜索 - https://crt.sh
- duckduckgo:DuckDuckGo 搜索引擎 - https://duckduckgo.com
- fullhunt:下一代攻击面安全平台(需要 API 密钥,见下文)- https://fullhunt.io
- github-code:GitHub 代码搜索引擎(需要 GitHub 个人访问令牌,见下文)- www.github.com
- hackertarget:在线漏洞扫描器和网络情报,助力企业 - https://hackertarget.com
- hunter:Hunter 搜索引擎(需要 API 密钥,见下文)- https://hunter.io
- hunterhow:面向安全研究人员的互联网搜索引擎(需要 API 密钥,见下文)- https://hunter.how
- intelx: Intelx 搜索引擎(需要 API 密钥,见下文)- http://intelx.io
- netlas:Shodan 或 Censys 的竞争对手(需要 API 密钥,见下文)- https://app.netlas.io
- onyphe:网络防御搜索引擎(需要 API 密钥,见下文)- https://www.onyphe.io/
- otx:AlienVault 开放式威胁交换平台 - https://otx.alienvault.com
- pentestTools:基于云的攻击性安全测试工具包,专注于 Web 应用程序和网络渗透测试(需要 API 密钥,见下文)- https://pentest-tools.com/
- projectDiscovery:我们积极收集和维护互联网资产数据,以加强研究并分析 DNS 的变化,从而获得更深入的洞察(需要 API 密钥,见下文)- https://chaos.projectdiscovery.io
- rapiddns:DNS 查询工具,可轻松查询同一 IP 的子域名或站点! https://rapiddns.io
- rocketreach:访问实时验证的个人/专业邮箱、电话号码和社交媒体链接(需要 API 密钥,详情见下文)- https://rocketreach.co
- securityTrails:Security Trails 搜索引擎,全球最大的历史 DNS 数据存储库(需要 API 密钥,详情见下文)- https://securitytrails.com
- -s, --shodan:Shodan 搜索引擎将搜索已发现主机的端口和横幅广告(需要 API 密钥,详情见下文)https://shodan.io
- sitedossier:查找网站上的可用信息 - http://www.sitedossier.com
- subdomaincenter:用于查找给定域名子域名的子域名查找工具 - https://www.subdomain.center/
- subdomainfinderc99:子域名查找工具用于查找给定域名的子域名 - https://subdomainfinder.c99.nl
- threatminer:威胁情报数据挖掘 - https://www.threatminer.org/
- tomba:Tomba 搜索引擎(需要 API 密钥,见下文)- https://tomba.io
- urlscan:用于 URL 和网站扫描的网络沙盒 - https://urlscan.io
- vhost:Bing 虚拟主机搜索
- venacus:Venacus 搜索引擎(需要 API 密钥,见下文)- https://venacus.com
- virustotal:域名搜索(需要 API 密钥,见下文)- https://www.virustotal.com
- whoisxml:子域名搜索(需要 API 密钥,见下文)- https://subdomains.whoisxmlapi.com/api/pricing
- yahoo:雅虎搜索引擎
- zoomeye:中国版 Shodan(需要 API 密钥,见下文)- https://www.zoomeye.org
可用模块
- DNS brute force:字典暴力枚举
- Screenshots:对找到的子域名进行屏幕截图
需要 API 密钥的模块
API 密钥设置文档可在以下位置找到 - https://github.com/laramies/theHarvester/wiki/Installation#api-keys
- bevigil - 最多 50 次免费查询。价格信息可在此处查看:https://bevigil.com/pricing/osint
- bing
- bufferoverun - 使用免费的 binaAPI
- censys - 需要 API 密钥,可从您的 Censys 帐户中获取。
- criminalip
- fullhunt
- github
- hunter - 免费套餐限制为 10 个,因此您需要执行 -l 10 切换。
- hunterhow
- intelx
- netlas - $
- onyphe -$
- pentestTools - $
- projectDiscovery - 目前仅限邀请。
- rocketreach - $
- securityTrails
- shodan - $
- tomba - 免费搜索最多 50 条记录。
- venacus - $
- whoisxml
- zoomeye
需要 Python 3.11 及以上版本。
安装
源码安装
通过以下命令来进行克隆源码项目,建议请先提前挂好代理进行克隆。
git clone https://github.com/laramies/theHarvester.git
进入目录并查看
cd theHarvester/
ls
创建一个 python 虚拟空间并激活。之后就可以看到创建了一个 venv 的文件夹,并且已经是激活的状态。
python3 -m venv venv
source venv/bin/activate
安装依赖和库
pip3 install -r requirements.txt
运行以下命令,如果出现这个界面,就说明安装成功了。
python3 theHarvester.py -h
Pipx 安装
通过以下命令来进行克隆源码项目,建议请先提前挂好代理进行克隆。
git clone https://github.com/laramies/theHarvester.git
进入目录并查看
cd theHarvester/
ls
安装 pipx
sudo apt install pipx
安装 python3.11-venv
sudo apt install python3.11-venv
使用 pipx 安装当前目录下的 theHarvester
pipx install --python python3.11 .
输入以下命令,如果出现了这个界面的话就说明安装成功了。
theHarvester -h
Docker 安装
也是一样先克隆项目源码并进入目录。
git clone https://github.com/laramies/theHarvester.git
cd theHarvester/
ls
在根目录下创建一个 theHarvester 文件夹。
mkdir ~/.theHarvester
进入这个目录
cd theHarvester/data/
ls
复制 api-keys.yaml 文件到本地配置目录
cp api-keys.yaml ~/.theHarvester/
退回到上上一级目录。
cd ..
cd ..
ls
拉取 debian:testing-slim 镜像
sudo docker pull debian:testing-slim
修改一下Dockerfile,添加上代理,并把里面的 python 修改一下,默然是 python 3.12 的,但是实际拉取的时候会一直报错,所以我直接修改为 python 就没报错了。
#编辑 Dockerfile 文件
vim Dockerfile
#在 FROM debian:testing-slim 后面添加一下代理
ARG HTTP_PROXY
ARG HTTPS_PROXY
ENV HTTP_PROXY=${HTTP_PROXY}
ENV HTTPS_PROXY=${HTTPS_PROXY}
#在
RUN pipx install --python python3.12 git+https://github.com/laramies/theHarvester.git
#这条语句里面,把 python3.12 修改为 python3,修改完即为
RUN pipx install --python python3 git+https://github.com/laramies/theHarvester.git
构建 Docker 镜像
sudo docker build --build-arg HTTP_PROXY=http://ip地址:端口 --build-arg HTTPS_PROXY=http://ip地址:端口 -t theharvester .
启动 Web 界面版本(监听本地端口 8080)
sudo docker run --rm -p 8080:80 --mount type=bind,source="$HOME/.theHarvester/api-keys.yaml",target="/app/api-keys.yaml" theharvester
在 FireFox 浏览器里面输入ip地址(或者 localhost)和端口号就可以打开了。
运行 CLI 模式(命令行),出现以下界面的话就说明安装成功了。
sudo docker run --rm -it --mount type=bind,source="$HOME/.theHarvester/api-keys.yaml",target="/app/api-keys.yaml" --entrypoint "/root/.local/bin/theHarvester" theharvester -h
APT 包管理器安装
Kali Linux 默然是没有安装 theHarvester 工具的。只有 Kali Everything 版本才有安装。通过以下命令来进行安装。
sudo apt install theharvester
使用
theharvester
theharvester -h
theharvester 命令已弃用。请使用 theHarvester 代替。
theHarvester
1. -h, --help
显示此帮助消息并退出
theHarvester -h
2. 常规使用
使用 DuckDuckGo(-b duckduckgo)从域中的电子邮件地址进行搜索(-d kali.org),将结果限制为 500(-l 500)
theHarvester -d kali.org -l 500 -b duckduckgo
3. -d, --domain DOMAIN
要搜索的公司名称或域名。
4. -l, --limit LIMIT
限制搜索结果数量,默认值为 500。
theHarvester -d kali.org -l 200 -b baidu
5. -S, --start START
从结果编号 X 开始,默认值为 0。
theHarvester -d kali.org -l 500 --start 0
6. -p, --proxies
使用代理进行请求,在 proxies.yaml 中输入代理。
先进入目录对这个 proxies.yaml 进行修改一下代理的ip地址和端口。
cd /etc/theHarvester
ls
cat proxies.yaml
可以看到当前是没有代理的,我们使用 vim 编辑工具来进行修改。
sudo vim proxies.yaml
这是我自己的代理ip地址和端口,你的应该和我的不一样,要按照实际情况来进行修改。确保你的ip和端口是正确的。
theHarvester -d baidu.com -l 500 --proxies
7. -s, --shodan
使用 Shodan 查询已发现的主机。
theHarvester -d baidu.com -l 500 --proxies --shodan
8. --screenshot SCREENSHOT
截取已解析域名的屏幕截图,指定输出目录:--screenshot output_directory
输出目录到一个已存在的目录:
theHarvester -d baidu.com -l 500 --proxies --shodan --screenshot /etc/theHarvester
输出目录到一个不存在的目录:
theHarvester -d baidu.com -l 500 --proxies --shodan --screenshot result
这样会提示“您输入的输出路径不存在,是否要创建”,输入"y"就可以创建一个我们制定的目录文件。
如果被拒绝的话记得给命令前面加 sudo 进行提权。
查看当前路径就可以看到已经成功创建一个我们输出制定路径的 result 文件夹了。
9. -v, --virtual-host
通过 DNS 解析验证主机名并搜索虚拟主机。
theHarvester -d kali.org -l 500 --proxies -b duckduckgo --virtual-host
10. -e, --dns-server DNS_SERVER
用于查找的 DNS 服务器。
theHarvester -d kali.org -l 500 --proxies --shodan -b bing --virtual-host --dns-server 8.8.8.8
11. -t, --take-over
检查是否存在接管。
theHarvester -d kali.org -l 500 --proxies -b bing --take-over
12. -r, --dns-resolve [DNS_RESOLVE]
使用解析器列表或传入的解析器对子域名执行 DNS 解析,默认为 False。
theHarvester -d kali.org -l 500 --proxies -b bing,duckduckgo,yahoo --dns-resolve
13. -n, --dns-lookup
启用 DNS 服务器查找,默认为 False。
theHarvester -d kali.org -l 500 --proxies -b bing,duckduckgo,yahoo --dns-resolve --dns-lookup
14. -c, --dns-brute
对域名执行 DNS 暴力破解。
如果运行的时候出现
[Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/theHarvester/data/wordlists/dns-names.txt'
这样的提示的话,只需要改一下目录路径就可以了。
进入目录并查看一下
cd /usr/lib/python3/dist-packages/theHarvester
ls
可以看到 wordlists 字典文件夹并未在 data 文件夹里面,所以我们只需要移动一下 wordlists 文件夹到 data 文件夹里面即可。
sudo mv wordlists data
再次查看就可以发现 wordlists 文件夹已经成功移动到 data 文件夹里面了。
theHarvester -d baidu.com -l 500 --proxies -b bing,duckduckgo,yahoo --dns-brute
15. -f, --filename FILENAME
将结果保存为 XML 和 JSON 文件。
theHarvester -d kali.org -l 500 --proxies -b bing,duckduckgo,yahoo --filename kali
16. -b, --source SOURCE
anubis、baidu、bevigil、binaryedge、bing、bingapi、brave、bufferoverun、censys、certspotter、criminalip、crtsh、duckduckgo、fullhunt、github-code、hackertarget、hunter、hunterhow、intelx、netlas、onyphe、otx、pentesttools、projectdiscovery、rapiddns、rocketreach、securityTrails、sitedossier、subdomaincenter、subdomainfinderc99、threatminer、tomba、urlscan、virustotal、yahoo、whoisxml、zoomeye、venacus
注意:这里有些模块需要先设置好API密钥,有免费和付费的。
修改API密钥,这里就会有个 api-keys.yaml 的文件,就是我们要修改密钥的文件。
cd /etc/theHarvester
ls
使用 vim 编辑器进行修改并保存。记得提权后才能进行修改。
sudo vim api-keys.yaml
我只添加了部分 api 密钥,其他付费的没有进行测试。
theHarvester -d kali.org -l 500 --proxies -b anubis,baidu,bevigil,binaryedge,bing,bingapi,brave,bufferoverun,censys,certspotter,criminalip,crtsh,duckduckgo,fullhunt,github-code,hackertarget,hunter,hunterhow,intelx,netlas,onyphe,otx,pentesttools,projectdiscovery,rapiddns,rocketreach,securityTrails,sitedossier,subdomaincenter,subdomainfinderc99,threatminer,tomba,urlscan,virustotal,yahoo,whoisxml,zoomeye,venacus
restfulHarvest
1. -h, --help
显示帮助信息并退出
restfulHarvest -h
2. -H, --host HOST
监听的 IP 地址,默认为 127.0.0.1
3. -p, --port PORT
绑定 Web 服务器的端口,默认为 5000
restfulHarvest --host 127.0.0.1 --port 5000
通过 FireFox 浏览器输入ip地址和端口,回车后就能看到这个界面。按 CTRL + C 停止运行。
4. -l, --log-level LOG_LEVEL
设置日志级别,默认为 info,但可以设置[critical | error | warning | info | debug | trace]
restfulHarvest --host 127.0.0.1 --port 5000 --log-level critical
restfulHarvest --host 127.0.0.1 --port 5000 --log-level error
restfulHarvest --host 127.0.0.1 --port 5000 --log-level warning
restfulHarvest --host 127.0.0.1 --port 5000 --log-level info
restfulHarvest --host 127.0.0.1 --port 5000 --log-level debug
restfulHarvest --host 127.0.0.1 --port 5000 --log-level trace
5. -r, --reload
启用 API 开发过程中使用的自动重新加载
restfulHarvest --host 127.0.0.1 --port 5000 --reload
总结
theHarvester 是一款强大的信息收集工具,主要用于在渗透测试前期阶段获取目标的电子邮件地址、子域名、IP 和主机名等情报。它支持多个数据源,操作简单,实用性强,能够有效辅助安全研究人员和红队人员进行目标侦察与资产分析,是信息搜集阶段不可或缺的开源神器。
在此特别强调,本教程仅在合法授权的情况下进行测试和研究,请勿用于其他用途。未经授权使用此类工具可能会侵犯他人隐私,触犯相关法律,任何因此引发的法律或利益纠纷与本人无关。
欢迎各位大佬,小白来找我交流。