Skip to content

Commit

Permalink
add -fjo(jarm) and -ff (fetch-fields)
Browse files Browse the repository at this point in the history
  • Loading branch information
Becivells committed Dec 30, 2021
1 parent 6f6d66e commit a23068d
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 169 deletions.
14 changes: 11 additions & 3 deletions internal/cli/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
Stdin_Mode
Query_Mode
File_Mode
DefaultField = ""
DefaultFieldSep = ","
)

type Options struct {
Expand Down Expand Up @@ -62,10 +64,14 @@ type queryOfFile struct {
}

type filter struct {
// 填写需要的另一个字段如,port
FetchOneField string
// 填写需要获取的字段如,port
FetchFields string
// 指定显示的分隔符
FetchFieldsSplit string
// 提取指定根域名的所有 title
FetchTitlesOfDomain bool
// 提取指定根域名的所有 title
FetchJarmOfDomain bool
// 提取完整的 hostInfo,带有 protocol
FetchFullHostInfo bool
// 排除干扰
Expand Down Expand Up @@ -149,7 +155,9 @@ func init() {
//flags.BoolVarP(&args.UniqByIP, "unique-by-ip", "ubi", args.UniqByIP, "以IP的方式进行去重"),
flags.BoolVarP(&args.FetchFullHostInfo, "fetch-fullHost-info", "ffi", false, "URL fetch, with scheme, hostname, port"),
flags.BoolVarP(&args.FetchTitlesOfDomain, "fetch-titles-ofDomain", "fto", false, "Fetch website title"),
// flags.StringVarP(&args.FetchOneField, "fetch-one-field", "fof", args.FetchOneField, "填写需要的另一个字段如,port"),
flags.BoolVarP(&args.FetchJarmOfDomain, "fetch-jarm-ofDomain", "fjo", false, "Fetch website jarm"),
flags.StringVarP(&args.FetchFields, "fetch-fields", "ff", DefaultField, "Fetch by fields.eg: (ip,port)"),
flags.StringVar(&args.FetchFieldsSplit, "fetch-fields-split", "\t", "Specify characters to split data in different fields"),
)
createGroup(
flags, "query", "Single query/cert/icon",
Expand Down
13 changes: 11 additions & 2 deletions internal/fofa/fofa_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"math"
"net/http"
"net/url"
"strings"
"time"

"fofax/internal/cli"
Expand Down Expand Up @@ -150,6 +151,9 @@ func (f *FoFa) fetchByFields(fields string, queryStr string) bool {
printer.Debugf("Fofa Api Query: %s", apiResult.Query)
}
printer.Successf("Fetch Data From FoFa: [%d/%d]", len(apiResult.Results), apiResult.Size)
if f.option.FetchFields != cli.DefaultField {
fmt.Println(strings.Join(strings.Split(f.option.FetchFields, ","), f.option.FetchFieldsSplit))
}
for _, result := range apiResult.Results {
//if len(result[0]) == 0 || result[0] == ":0" {
// printer.Debug("There is no HostInfo!")
Expand Down Expand Up @@ -179,8 +183,8 @@ func (f *FoFa) FetchFullHostInfo(queryStr string) bool {
return f.fetchByFields("protocol,ip,port,host,type", queryStr)
}

// FetchOneField 提取指定的字段
func (f *FoFa) FetchOneField(field, queryStr string) bool {
// FetchField 提取指定的字段
func (f *FoFa) FetchField(field, queryStr string) bool {
return f.fetchByFields(field, queryStr)
}

Expand All @@ -189,6 +193,11 @@ func (f *FoFa) FetchTitlesOfDomain(queryStr string) bool {
return f.fetchByFields("protocol,ip,port,host,type,title,lastupdatetime", queryStr)
}

// FetchJarmOfDomain 提取 title
func (f *FoFa) FetchJarmOfDomain(queryStr string) bool {
return f.fetchByFields("protocol,ip,port,host,type,jarm,lastupdatetime", queryStr)
}

func (f *FoFa) Fetch(queryStr string) bool {
return f.fetchByFields("host,title,lastupdatetime", queryStr)
}
Expand Down
1 change: 1 addition & 0 deletions internal/fxparser/FOFA.g4
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ FOFA_KEY
| 'ip_city'
| 'ip_after'
| 'ip_before'
| 'jarm'
| 'fx'
;
Expand Down
2 changes: 1 addition & 1 deletion internal/fxparser/parser/FOFALexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit a23068d

Please sign in to comment.