Documentation
¶
Overview ¶
Package gofofa fofa client in Go
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 ¶
- func ExtractIconFromHtml(data []byte) string
- func FofaURLFromEnv() string
- func IconHash(iconUrl string) (hash string, err error)
- type AccountInfo
- type Client
- func (c *Client) AccountInfo() (ac AccountInfo, err error)
- func (c *Client) Fetch(apiURI string, params map[string]string, v interface{}) (err error)
- func (c *Client) HostSearch(query string, size int, fields []string) (res [][]string, err error)
- func (c *Client) HostSize(query string) (count int, err error)
- func (c *Client) Stats(query string, size int, fields []string) (res []StatsObject, err error)
- func (c *Client) URL() string
- func (c *Client) Update(configURL string) error
- type DeductMode
- type HostResults
- type StatsItem
- type StatsObject
- type StatsResults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractIconFromHtml ¶ added in v0.0.4
ExtractIconFromHtml extract link icon from html
func FofaURLFromEnv ¶
func FofaURLFromEnv() string
FofaURLFromEnv parse fofa connection url from env, then generate url string
Types ¶
type AccountInfo ¶
type AccountInfo struct {
Error bool `json:"error"` // error or not
ErrMsg string `json:"errmsg,omitempty"` // error string message
FCoin int `json:"fcoin"` // fcoin count
IsVIP bool `json:"isvip"` // is vip
VIPLevel int `json:"vip_level"` // vip level
}
AccountInfo fofa account info
func (AccountInfo) String ¶
func (ai AccountInfo) String() string
type Client ¶
type Client 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 // 扣费提醒默认
// contains filtered or unexported fields
}
Client of fofa connection
func NewClient ¶
NewClient from fofa connection string to config and with env config merge configURL format: <url>/?email=<email>&key=<key>&version=<v2>&tlsdisabled=false&debuglevel=0
func (*Client) AccountInfo ¶
func (c *Client) AccountInfo() (ac AccountInfo, err error)
AccountInfo fetch account info from fofa
func (*Client) HostSearch ¶
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 field of fofa host struct
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 HostResults ¶
type HostResults 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"`
}
HostResults /search/all api results
type StatsObject ¶ added in v0.0.3
StatsObject one stats object
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fofa
command
|
|
|
pkg
|
|
|
fzq
Package fzq fofa zq
|
Package fzq fofa zq |
|
pipeparser
Package pipeparser pipe grammar parser 用管道的方式生成底层的go代码: pipelineCode := pipeparser.NewParser().Parse("a() | b() | c()") // 如果没有注册hook函数的话,那么自动生成 "a()\nb()\nc()\n" 用hook的方式自定义生成go代码: pipeparser.RegisterFunction("a", func(fi *pipeparser.FuncInfo) string { return "testa()" }) pipelineCode := pipeparser.NewParser().Parse("a() | b() | c()") // 生成 "testa()\nb()\nc()" 处理参数,同时进行模板话处理: pipeparser.RegisterFunction("a", func(fi *pipeparser.FuncInfo) string { tmpl, err := template.New("fofa").Parse(`FetchFofa(map[string]interface{} { "query": {{ .Query }}, "size": {{ .Size }}, "fields": {{ .Fields }}, })`) if err != nil { panic(err) } var size int64 = 10 fields := "`host,title`" if len(fi.Params) > 1 { fields = fi.Params[1].String() } if len(fi.Params) > 2 { size = fi.Params[2].Int64() } var tpl bytes.Buffer err = tmpl.Execute(&tpl, struct { Query string Size int64 Fields string }{ Query: fi.Params[0].String(), Fields: fields, Size: size, }) if err != nil { panic(err) } return tpl.String() }) pipelineCode := pipeparser.NewParser().Parse("fofa(`title="test`)") // 生成 "FetchFofa(map[string]interface{} {\n...\n})\nb()\nc()"
|
Package pipeparser pipe grammar parser 用管道的方式生成底层的go代码: pipelineCode := pipeparser.NewParser().Parse("a() | b() | c()") // 如果没有注册hook函数的话,那么自动生成 "a()\nb()\nc()\n" 用hook的方式自定义生成go代码: pipeparser.RegisterFunction("a", func(fi *pipeparser.FuncInfo) string { return "testa()" }) pipelineCode := pipeparser.NewParser().Parse("a() | b() | c()") // 生成 "testa()\nb()\nc()" 处理参数,同时进行模板话处理: pipeparser.RegisterFunction("a", func(fi *pipeparser.FuncInfo) string { tmpl, err := template.New("fofa").Parse(`FetchFofa(map[string]interface{} { "query": {{ .Query }}, "size": {{ .Size }}, "fields": {{ .Fields }}, })`) if err != nil { panic(err) } var size int64 = 10 fields := "`host,title`" if len(fi.Params) > 1 { fields = fi.Params[1].String() } if len(fi.Params) > 2 { size = fi.Params[2].Int64() } var tpl bytes.Buffer err = tmpl.Execute(&tpl, struct { Query string Size int64 Fields string }{ Query: fi.Params[0].String(), Fields: fields, Size: size, }) if err != nil { panic(err) } return tpl.String() }) pipelineCode := pipeparser.NewParser().Parse("fofa(`title="test`)") // 生成 "FetchFofa(map[string]interface{} {\n...\n})\nb()\nc()" |
