FOFA Pro API 是资产搜索引擎 FOFA Pro 为开发者提供的 RESTful API 接口, 允许开发者在自己的项目中集成 FOFA Pro 的功能。
基于 FOFA Pro API 编写的 golang 版 SDK, 方便 golang 开发者快速将 FOFA Pro 集成到自己的项目中。
$ go version
go version go1.7.3 darwin/amd64$ go version
go version go1.7.3 darwin/amd64建议在 go version > 1.7.2 && (Windows >= XP || OS X >= 10.8 || Linux >= 2.6.23) && 64-bit processor 使用 FOFA SDK
安装 FOFA SDK 之前,请先确认已经安装 govendor.
$ go get -u -v github.com/kardianos/govendor点击 GOVENDOR FAQ 了解更详细的使用说明
下载 FOFA SDK
$ go get github.com/fofapro/fofa-go安装
$ govendor install +local如果是 *nix 或者 mac 可以使用
$ make
$ make install文档
$ godoc -http=:6060 -index或者
$ make doc测试
$ govendor test ./fofa如果是 *nix 或者 mac 可以使用
$ make testEmail |
用户登陆 FOFA Pro 使用的 Email |
|---|---|
Key |
前往 个人中心 查看 API Key |
如果开发者经常使用固定的账号,建议将email与key添加到环境变量中 |
echo "export FOFA_EMAIL=example@fofa.so" >> ~/.zshrc
echo "export FOFA_KEY=32charsMD5String" >> ~/.zshrcSDK 提供的示例代码就是使用的这种形式。
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
}
result, err := clt.QueryAsJSON(1, []byte(`body="小米"`))
if err != nil {
fmt.Printf("%v\n", err.Error())
}
fmt.Printf("%s\n", result)
arr, err := clt.QueryAsArray(1, []byte(`domain="haosec.cn"`), []byte("domain"))
if err != nil {
fmt.Printf("%v\n", err.Error())
}
fmt.Printf("count: %d\n", len(arr))
encodeArr, _ := json.Marshal(arr)
fmt.Printf("\n%s\n", encodeArr)
}使用FOFA SDK 开发的控制台程序,无序登陆即可进行FOFA查询.
在同时满足安装FOFA SDK与$GOPATH/bin包含在$PATH环境变量时,可以直接运行.
$ fofa-go
Fofa is a tool for discovering assets.
Usage:
fofa option argument ...
The commands are:
email the email which you login to fofa.so
Use FOFA_EMAIL env by default.
key the md5 string which you can find on userinfo page
Use FOFA_KEY env by default.
fields fields which you want to select
Use host,ip,port as default.
query query statement which is similar to the statement used in the fofa.so
format output format
Json(json) as default, alternatively you can select array(array).
page page number you want to query, 1000 records per page
If page is not set or page is less than 1, page will be set to 1.
out output file path
Use fofa_${timestamp} as default.FOFA SDK 遵循 MIT 协议 https://opensource.org/licenses/mit