Projects STRLCPY metabigor Commits 6250c833
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    README.md
    1 1  <p align="center">
    2 2   <img alt="Metabigor" src="https://image.flaticon.com/icons/svg/2303/2303030.svg" height="140" />
    3  - <p align="center">Intelligence Framework but without API key</p>
     3 + <p align="center">Intelligence Tool but without API key</p>
    4 4   <p align="center">
    5  - <a href="https://github.com/j3ssie/metabigor"><img alt="Release" src="https://img.shields.io/badge/version-1.0-red.svg"></a>
     5 + <a href="https://github.com/j3ssie/metabigor"><img alt="Release" src="https://img.shields.io/badge/version-0.3-red.svg"></a>
    6 6   <a href=""><img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"></a>
    7 7   </p>
    8 8  </p>
    9 9   
    10 10  ## What is Metabigor?
    11  -Metabigor is Intelligence Framework, its goal is to do OSINT tasks and more but without any API key.
     11 +Metabigor is Intelligence tool, its goal is to do OSINT tasks and more but without any API key.
    12 12   
    13 13   
    14 14  ## Installation
    skipped 1 lines
    16 16  ```
    17 17  go get -u github.com/j3ssie/metabigor
    18 18  ```
    19  - 
    20 19   
    21 20  ### Example Commands
    22 21   
    skipped 10 lines
    33 32   
    34 33  # running masscan on port all port and nmap on open port
    35 34  cat list_of_IPs | metabigor scan --detail -o /tmp/result.txt
     35 + 
     36 +# search result on fofa
     37 +echo 'title="RabbitMQ Management"' | metabigor search -x -v -o /tmp/result.txt
    36 38  ```
    37 39   
    38 40  ## Credits
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    cmd/net.go
    skipped 93 lines
    94 94   wg.Done()
    95 95   }()
    96 96   
    97  - // wg.Add(1)
    98  - // go func() {
    99  - // data = append(data, modules.ASNSpyse(options)...)
    100  - // wg.Done()
    101  - // }()
    102  - 
    103 97   wg.Wait()
    104 98   return data
    105 99  }
    skipped 48 lines
  • ■ ■ ■ ■ ■ ■
    cmd/root.go
    skipped 33 lines
    34 34   
    35 35  func init() {
    36 36   cobra.OnInitialize(initConfig)
    37  - RootCmd.PersistentFlags().StringVar(&options.ConfigFile, "configFile", "~/.metabigor/config.yaml", "root Project")
    38 37   RootCmd.PersistentFlags().StringVar(&options.Scan.TmpOutput, "tmp", "", "Temp Output folder")
    39 38   RootCmd.PersistentFlags().StringVar(&options.Proxy, "proxy", "", "Proxy for doing request")
    40  - RootCmd.PersistentFlags().IntVarP(&options.Concurrency, "concurrency", "c", 3, "concurrency")
    41  - RootCmd.PersistentFlags().IntVar(&options.Timeout, "timeout", 10, "timeout")
     39 + RootCmd.PersistentFlags().IntVarP(&options.Concurrency, "concurrency", "c", 5, "concurrency")
     40 + RootCmd.PersistentFlags().IntVar(&options.Timeout, "timeout", 15, "timeout")
    42 41   RootCmd.PersistentFlags().StringVarP(&options.Input, "input", "i", "-", "input as a string, file or from stdin")
    43 42   RootCmd.PersistentFlags().StringVarP(&options.Output, "output", "o", "out.txt", "output name")
    44 43   RootCmd.PersistentFlags().BoolVar(&options.Debug, "debug", false, "Debug")
    skipped 4 lines
    49 48  func initConfig() {
    50 49   if options.Debug {
    51 50   options.Verbose = true
    52  - }
    53  - if options.Verbose {
    54  - core.InforF("Metabigor %v by %v\n", core.VERSION, core.AUTHOR)
    55 51   }
    56 52   core.InitLog(options)
    57 53   // planned feature
    skipped 27 lines
  • ■ ■ ■ ■
    cmd/scan.go
    skipped 132 lines
    133 133  }
    134 134   
    135 135  func directDetail(input string, options core.Options) []string {
    136  - if input == "" {
     136 + if input == "" {
    137 137   return []string{}
    138 138   }
    139 139   if len(strings.Split(input, ":")) == 1 {
    skipped 54 lines
  • ■ ■ ■ ■ ■ ■
    cmd/search.go
     1 +package cmd
     2 + 
     3 +import (
     4 + "fmt"
     5 + "os"
     6 + "strings"
     7 + "sync"
     8 + 
     9 + "github.com/j3ssie/metabigor/core"
     10 + "github.com/j3ssie/metabigor/modules"
     11 + "github.com/spf13/cobra"
     12 +)
     13 + 
     14 +var searchCmd *cobra.Command
     15 + 
     16 +func init() {
     17 + // byeCmd represents the bye command
     18 + var searchCmd = &cobra.Command{
     19 + Use: "search",
     20 + Short: "Do Search on popular search engine",
     21 + Long: fmt.Sprintf(`Metabigor - Intelligence Framework but without API key - %v by %v`, core.VERSION, core.AUTHOR),
     22 + RunE: runSearch,
     23 + }
     24 + 
     25 + searchCmd.Flags().StringP("source", "s", "fofa", "Search Engine")
     26 + searchCmd.Flags().StringSliceP("query", "q", []string{}, "Query to search")
     27 + searchCmd.Flags().BoolP("brute", "b", false, "Enable Brute Force")
     28 + searchCmd.Flags().BoolP("optimize", "x", false, "Enable Optimize Query")
     29 + RootCmd.AddCommand(searchCmd)
     30 +}
     31 + 
     32 +func runSearch(cmd *cobra.Command, args []string) error {
     33 + options.Search.Source, _ = cmd.Flags().GetString("source")
     34 + options.Search.Source = strings.ToLower(options.Search.Source)
     35 + options.Search.More, _ = cmd.Flags().GetBool("brute")
     36 + options.Search.Optimize, _ = cmd.Flags().GetBool("optimize")
     37 + 
     38 + queries, _ := cmd.Flags().GetStringSlice("query")
     39 + 
     40 + var inputs []string
     41 + if options.Input != "-" && options.Input != "" {
     42 + if strings.Contains(options.Input, "\n") {
     43 + inputs = strings.Split(options.Input, "\n")
     44 + } else {
     45 + inputs = append(inputs, options.Input)
     46 + }
     47 + }
     48 + if len(queries) > 0 {
     49 + inputs = append(inputs, queries...)
     50 + }
     51 + if len(inputs) == 0 {
     52 + core.ErrorF("No input found")
     53 + os.Exit(1)
     54 + }
     55 + 
     56 + if options.Search.More {
     57 + inputs = addMoreQuery(inputs, options)
     58 + }
     59 + 
     60 + var wg sync.WaitGroup
     61 + jobs := make(chan string)
     62 + 
     63 + for i := 0; i < options.Concurrency; i++ {
     64 + wg.Add(1)
     65 + go func() {
     66 + defer wg.Done()
     67 + // do real stuff here
     68 + for job := range jobs {
     69 + searchResult := runSearchSingle(job, options)
     70 + StoreData(searchResult, options)
     71 + }
     72 + }()
     73 + }
     74 + 
     75 + for _, input := range inputs {
     76 + jobs <- input
     77 + }
     78 + 
     79 + close(jobs)
     80 + wg.Wait()
     81 + 
     82 + if !core.FileExists(options.Output) {
     83 + core.ErrorF("No data found")
     84 + }
     85 + core.DebugF("Unique Output: %v", options.Output)
     86 + core.Unique(options.Output)
     87 + return nil
     88 +}
     89 + 
     90 +func runSearchSingle(input string, options core.Options) []string {
     91 + var data []string
     92 + core.BannerF(fmt.Sprintf("Search on %v for: ", options.Search.Source), input)
     93 + options.Search.Query = input
     94 + 
     95 + switch options.Search.Source {
     96 + case "fofa":
     97 + data = append(data, modules.FoFaSearch(options)...)
     98 + break
     99 + }
     100 + return data
     101 +}
     102 + 
     103 +// add more query by add the country code with original query
     104 +func addMoreQuery(inputs []string, options core.Options) []string {
     105 + var moreQueries []string
     106 + ContriesCode := []string{"AF̵", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "EH", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GN", "GW", "GY", "HT", "HM", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IL", "IT", "JM", "JP", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "AN", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "SH", "KN", "LC", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "CS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VE", "VU", "VN", "VG", "VI", "WF", "YE", "ZW",}
     107 + 
     108 + for _, input := range inputs {
     109 + options.Search.Query = input
     110 + switch options.Search.Source {
     111 + case "fofa":
     112 + for _, country := range ContriesCode {
     113 + newQuery := fmt.Sprintf(`%v && country="%v"`, input, country)
     114 + moreQueries = append(moreQueries, newQuery)
     115 + }
     116 + break
     117 + }
     118 + }
     119 + 
     120 + return moreQueries
     121 +}
     122 + 
  • ■ ■ ■ ■ ■ ■
    core/common.go
    skipped 52 lines
    53 53   } else {
    54 54   logger.SetOutput(ioutil.Discard)
    55 55   }
     56 + 
     57 + InforF("Metabigor %v by %v", VERSION, AUTHOR)
    56 58   logger.Info(fmt.Sprintf("Store log file to: %v", logFile))
    57 59  }
    58 60   
    skipped 34 lines
  • ■ ■ ■ ■ ■ ■
    core/config.go
    1  -package core
    2  - 
    3  -import (
    4  - "bytes"
    5  - "fmt"
    6  - "io/ioutil"
    7  - "os"
    8  - "path/filepath"
    9  - "strings"
    10  - 
    11  - "github.com/mitchellh/go-homedir"
    12  - "github.com/spf13/viper"
    13  -)
    14  - 
    15  -// InitConfig Init the config
    16  -func InitConfig(options Options) {
    17  - options.ConfigFile, _ = homedir.Expand(options.ConfigFile)
    18  - RootFolder := filepath.Dir(options.ConfigFile)
    19  - if !FolderExists(RootFolder) {
    20  - InforF("Init new config at %v", RootFolder)
    21  - os.MkdirAll(RootFolder, 0750)
    22  - }
    23  - 
    24  - // init config
    25  - v := viper.New()
    26  - v.AddConfigPath(RootFolder)
    27  - v.SetConfigName("config")
    28  - v.SetConfigType("yaml")
    29  - if !FileExists(options.ConfigFile) {
    30  - InforF("Write new config to: %v", options.ConfigFile)
    31  - v.SetDefault("Sessions", map[string]string{
    32  - "fofa": "xxx",
    33  - "censys": "xxx",
    34  - "zoomeye": "xxx",
    35  - "github": "xxx",
    36  - })
    37  - v.SetDefault("Credentials", map[string]string{
    38  - "fofa": "username:password",
    39  - "censys": "username:password",
    40  - "zoomeye": "username:password",
    41  - "github": "username:password",
    42  - })
    43  - v.WriteConfigAs(options.ConfigFile)
    44  - } else {
    45  - if options.Debug {
    46  - InforF("Load config from: %v", options.ConfigFile)
    47  - }
    48  - b, _ := ioutil.ReadFile(options.ConfigFile)
    49  - v.ReadConfig(bytes.NewBuffer(b))
    50  - }
    51  -}
    52  - 
    53  -// GetCred get credentials
    54  -func GetCred(source string, options Options) string {
    55  - options.ConfigFile, _ = homedir.Expand(options.ConfigFile)
    56  - RootFolder := filepath.Dir(options.ConfigFile)
    57  - v := viper.New()
    58  - v.SetConfigName("config")
    59  - v.SetConfigType("yaml")
    60  - v.AddConfigPath(RootFolder)
    61  - if err := v.ReadInConfig(); err != nil {
    62  - fmt.Printf("Failed to read the configuration file: %s\n", err)
    63  - InitConfig(options)
    64  - return ""
    65  - }
    66  - 
    67  - Creds := v.GetStringMapString("Credentials")
    68  - if Creds == nil {
    69  - return ""
    70  - }
    71  - for k, v := range Creds {
    72  - if strings.ToLower(k) == strings.ToLower(source) {
    73  - return fmt.Sprintf("%v", v)
    74  - }
    75  - }
    76  - return ""
    77  -}
    78  - 
    79  -// GetSess get credentials
    80  -func GetSess(source string, options Options) string {
    81  - options.ConfigFile, _ = homedir.Expand(options.ConfigFile)
    82  - RootFolder := filepath.Dir(options.ConfigFile)
    83  - v := viper.New()
    84  - v.SetConfigName("config")
    85  - v.SetConfigType("yaml")
    86  - v.AddConfigPath(RootFolder)
    87  - if err := v.ReadInConfig(); err != nil {
    88  - fmt.Printf("Failed to read the configuration file: %s\n", err)
    89  - InitConfig(options)
    90  - return ""
    91  - }
    92  - Creds := v.GetStringMapString("Sessions")
    93  - if Creds == nil {
    94  - return ""
    95  - }
    96  - for k, v := range Creds {
    97  - if strings.ToLower(k) == strings.ToLower(source) {
    98  - return fmt.Sprintf("%v", v)
    99  - }
    100  - }
    101  - return ""
    102  -}
    103  - 
    104  -// SaveSess get credentials
    105  -func SaveSess(source string, sess string, options Options) string {
    106  - options.ConfigFile, _ = homedir.Expand(options.ConfigFile)
    107  - RootFolder := filepath.Dir(options.ConfigFile)
    108  - v := viper.New()
    109  - v.SetConfigName("config")
    110  - v.SetConfigType("yaml")
    111  - v.AddConfigPath(RootFolder)
    112  - if err := v.ReadInConfig(); err != nil {
    113  - fmt.Printf("Failed to read the configuration file: %s\n", err)
    114  - InitConfig(options)
    115  - return ""
    116  - }
    117  - 
    118  - Sessions := v.GetStringMapString("Sessions")
    119  - Sessions[source] = sess
    120  - v.Set("Sessions", Sessions)
    121  - v.WriteConfig()
    122  - return sess
    123  -}
    124  - 
  • ■ ■ ■ ■ ■ ■
    core/helper.go
    skipped 3 lines
    4 4   "archive/zip"
    5 5   "bufio"
    6 6   "crypto/sha1"
     7 + "encoding/base64"
    7 8   "encoding/json"
    8 9   "fmt"
    9 10   "io"
    10 11   "io/ioutil"
     12 + "net/url"
    11 13   "os"
    12 14   "path/filepath"
    13 15   "regexp"
    skipped 68 lines
    82 84   if val == "" {
    83 85   continue
    84 86   }
     87 + val = strings.TrimSpace(val)
    85 88   if seen[val] && unique {
    86 89   continue
    87 90   }
    skipped 12 lines
    100 103   
    101 104  // WriteToFile write string to a file
    102 105  func WriteToFile(filename string, data string) (string, error) {
    103  - file, err := os.Create(filename)
     106 + file, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
    104 107   if err != nil {
    105 108   return "", err
    106 109   }
    skipped 4 lines
    111 114   return "", err
    112 115   }
    113 116   return filename, file.Sync()
     117 +}
     118 + 
     119 +// Unique unique content of a file and remove blank line
     120 +func Unique(filename string) {
     121 + data := ReadingFileUnique(filename)
     122 + WriteToFile(filename, strings.Join(data, "\n"))
    114 123  }
    115 124   
    116 125  // AppendToContent append string to a file
    skipped 149 lines
    266 275   return raw
    267 276  }
    268 277   
     278 +// Base64Encode just Base64 Encode
     279 +func Base64Encode(raw string) string {
     280 + return base64.StdEncoding.EncodeToString([]byte(raw))
     281 +}
     282 + 
     283 +// Base64Decode just Base64 Encode
     284 +func Base64Decode(raw string) string {
     285 + data, err := base64.StdEncoding.DecodeString(raw)
     286 + if err != nil {
     287 + return raw
     288 + }
     289 + return string(data)
     290 +}
     291 + 
     292 +// URLDecode decode url
     293 +func URLDecode(raw string) string {
     294 + decodedValue, err := url.QueryUnescape(raw)
     295 + if err != nil {
     296 + return raw
     297 + }
     298 + return decodedValue
     299 +}
     300 + 
     301 +// URLEncode Encode query
     302 +func URLEncode(raw string) string {
     303 + decodedValue := url.QueryEscape(raw)
     304 + return decodedValue
     305 +}
     306 + 
  • ■ ■ ■ ■ ■
    core/options.go
    skipped 15 lines
    16 16   Debug bool
    17 17   // Ports string
    18 18   // Rate string
    19  - Scan ScanOptions
    20  - Net NetOptions
     19 + Scan ScanOptions
     20 + Net NetOptions
     21 + Search SearchOptions
    21 22  }
    22 23   
    23 24  // ScanOptions options for net command
    skipped 11 lines
    35 36  type NetOptions struct {
    36 37   Asn string
    37 38   Org string
     39 +}
     40 + 
     41 +// SearchOptions options for net command
     42 +type SearchOptions struct {
     43 + Source string
     44 + Query string
     45 + Optimize bool
     46 + More bool
    38 47  }
    39 48   
    40 49  // HTTPRequest all information about response
    skipped 18 lines
  • ■ ■ ■ ■ ■
    core/request.go
    skipped 63 lines
    64 64   url := req.URL
    65 65   headers := req.Headers
    66 66   body := req.Body
     67 + // default user-agent
     68 + if headers == nil {
     69 + headers = make(map[string]string)
     70 + }
     71 + headers["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4052.0 Safari/537.36"
    67 72   
    68 73   // new client
    69 74   client := gorequest.New().TLSClientConfig(&tls.Config{InsecureSkipVerify: true})
    skipped 82 lines
  • ■ ■ ■ ■ ■ ■
    core/version.go
    1 1  package core
    2 2   
    3 3  const (
    4  - // VERSION current Jaeles version
    5  - VERSION = "beta v0.2"
     4 + // VERSION current Metabigor version
     5 + VERSION = "beta v0.3"
    6 6   // AUTHOR author of this
    7 7   AUTHOR = "@j3ssiejjj"
    8 8  )
    skipped 1 lines
  • ■ ■ ■ ■ ■ ■
    modules/search.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "fmt"
     5 + "github.com/thoas/go-funk"
     6 + "regexp"
    5 7   "strings"
     8 + "sync"
    6 9   
    7 10   "github.com/PuerkitoBio/goquery"
    8 11   "github.com/j3ssie/metabigor/core"
    9 12  )
    10 13   
    11  -// FoFa doing searching on FoFa
    12  -func FoFa(options core.Options) string {
    13  - asn := options.Net.Asn
    14  - url := fmt.Sprintf(`https://ipinfo.io/%v`, asn)
     14 +// FoFaSearch doing searching on FoFa
     15 +func FoFaSearch(options core.Options) []string {
     16 + var result []string
     17 + result = append(result, singleFoFaSearch(options.Search.Query)...)
    15 18   
    16  - if options.Debug {
    17  - core.DebugF(url)
     19 + if !options.Search.Optimize {
     20 + return result
    18 21   }
    19 22   
    20  - content := core.RequestWithChrome(url, "ipTabContent")
     23 + moreQueries := OptimizeFofaQuery(options)
     24 + if len(moreQueries) > 0 {
     25 + var wg sync.WaitGroup
     26 + count := 0
     27 + for _, moreQuery := range moreQueries {
     28 + wg.Add(1)
     29 + go func(query string) {
     30 + defer wg.Done()
     31 + result = append(result, singleFoFaSearch(query)...)
     32 + }(moreQuery)
     33 + // limit the pool
     34 + count++
     35 + if count == options.Concurrency {
     36 + wg.Wait()
     37 + count = 0
     38 + }
     39 + }
     40 + }
     41 + 
     42 + return result
     43 +}
     44 + 
     45 +func singleFoFaSearch(query string) []string {
     46 + core.InforF("Fofa Query: %v", query)
     47 + query = core.Base64Encode(query)
     48 + url := fmt.Sprintf(`https://fofa.so/result?qbase64=%v`, query)
     49 + core.DebugF("Get data from: %v", url)
     50 + var result []string
     51 + 
     52 + content := core.RequestWithChrome(url, "ajax_content")
    21 53   doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
    22 54   if err != nil {
    23  - return ""
     55 + return result
    24 56   }
    25  - // searching for data
    26  - doc.Find("tr").Each(func(i int, s *goquery.Selection) {
    27  - data := strings.Split(strings.TrimSpace(s.Text()), " ")
    28  - cidr := strings.TrimSpace(data[0])
    29  - desc := strings.TrimSpace(data[len(data)-1])
    30  - fmt.Printf("Link #%d:\ntext: %s - %s\n\n", i, cidr, desc)
     57 + 
     58 + doc.Find(".list_mod_t").Each(func(i int, s *goquery.Selection) {
     59 + doc.Find(".list_mod_t").Each(func(i int, s *goquery.Selection) {
     60 + data := regexp.MustCompile(`[\s\t\r\n]+`).ReplaceAllString(strings.TrimSpace(s.Text()), " ")
     61 + content := strings.Split(data, " ")
     62 + if len(content) <= 1 {
     63 + return
     64 + }
     65 + 
     66 + if len(content) <= 2 {
     67 + line := content[0]
     68 + if strings.HasPrefix(line, "http") {
     69 + line = strings.Replace(line, "http://", "", -1)
     70 + line = strings.Replace(line, "https://", "", -1)
     71 + }
     72 + result = append(result, fmt.Sprintf("%v", line))
     73 + return
     74 + }
     75 + result = append(result, fmt.Sprintf("%v:%v", content[0], content[1]))
     76 + })
    31 77   })
    32  - return content
     78 + 
     79 + return result
    33 80  }
    34 81   
    35  -// // FofaLogin do login to Fofa
    36  -// func FofaSession(options core.Options) bool {
    37  -// // check session is still valid or not
    38  -// sessURL := "https://fofa.so/user/users/info"
    39  -// headers := map[string]string{
    40  -// "Cookie": core.GetSess("fofa", options),
    41  -// }
    42  -// core.DebugF(sessURL)
    43  -// req := core.HTTPRequest{
    44  -// Method: "GET",
    45  -// URL: "https://fofa.so/user/users/info",
    46  -// Headers: headers,
    47  -// }
    48  -// resp := core.SendRequest(req, options)
    49  -// if resp.StatusCode == 200 {
    50  -// return true
    51  -// }
     82 +// OptimizeFofaQuery find more optimze
     83 +func OptimizeFofaQuery(options core.Options) []string {
     84 + var optimzeQueries []string
     85 + 
     86 + query := core.Base64Encode(options.Search.Query)
     87 + url := fmt.Sprintf(`https://fofa.so/search/result_stats?qbase64=%v`, query)
     88 + core.DebugF("Get optimize data from: %v", url)
     89 + req := core.HTTPRequest{
     90 + Method: "GET",
     91 + URL: url,
     92 + Headers: map[string]string{
     93 + "X-Requested-With": "XMLHttpRequest",
     94 + },
     95 + }
     96 + res := core.SendRequest(req, options)
     97 + content := res.Body
     98 + 
     99 + var result []string
     100 + regex := "qbase64\\=[a-zA-Z0-9%]+"
     101 + r, rerr := regexp.Compile(regex)
     102 + if rerr != nil {
     103 + return result
     104 + }
     105 + matches := r.FindAllString(content, -1)
     106 + if len(matches) == 0 {
     107 + return result
     108 + }
    52 109   
    53  -// return false
    54  -// }
     110 + for _, match := range matches {
     111 + query := core.URLDecode(strings.Replace(match, "qbase64=", "", -1))
     112 + optimizeQuery := strings.TrimSpace(core.Base64Decode(query))
     113 + optimzeQueries = append(optimzeQueries, optimizeQuery)
     114 + }
     115 + 
     116 + return funk.UniqString(optimzeQueries)
     117 +}
    55 118   
Please wait...
Page is in error, reload to recover