Projects STRLCPY metabigor Commits fbbb71b9
🤬
  • ■ ■ ■ ■
    README.md
    skipped 1 lines
    2 2   <img alt="Metabigor" src="https://image.flaticon.com/icons/svg/2303/2303030.svg" height="140" />
    3 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.1-red.svg"></a>
     5 + <a href="https://github.com/j3ssie/metabigor"><img alt="Release" src="https://img.shields.io/badge/version-1.5-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>
    skipped 36 lines
    45 45   
    46 46  # search result on fofa
    47 47  echo 'title="RabbitMQ Management"' | metabigor search -x -v -o /tmp/result.txt
     48 + 
     49 +# search IP on shodan
     50 +echo '1.2.3.4' | metabigor ip -s 'shodan' -v
    48 51  ```
    49 52   
    50 53  ## Credits
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    cmd/ip.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 +func init() {
     15 + var ipCmd = &cobra.Command{
     16 + Use: "ip",
     17 + Short: "IP OSINT Search",
     18 + Long: fmt.Sprintf(`Metabigor - Intelligence Tool but without API key - %v by %v`, core.VERSION, core.AUTHOR),
     19 + RunE: runIP,
     20 + }
     21 + 
     22 + ipCmd.Flags().StringP("source", "s", "all", "Search Engine Select")
     23 + ipCmd.Flags().StringSliceP("query", "q", []string{}, "Query to search (Multiple -q flags are accepted)")
     24 + RootCmd.AddCommand(ipCmd)
     25 +}
     26 + 
     27 +func runIP(cmd *cobra.Command, _ []string) error {
     28 + options.Search.Source, _ = cmd.Flags().GetString("source")
     29 + options.Search.Source = strings.ToLower(options.Search.Source)
     30 + options.Search.More, _ = cmd.Flags().GetBool("brute")
     31 + options.Search.Optimize, _ = cmd.Flags().GetBool("optimize")
     32 + queries, _ := cmd.Flags().GetStringSlice("query")
     33 + 
     34 + var inputs []string
     35 + if options.Input != "-" && options.Input != "" {
     36 + if strings.Contains(options.Input, "\n") {
     37 + inputs = strings.Split(options.Input, "\n")
     38 + } else {
     39 + inputs = append(inputs, options.Input)
     40 + }
     41 + }
     42 + if len(queries) > 0 {
     43 + inputs = append(inputs, queries...)
     44 + }
     45 + if len(inputs) == 0 {
     46 + core.ErrorF("No input found")
     47 + os.Exit(1)
     48 + }
     49 + 
     50 + if options.Search.More {
     51 + inputs = addMoreQuery(inputs, options)
     52 + }
     53 + 
     54 + var wg sync.WaitGroup
     55 + jobs := make(chan string)
     56 + 
     57 + for i := 0; i < options.Concurrency; i++ {
     58 + wg.Add(1)
     59 + go func() {
     60 + defer wg.Done()
     61 + // do real stuff here
     62 + for job := range jobs {
     63 + searchResult := runIPSingle(job, options)
     64 + StoreData(searchResult, options)
     65 + }
     66 + }()
     67 + }
     68 + 
     69 + for _, input := range inputs {
     70 + jobs <- input
     71 + }
     72 + 
     73 + close(jobs)
     74 + wg.Wait()
     75 + 
     76 + if !core.FileExists(options.Output) {
     77 + core.ErrorF("No data found")
     78 + }
     79 + core.DebugF("Unique Output: %v", options.Output)
     80 + core.Unique(options.Output)
     81 + return nil
     82 +}
     83 + 
     84 +func runIPSingle(input string, options core.Options) []string {
     85 + var data []string
     86 + core.BannerF(fmt.Sprintf("Search on %v for: ", options.Search.Source), input)
     87 + if options.Search.Source == "all" {
     88 + options.Search.Source = "ony,shodan"
     89 + }
     90 + options.Search.Query = input
     91 + 
     92 + // select source
     93 + if strings.Contains(options.Search.Source, "ony") {
     94 + data = append(data, modules.Onyphe(options.Search.Query, options)...)
     95 + }
     96 + 
     97 + if strings.Contains(options.Search.Source, "sho") {
     98 + data = append(data, modules.Shodan(options.Search.Query, options)...)
     99 + }
     100 + 
     101 + return data
     102 +}
     103 + 
  • ■ ■ ■ ■
    core/request.go
    skipped 32 lines
    33 33   
    34 34  // JustSend just sending request
    35 35  func JustSend(options Options, method string, url string, headers map[string]string) (res Response, err error) {
    36  - 
    37 36   timeout := options.Timeout
    38 37   
    39 38   // disable log when retry
    skipped 21 lines
    61 60   client.SetTimeout(time.Duration(timeout) * time.Second)
    62 61   client.SetRetryWaitTime(time.Duration(timeout/2) * time.Second)
    63 62   client.SetRetryMaxWaitTime(time.Duration(timeout) * time.Second)
     63 + 
     64 + if options.Proxy != "" {
     65 + client.SetProxy(options.Proxy)
     66 + }
    64 67   
    65 68   var resp *resty.Response
    66 69   // really sending things here
    skipped 83 lines
  • ■ ■ ■ ■
    core/version.go
    skipped 1 lines
    2 2   
    3 3  const (
    4 4   // VERSION current Metabigor version
    5  - VERSION = "beta v1.4"
     5 + VERSION = "beta v1.5"
    6 6   // AUTHOR author of this
    7 7   AUTHOR = "@j3ssiejjj"
    8 8  )
    skipped 1 lines
  • ■ ■ ■ ■ ■
    modules/ip.go
    skipped 15 lines
    16 16   if content == "" {
    17 17   return result
    18 18   }
    19  - data := ParseOnyphe(content, options)
     19 + info := ParseOnyphe(content)
     20 + if options.Verbose {
     21 + result = append(result, fmt.Sprintf("[onyphe] %v ports|%v", query, info["ports"]))
     22 + return result
     23 + }
     24 + for key, value := range info {
     25 + if key != "port" {
     26 + result = append(result, fmt.Sprintf("[onyphe] %v %v|%v", query, key, value))
     27 + }
     28 + }
     29 + return result
     30 +}
    20 31   
    21  - for _, item := range data {
    22  - result = append(result, fmt.Sprintf("%v:%v", query, item))
     32 +// Shodan get IPInfo from https://www.shodan.io
     33 +func Shodan(query string, options core.Options) []string {
     34 + url := fmt.Sprintf(`https://www.shodan.io/host/%v`, query)
     35 + var result []string
     36 + core.InforF("Get data from: %v", url)
     37 + content := core.SendGET(url, options)
     38 + if content == "" {
     39 + core.DebugF("Error in sending to Shodan")
     40 + return result
     41 + }
     42 + info := ParseShodan(content)
     43 + if options.Verbose {
     44 + result = append(result, fmt.Sprintf("[shodan] %v ports|%v", query, info["ports"]))
     45 + return result
     46 + }
     47 + for key, value := range info {
     48 + if key != "port" {
     49 + result = append(result, fmt.Sprintf("[shodan] %v %v|%v", query, key, value))
     50 + }
    23 51   }
    24 52   return result
    25 53  }
    26 54   
    27 55  // ParseOnyphe parsing data from Onyphe
    28  -func ParseOnyphe(content string, options core.Options) []string {
    29  - var result []string
     56 +func ParseOnyphe(content string) map[string]string {
     57 + info := make(map[string]string)
     58 + 
    30 59   doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
    31 60   if err != nil {
    32  - return result
     61 + core.DebugF("Error parsing HTML")
     62 + return info
    33 63   }
    34 64   
    35 65   // searching for data
    36  - info := make(map[string]string)
    37 66   doc.Find(".features-list").Each(func(i int, s *goquery.Selection) {
    38 67   text := s.Text()
    39 68   // basic info part
    40 69   if strings.Contains(text, "geoloc") {
    41  - tds := s.Find("td").Children()
    42  - if strings.Contains(tds.Text(), "organization") {
    43  - for i := range tds.Nodes {
    44  - if i == 0 {
    45  - tag := tds.Eq(i)
    46  - data := tds.Eq(i + 1)
    47  - info[tag.Text()] = data.Text()
    48  - continue
    49  - }
    50  - if i%2 != 0 {
    51  - tag := tds.Eq(i)
    52  - data := tds.Eq(i + 1)
    53  - info[tag.Text()] = data.Text()
    54  - }
     70 + s.Find("tr").Each(func(i int, tr *goquery.Selection) {
     71 + text := tr.Text()
     72 + if strings.Contains(text, "organization") {
     73 + organization := strings.Replace(text, "organization", "", -1)
     74 + info["organization"] = organization
     75 + }
     76 + 
     77 + if strings.Contains(text, "asn") {
     78 + asn := strings.Replace(text, "asn", "", -1)
     79 + info["asn"] = asn
     80 + }
     81 + 
     82 + if strings.Contains(text, "subnet") {
     83 + subnet := strings.Replace(text, "subnet", "", -1)
     84 + info["subnet"] = subnet
     85 + }
     86 + 
     87 + if strings.Contains(text, "city") {
     88 + city := strings.Replace(text, "city", "", -1)
     89 + info["city"] = city
     90 + }
     91 + 
     92 + if strings.Contains(text, "country") {
     93 + country := strings.Replace(text, "country", "", -1)
     94 + info["country"] = country
    55 95   }
    56  - }
     96 + })
    57 97   }
     98 + 
    58 99   // open port
    59 100   if strings.Contains(text, "synscan") {
    60  - var port string
     101 + var ports []string
    61 102   s.Find("a").Each(func(i int, tag *goquery.Selection) {
    62 103   href, _ := tag.Attr("href")
    63 104   if strings.Contains(href, "port") {
    64  - port = tag.Text()
    65  - result = append(result, port)
     105 + port := tag.Text()
     106 + ports = append(ports, port)
     107 + }
     108 + })
     109 + info["ports"] = strings.Join(ports, ",")
     110 + }
     111 + })
     112 + return info
     113 +}
     114 + 
     115 +// ParseShodan parsing data from Onyphe
     116 +func ParseShodan(content string) map[string]string {
     117 + info := make(map[string]string)
     118 + doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
     119 + if err != nil {
     120 + core.DebugF("Error parsing HTML")
     121 + return info
     122 + }
     123 + 
     124 + // searching for data
     125 + doc.Find(".table").Each(func(i int, s *goquery.Selection) {
     126 + text := s.Text()
     127 + // basic info part
     128 + if strings.Contains(text, "Country") {
     129 + s.Find("tr").Each(func(i int, tr *goquery.Selection) {
     130 + text := tr.Text()
     131 + if strings.Contains(text, "Organization") {
     132 + organization := strings.Replace(text, "Organization", "", -1)
     133 + info["organization"] = strings.TrimSpace(organization)
     134 + }
     135 + 
     136 + if strings.Contains(text, "ASN") {
     137 + asn := strings.Replace(text, "ASN", "", -1)
     138 + info["asn"] = strings.TrimSpace(asn)
     139 + }
     140 + 
     141 + if strings.Contains(text, "ISP") {
     142 + ISP := strings.Replace(text, "ISP", "", -1)
     143 + info["isp"] = strings.TrimSpace(ISP)
     144 + }
     145 + 
     146 + if strings.Contains(text, "Hostnames") {
     147 + hostnames := strings.Replace(text, "Hostnames", "", -1)
     148 + info["hostnames"] = strings.TrimSpace(hostnames)
     149 + }
     150 + 
     151 + if strings.Contains(text, "Country") {
     152 + country := strings.Replace(text, "Country", "", -1)
     153 + info["country"] = strings.TrimSpace(country)
    66 154   }
    67 155   })
    68 156   }
    69 157   })
    70 158   
    71  - // more info in verbose mode
    72  - if options.Verbose {
    73  - for k, v := range info {
    74  - data := fmt.Sprintf("%v|%v", k, v)
    75  - result = append(result, data)
     159 + // ports part
     160 + var ports []string
     161 + doc.Find(".services").Each(func(i int, s *goquery.Selection) {
     162 + port := strings.Replace(strings.TrimSpace(s.Find(".service-details").Text()), "\n", "/", -1)
     163 + port = strings.Replace(port, "///", "", -1)
     164 + if port != "" {
     165 + ports = append(ports, port)
    76 166   }
    77  - }
    78  - return result
     167 + })
     168 + info["ports"] = strings.Join(ports, ",")
     169 + return info
    79 170  }
    80 171   
  • ■ ■ ■ ■ ■ ■
    modules/ip_test.go
    skipped 7 lines
    8 8   
    9 9  func TestParseOnyphe(t *testing.T) {
    10 10   var options core.Options
     11 + options.Verbose = true
    11 12   raw := core.GetFileContent("/tmp/testttt/ony.html")
    12  - result := ParseOnyphe(raw, options)
     13 + result := ParseOnyphe(raw)
    13 14   fmt.Println(result)
    14 15   if len(result) == 0 {
    15 16   t.Errorf("Error parseOnyphe")
    16 17   }
     18 +}
    17 19   
     20 +func TestParseShodan(t *testing.T) {
     21 + var options core.Options
     22 + options.Verbose = true
     23 + raw := core.GetFileContent("/tmp/testttt/shodan.html")
     24 + result := ParseShodan(raw)
     25 + fmt.Println(result)
     26 + if len(result) == 0 {
     27 + t.Errorf("Error parseOnyphe")
     28 + }
    18 29  }
    19 30   
Please wait...
Page is in error, reload to recover