anorz / fofa-go

fofa pro的sdk,go语言版本

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FOFA Pro SDK 使用说明文档

FOFA Pro API

FOFA Pro API 是资产搜索引擎 FOFA Pro 为开发者提供的 RESTful API 接口, 允许开发者在自己的项目中集成 FOFA Pro 的功能。

FOFA SDK

基于 FOFA Pro API 编写的 golangSDK, 方便 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

获取

govendor

安装 FOFA SDK 之前,请先确认已经安装 govendor.

$ go get -u -v github.com/kardianos/govendor

点击 GOVENDOR FAQ 了解更详细的使用说明

FOFA SDK

下载 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 test

依赖

Email & API Key

Email 用户登陆 FOFA Pro 使用的 Email
Key 前往 个人中心 查看 API Key
如果开发者经常使用固定的账号,建议将emailkey添加到环境变量中
echo "export FOFA_EMAIL=example@fofa.so" >> ~/.zshrc
echo "export FOFA_KEY=32charsMD5String" >> ~/.zshrc

SDK 提供的示例代码就是使用的这种形式。

Example

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 Tool

使用FOFA SDK 开发的控制台程序,无序登陆即可进行FOFA查询.
在同时满足安装FOFA SDK$GOPATH/bin包含在$PATH环境变量时,可以直接运行.

USAGE

$ 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

About

fofa pro的sdk,go语言版本

License:MIT License


Languages

Language:Go 99.1%Language:Makefile 0.9%