基于 puppeteer 的 fofa.so 爬虫

基于 puppeteer 的 fofa.so 爬虫

Node.js HTTP工具

详细介绍

基于 puppeteer 的 fofa.so 爬虫

简介

使用这个工具,需要是fofa会员,普通会员即可。fofa会员,了解一下。不是会员可能会出错,我没测试。

有钱的大佬可以考虑用f币下载,点我充值f币

这个脚本会爬取fofa.so搜索的结果,提取出结果里面的链接地址,每行一个生成报告写入文件。

大致流程是先登录,然后访问fofa搜索地址,提取出页面数,遍历地提取信息这样子。

如果你想知道具体细节的话,可以修改fofa_spider.js文件,取消第58行的注释,即可取消无头模式。

用法

./fofa_spider.js https://fofa.so/result\?qbase64\=YXBwPSLmg6DlsJTpob%2FkuIrnvZHooYzkuLrnrqHnkIbns7vnu58i

报告结果展示
$ head -n 10 app_惠尔顿上网行为管理系统.txt 
https://118.123.46.107 
https://116.25.125.104 
118.247.239.34 
113.232.132.232 
https://113.234.177.58 
https://220.166.241.45 
https://222.218.19.171 
120.193.225.190 
https://42.179.231.23 
https://171.221.36.134 

安装

克隆项目到本地

git clone https://github.com/a4m/fofa_spider.git --depth 1
cd fofa_spider

安装相应的模块

npm install puppeteer system-sleep command-line-args progress -g
npm link puppeteer system-sleep command-line-args progress

creds.js.bak重命名为creds.js,改成自己的用户名和密码。

可能出现的错误

Chrome不能启动

参照官方文档Troubleshooting部分,可能是缺少依赖,安装上依赖的包即可。

Debian/Ubuntu可直接运行下面语句,CentOS请参见上面文档。

sudo apt install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

TODO

改进抓取有用信息部分代码 从页面中提取出所需要部分写的不是很好,很差。 目前只能提取出url链接。 如果你熟悉javascript并且愿意帮助我改进的话,可以在 fofa_spider.js中搜索 Need_to_fix查看详情。
绕过网页1000页的限制 可以在检索时设置一下时间段,比如: after="2017" && before="2017-10-01"

前后进行多次搜索,第一次设置before,第二次设置after。 由于精力有限,未能用代码实现。

更新记录

  • 2018-04-18 18:33:30 将报告存放到report文件夹里
  • 2018-04-18 18:49:11 文件头的下划线会被省略
  • 2018-05-06 15:42:51 网页查询的结果更正为1000页
  • 2018-05-06 16:06:34 完善文档