fofa-go

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: MIT

README

FOFA Pro - Go 使用说明文档

FOFA Pro API

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

FOFA Go SDK

基于 FOFA Pro API 编写的 golangSDK, 方便 golang 开发者快速将 FOFA Pro 集成到自己的项目中。

环境
开发环境
$ go version
go version go1.15.3 windows/amd64
测试环境
$ go version
go version go1.15.3 windows/amd64
使用
import "github.com/xiaoyu-0814/fofa-go/fofa"
获取
go get github.com/xiaoyu-0814/fofa-go/fofa
依赖
Email & API Key
字段 描述
Email 用户登陆 FOFA Pro 使用的 Email
Key 前往 个人中心 查看 API Key

如果开发者经常使用固定的账号,建议将emailkey添加到环境变量中。

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
	}
    
	//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 Go Cli

基于 FOFA Pro APIFOFA Go SDK 编写的 golang命令行工具, 方便技术人员更便捷地搜索、筛选、导出 FOFA 的数据。

使用
0x01 下载

直接下载即可使用,链接:FOFA Cli

linux需要加权限并在root用户下运行:chmod +777 fofa

0x02 使用方法

在成功下载之后,可直接在终端下使用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.


1.初始化

邮箱(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
2.个人信息
$ fofa_cli info
Email:example@fofa.so
UserName:fofa
Fcoin:0
Vip:true
VipLevel:1
3.查询
基本查询
$ 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
查看cli版本
$ fofa_cli version

Version:1.0.0

协议

FOFA SDK 遵循 MIT 协议 https://opensource.org/licenses/mit

建议收集

建议投递 邮箱:pasiyu0814@163.com

Directories

Path Synopsis
Package examples shows how to use fofa sdk
Package examples shows how to use fofa sdk
Package fofa implements some fofa-api utility functions.
Package fofa implements some fofa-api utility functions.
package main
package main

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL