Documentation
¶
Overview ¶
env settings: - FOFA_CLIENT_URL full fofa connnection string, format: <url>/?email=<email>&key=<key>&version=<v2> - FOFA_SERVER fofa server - FOFA_EMAIL fofa account email - FOFA_KEY fofa account key
Index ¶
- Constants
- func NewFixUrl(rowURL string) string
- func NewRequestConfig(fullURL string) *http.Client
- func SplitDomainsAndIPs(input []string) (domains []string, ips []string)
- type AccountInfo
- type ClientOption
- type DeductMode
- type FofaClient
- func (c *FofaClient) AccountInfo() (ac AccountInfo, err error)
- func (c *FofaClient) DumpSearch(query string, allSize int, batchSize int, fields []string, ...) (err error)
- func (c *FofaClient) Fetch(apiURI string, params map[string]string, v interface{}) (err error)
- func (c *FofaClient) GetContext() context.Context
- func (c *FofaClient) HostSearch(query string, size int, fields []string, options ...SearchOptions) (res [][]string, err error)
- func (c *FofaClient) HostSize(query string) (count int, err error)
- func (c *FofaClient) HostStats(host string) (data HostStatsData, err error)
- func (c *FofaClient) SetContext(ctx context.Context)
- func (c *FofaClient) URL() string
- func (c *FofaClient) Update(configURL string) error
- type HostStatsData
- type HttpResponse
- type SearchOptions
- type SearchResults
- type VipLevel
Constants ¶
const (
NoHostWithFixURL = "host field must included when fixUrl option set"
)
Variables ¶
This section is empty.
Functions ¶
func NewRequestConfig ¶
func SplitDomainsAndIPs ¶
SplitDomainsAndIPs 解析输入数组并分为 domain 和 ip 两个数组
Types ¶
type AccountInfo ¶
type AccountInfo struct {
Error bool `json:"error"` // 是否出现错误
ErrMsg string `json:"errmsg,omitempty"` // error string message
Email string `json:"email"`
Username string `json:"username"`
Category string `json:"category"` // 用户种类
FCoin int `json:"fcoin"` // F币
FofaPoint int64 `json:"fofa_point"` // F点
RemainFreePoint int `json:"remain_free_point"` // 剩余免费F点
RemainApiQuery int `json:"remain_api_query"` // API月度剩余查询次数
RemainApiData int `json:"remain_api_data"` // API月度剩余返回数量
IsVIP bool `json:"isvip"` // 是否是会员
VIPLevel VipLevel `json:"vip_level"`
IsVerified bool `json:"is_verified"`
Avatar string `json:"avatar"` // page.api.whether.level
Message string `json:"message"`
FofacliVer string `json:"fofacli_ver"`
FofaServer bool `json:"fofa_server"`
}
func (AccountInfo) String ¶
func (ai AccountInfo) String() string
type ClientOption ¶
type ClientOption func(c *FofaClient) error
func WithAccountDebug ¶
func WithAccountDebug(v bool) ClientOption
WithAccountDebug 是否错误里面显示账号密码原始信息
func WithApiKey ¶
func WithApiKey(apiKey string) ClientOption
func WithEmail ¶
func WithEmail(email string) ClientOption
func WithOnResults ¶
func WithOnResults(onResults func(results [][]string)) ClientOption
WithOnResults set on results callback
func WithURL ¶
func WithURL(configURL string) ClientOption
WithURL configURL format: <url>/?email=<email>&key=<key>&version=<v2>&tlsdisabled=false&debuglevel=0
type DeductMode ¶
type DeductMode int
DeductMode should deduct fcoin automatically or just use free limit
const ( // DeductModeFree only use free limit size DeductModeFree DeductMode = 0 // DeductModeFCoin deduct fcoin automatically if account has fcoin DeductModeFCoin DeductMode = 1 )
func ParseDeductMode ¶
func ParseDeductMode(v string) DeductMode
ParseDeductMode parse string to DeductMode
type FofaClient ¶
type FofaClient struct {
Server string // can set local server for debugging, format: <scheme>://<host>
APIVersion string // api version
Email string // fofa email
Key string // fofa key
Account AccountInfo // fofa account info
DeductMode DeductMode // Deduct Mode
Ctx context.Context // use to cancel requests
// contains filtered or unexported fields
}
FofaClient of fofa connection
func NewClient ¶
func NewClient(options ...ClientOption) (c *FofaClient, err error)
NewClient from fofa connection string to config
func (*FofaClient) AccountInfo ¶
func (c *FofaClient) AccountInfo() (ac AccountInfo, err error)
AccountInfo fetch account info from fofa
func (*FofaClient) DumpSearch ¶
func (c *FofaClient) DumpSearch(query string, allSize int, batchSize int, fields []string, onResults func([][]string, int) error, options ...SearchOptions) (err error)
DumpSearch search fofa host data query fofa query string size data size: -1 means all,0 means just data total info, >0 means actual size fields of fofa host search options for search
func (*FofaClient) Fetch ¶
func (c *FofaClient) Fetch(apiURI string, params map[string]string, v interface{}) (err error)
Fetch http request and parse as json return to v
func (*FofaClient) GetContext ¶
func (c *FofaClient) GetContext() context.Context
GetContext 获取context,用于中止任务
func (*FofaClient) HostSearch ¶
func (c *FofaClient) HostSearch(query string, size int, fields []string, options ...SearchOptions) (res [][]string, err error)
HostSearch search fofa host data query fofa query string size data size: -1 means all,0 means just data total info, >0 means actual size fields of fofa host search options for search
func (*FofaClient) HostSize ¶
func (c *FofaClient) HostSize(query string) (count int, err error)
HostSize fetch query matched host count
func (*FofaClient) HostStats ¶
func (c *FofaClient) HostStats(host string) (data HostStatsData, err error)
HostStats fetch query matched host count
func (*FofaClient) SetContext ¶
func (c *FofaClient) SetContext(ctx context.Context)
SetContext 设置context,用于中止任务
func (*FofaClient) Update ¶
func (c *FofaClient) Update(configURL string) error
Update merge config from config url
type HostStatsData ¶
type HostStatsData struct {
Error bool `json:"error"`
Errmsg string `json:"errmsg"`
Host string `json:"host"`
IP string `json:"ip"`
ASN int `json:"asn"`
ORG string `json:"org"`
Country string `json:"country_name"`
CountryCode string `json:"country_code"`
Protocols []string `json:"protocol"`
Ports []int `json:"port"`
Categories []string `json:"category"`
Products []string `json:"product"`
UpdateTime string `json:"update_time"`
}
HostStatsData /host api results
type HttpResponse ¶
func DoHttpCheck ¶
func DoHttpCheck(rowURL string, retry int) HttpResponse
type SearchOptions ¶
type SearchOptions struct {
FixUrl bool // each host fix as url, like 1.1.1.1,80 will change to http://1.1.1.1, https://1.1.1.1:8443 will no change
UrlPrefix string // default is http://
Full bool // search result for over a year
UniqByIP bool // uniq by ip
CheckActive int // probe website is existed, add isActive field
DeWildcard int // number of wildcard domains retained
Filter string // filter data by rules
DedupHost bool // prioritize subdomain data retention
}
SearchOptions options of search, for post processors
type SearchResults ¶
type SearchResults struct {
Mode string `json:"mode"`
Error bool `json:"error"`
Errmsg string `json:"errmsg"`
Query string `json:"query"`
Page int `json:"page"`
Size int `json:"size"` // 总数
Results interface{} `json:"results"`
Next string `json:"next"`
}
SearchResults /search/all api results