FOFA Pro API 是资产搜索引擎 FOFA Pro 为开发者提供的 RESTful API 接口, 允许开发者在自己的项目中集成 FOFA Pro 的功能。
基于 FOFA Pro API 编写的 golang 版 SDK, 方便 golang 开发者快速将 FOFA Pro 集成到自己的项目中。
$ go version
go version go1.15.3 windows/amd64$ go version
go version go1.15.3 windows/amd64import "github.com/xiaoyu-0814/fofa-go/fofa"go get github.com/xiaoyu-0814/fofa-go/fofa| 字段 | 描述 |
|---|---|
用户登陆 FOFA Pro 使用的 Email |
|
| Key | 前往 个人中心 查看 API Key |
如果开发者经常使用固定的账号,建议将email与key添加到环境变量中。
SDK 提供的示例代码就是使用的这种形式。
func FofaExample() {
email := os.Getenv("FOFA_EMAIL")
key := os.Getenv("FOFA_KEY")
clt := fofa.NewFofaClient([]byte(email), []byte(key))
if clt == nil {
fmt.Printf("create fofa client\n")
return
}
//QueryAsJSON
ret, err := clt.QueryAsJSON(1, []byte(`body="小米"`))
if err != nil {
fmt.Printf("%v\n", err.Error())
return
}
fmt.Printf("%s\n", ret)
//QueryAsObject
data, err := clt.QueryAsObject(1, []byte(`domain="163.com"`), []byte("ip,host,title"))
if err != nil {
fmt.Printf("%v\n", err.Error())
return
}
fmt.Printf("count: %d\n", len(data.Results))
fmt.Printf("\n%s\n", data.String())
}基于 FOFA Pro API与FOFA Go SDK 编写的 golang 版 命令行工具, 方便技术人员更便捷地搜索、筛选、导出 FOFA 的数据。
直接下载即可使用,链接:FOFA Cli
linux需要加权限并在root用户下运行:chmod +777 fofa
在成功下载之后,可直接在终端下使用fofa命令,如下:
$ fofa_cli
Fofa is a tool for discovering assets.
Usage:
fofa init|info|search option argument ...
The options are:
init:
email the email which you login to fofa.so
key the md5 string which you can find on userinfo page
search:
fields fields which you want to select
Use ip,port,protocol as default.
format output format
Default is /t splice, you can choose other.
query query statement which is similar to the statement used in the fofa.so
page page number you want to query, 100 records per page
If page is not set or page is less than 1, page will be set to 1.
out output file path
Print to the terminal as default.
count only count the total number of matches,true or false
False as default.
邮箱(email)和 API KEY (key)请在FOFA官网--->个人中心--->个人资料查看。
$ fofa_cli init -email example@fofa.so -key 32charsMD5String
[+] Successfully initialized
Email:example@fofa.so
UserName:fofa
Fcoin:0
Vip:true
VipLevel:1
$ fofa_cli info
Email:example@fofa.so
UserName:fofa
Fcoin:0
Vip:true
VipLevel:1
$ fofa_cli search -query "domain=163.com && port=443"
103.254.188.71 443
59.111.18.135 443
59.111.137.212 443
......
total: 181
字段默认值:
fields:ip,port,protocol
page:1
$ fofa_cli search -query "domain=163.com || domain=126.com" -fields ip,port,protocol,title -page 2
101.71.154.230 80 nil 301 Moved Permanently
42.186.69.125 80 nil nil
123.126.96.212 80 nil nil
2408:8719:5200::24 80 nil 301 Moved Permanently
59.111.0.134 80 nil 301 Moved Permanently
123.126.97.207 80 nil 系统提示
......
total: 1434
$ fofa_cli search -query domain=163.com -out ./fofa
[+] Successfully
$ fofa_cli search -query domain=163.com -format ------
59.111.181.60------80
123.128.14.183------80
101.71.154.225------80
123.126.97.202------80
123.134.184.218------80
1.71.150.8------80
103.254.188.71------443
......
total: 1111
$ fofa_cli search -query domain=163.com -count true
total: 1111
$ fofa_cli version
Version:1.0.0
FOFA SDK 遵循 MIT 协议 https://opensource.org/licenses/mit
建议投递 邮箱:pasiyu0814@163.com