client

package
v0.0.0-...-13a5186 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

client package provided a fofa api call

Index

Examples

Constants

View Source
const (
	// review  failure
	FAIL = "failed"
	// review pending
	PEND = "pending"
	// review ok
	PUBLISH = "publish"
	// you purchas poc
	PURCHAS = "purchased"
)

poc status

View Source
const (
	CliVersion     = "4.10.2"
	FofaServer     = "fofa.so"
	ApiMy          = "/api/v1/info/my"
	ApiExploitList = "/api/v1/user/exploits"
	ApiMessage     = "/messages"
	ApiSearchRule  = "/api/v1/exploit/rule_list"
	ApiRuleInfo    = "/api/v1/exploit/rule_info"
	ApiShop        = "/exploits/shop"
	ApiShopSum     = "/exploits/all_exploits_count"
	ApiSearch      = "/api/v1/search/all"
	ApiCode        = "/api/v1/exploit/code"
	ApiPublish     = "/api/v1/exploit/publish"
)
View Source
const (
	// Member search Free quota
	MemberLimit = 100
	// 1 Foin = 10000
	FcoinToSearch = 10000
	// Vip search Free quota
	VipLimit = 10000
)

fofa search limit

Variables

This section is empty.

Functions

func GetApiUrl

func GetApiUrl(path string) (reqUrl url.URL)

GetApiUrl receive a api path, get Full url

Types

type CodeResponse

type CodeResponse struct {
	Code string `json:"code"`
	ErrorMsg
}

CodeResponse is install poc code request response

func (*CodeResponse) GetError

func (c *CodeResponse) GetError() error

GetError get error and msg

type ErrorMsg

type ErrorMsg struct {
	// is error?
	Error bool `json:"error"`
	// error msg
	Errmsg string `json:"errmsg"`
}

error info

func NewErrorMsg

func NewErrorMsg(errmsg string) *ErrorMsg

func (*ErrorMsg) GetErrorMsg

func (e *ErrorMsg) GetErrorMsg() error

GetErrorMsg get error msg

type Exploit

type Exploit struct {
	// author name
	Author string `json:"author"`
	// poc descript
	Description string `json:"description"`
	// poc filename
	Filename string `json:"filename"`
	// fofa query rule
	Fofaquery string `json:"fofaquery"`
	// exploir level
	Level int `json:"level"`
	// poc name
	Name string `json:"name"`
	// exploit product
	Product string `json:"product"`
	// product url
	Homapage string `json:"homapage"`
	// is zero day?
	IsZeroDay bool
	// poc update time
	UpdateAt string `json:"update_at"`
	// poc status
	Status string
}

fofa poc file

type ExploitResponse

type ExploitResponse struct {
	ErrorMsg
	Failed    []Exploit `json:"failed"`
	Pending   []Exploit `json:"pending"`
	Published []Exploit `json:"published"`
	Purchased []Exploit `json:"purchased"`
}

ExploitResponse get expoloit list response

type Message

type Message struct {
	Time string `json:"time"`
	Msg  string `json:"msg"`
}

notice message

func NewMessage

func NewMessage(time string, msg string) *Message

new message

type PublishResponse

type PublishResponse struct {
	ErrorMsg
}

type RuleInfoResponse

type RuleInfoResponse struct {
	ErrorMsg
	// 查询规则细节
	Rule string `json:"rule"`
	// 规则名
	Url string `json:"url"`
}

rule info result

type Search []string

type SearchResponse

type SearchResponse struct {
	ErrorMsg
	// search mode
	Mode string `json:"mode"`
	// query keyword
	Query string `json:"query"`
	// query page num
	Page int `json:"page"`
	// query total num
	Size int `json:"size"`
	// query result
	Results []Search `json:"results"`
}

fofa search result

type SearchRuleResponse

type SearchRuleResponse struct {
	ErrorMsg
	// rule name
	Data []string `json:"data"`
}

search rule result

type User

type User struct {
	// account email
	Email string `json:"email"`
	// account api token
	Token  string `json:"token, omitempty"`
	Client *http.Client
	UserInfo
}

Fofa User

func NewUser

func NewUser(email string, token string) *User

NewUser Get an a instance from email and token

Example
fakeEmail := "fake"
fakeToken := "fake"
_ = NewUser(fakeEmail, fakeToken)
Output:

func (*User) AddQuery

func (u *User) AddQuery(query url.Values) (value url.Values)

AddQuery will add authentication parameter

func (*User) GetMessages

func (u *User) GetMessages() (messages []Message, err error)

GetMessages get you notice message

Example
msg, err := user.GetMessages()
if err != nil {
	fmt.Print(err)
	return
}
if len(msg) == 0 {
	fmt.Print("not have message")
	return
}
for _, value := range msg {
	fmt.Printf("%s : <msg>", value.Time)
}
Output:

func (*User) GetPoc

func (u *User) GetPoc() (exploits ExploitResponse, err error)

GetPoc wiil get you poc

func (*User) GetPocCode

func (u *User) GetPocCode(filename string) (code string, err error)

download you poc code

Example
code, err := user.GetPocCode("phpyun_v4_install_getshell.rb")
if err != nil {
	fmt.Print(err)
	return
}
output, err := os.OpenFile("phpyun_v4_install_getshell.rb", os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm)
if err != nil {
	fmt.Print(err)
	return
}
_, err = output.WriteString(code)
if err != nil {
	fmt.Print(err)
	return
}
Output:

func (*User) GetRuleInfo

func (u *User) GetRuleInfo(name string) (rule RuleInfoResponse, err error)

SearchRule receive rulename return rule info

func (*User) GetShopPoc

func (u *User) GetShopPoc(page int) (exploits []Exploit, err error)

get number of pages exploit info

func (*User) GetShopPocNum

func (u *User) GetShopPocNum() (num int, err error)

get shop poc total

func (*User) Me

func (u *User) Me() (err error)

Me will get user info

Example
err := user.Me()
if err != nil {
	fmt.Print(err)
	return
}
fmt.Printf("%s have %d message %d Fcoin", user.UserName, user.MessageNum, user.Fcoin)
Output:

func (*User) PublishPoc

func (u *User) PublishPoc(exp Exploit, code []byte) (err error)

PublishPoc will publish you poc

func (*User) Req

func (u *User) Req(reqUrl url.URL) (data []byte, err error)

Req make a request from the url

func (*User) ReqHtml

func (u *User) ReqHtml(reqUrl url.URL) (doc *goquery.Document, err error)

Req make a request from the url, then Convert to a goquery document

func (*User) Search

func (u *User) Search(query string, fields string, page int, limit int) (searchs SearchResponse, err error)

Search receive a query, fields, pagenum, return search results

func (*User) SearchRule

func (u *User) SearchRule(key string) (resp SearchRuleResponse, err error)

SearchRule receive search key return search response

type UserInfo

type UserInfo struct {
	// user avatar
	Avatar string `json:"avatar"`
	// f coin num
	Fcoin int `json:"fcoin"`
	//
	FofaServer bool `json:"fofa_server"`
	// cli version
	CliVersion string `json:"fofacli_ver"`
	// is verify user?
	IsVerified bool `json:"is_verified"`
	// is vip user?
	IsVip bool `json:"isvip"`
	// unread message num
	MessageNum int `json:"message"`
	// username
	UserName string `json:"username"`
	// viplevel
	VipLevel int `json:"vip_level"`
}

user info

Jump to

Keyboard shortcuts

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