xiecat / fofax

FOFAX是一个基于fofa.info的API命令行查询工具
https://fofax.xiecat.fun/
GNU General Public License v3.0
719 stars 74 forks source link

批量读取导出功能 #23

Open Conan924 opened 2 years ago

Conan924 commented 2 years ago

师傅 提个建议,给了一大批ip,可以对ip.txt批量查询返回

0xf4n9x commented 2 years ago

给你举个例子

首先给定的ip.txt文件内容为如下。

# cat ip.txt
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4

那么可以利用sed命令或其他操作,在每行首添加ip=",行尾添加",最终输出内容如下。

# sed 's/^/ip="&/g;s/$/&"/g' ip.txt > query.txt
# cat query.txt
ip="1.1.1.1"
ip="2.2.2.2"
ip="3.3.3.3"
ip="4.4.4.4"

下一步,就可以使用fofax对文件进行多语句查询。

# fofax -qf query.txt -ffi -fs 10

      ____        ____       _  __
     / __/____   / __/____ _| |/ /
    / /_ / __ \ / /_ / __ `/|   /
   / __// /_/ // __// /_/ //   |
  /_/   \____//_/   \__,_//_/|_|
                    v0.1.42
            https://fofax.xiecat.fun

2022/07/11 13:58:40 [SUCC] Fetch Data From FoFa: [10/25073]
2022/07/11 13:58:41 [SUCC] Fetch Data From FoFa: [10/15]
2022/07/11 13:58:42 [SUCC] Fetch Data From FoFa: [4/4]
2022/07/11 13:58:43 [SUCC] Fetch Data From FoFa: [2/2]
dns://xxx.suda.edu.cn:53
dns://boyavip78.com:53
http://samsungclouddev.com
http://multi.i618.com.cn
https://multi.i618.com.cn
http://xxx.yuceyi.com
http://www.jiay.shop
https://xxx.suda.edu.cn
https://www.yuecode.net
https://test.wsgtm3.com
https://test1.bigmen.cn
http://test1.bigmen.cn
https://xxx.yuceyi.com
https://test1.mydnspod.net
https://boyavip78.com
https://fyy.ch
http://yanhuoa.com
http://test.ntbna.gov.tw
http://dnstest.cfzq.com
http://xxx.suda.edu.cn
http://boyavip78.com
dns://1.1.1.1:53
...
osxtest commented 1 year ago

another way to solve this:

$ cat ip.txt
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
$ fofax -debug -q "$(cat ip.txt | xargs -n1 -I {} printf 'ip="{}" || ' | sed -e "s/ || $//")"
...
2022/12/11 18:02:19 [DEBUG] FoFa input Query of: ip="1.1.1.1" || ip="2.2.2.2" || ip="3.3.3.3" || ip="4.4.4.4"
0xf4n9x commented 1 year ago

another way to solve this:

$ cat ip.txt
1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
$ fofax -debug -q "$(cat ip.txt | xargs -n1 -I {} printf 'ip="{}" || ' | sed -e "s/ || $//")"
...
2022/12/11 18:02:19 [DEBUG] FoFa input Query of: ip="1.1.1.1" || ip="2.2.2.2" || ip="3.3.3.3" || ip="4.4.4.4"

这种方式很赞,但是需要注意的是由于FOFA的查询是通过GET方法将查询语句传到后端,所以查询长度是有限制的。如果IP数量太多,通过这种一条查询语句的方式可能做不到。

不过我刚问了一下官方,现在FOFA已经支持了POST传参,后续FOFAX也会一并做修改,这种方式就可以完全支持了。