Projects STRLCPY metabigor Commits aaee0e38
🤬
  • ■ ■ ■ ■ ■ ■
    modules/ip.go
    skipped 2 lines
    3 3  import (
    4 4   "fmt"
    5 5   "github.com/PuerkitoBio/goquery"
     6 + "github.com/genkiroid/cert"
    6 7   "github.com/j3ssie/metabigor/core"
    7 8   "strings"
    8 9  )
    skipped 8 lines
    17 18   return result
    18 19   }
    19 20   info := ParseOnyphe(content)
    20  - if options.Verbose {
     21 + if !options.Verbose {
    21 22   result = append(result, fmt.Sprintf("[onyphe] %v ports|%v", query, info["ports"]))
    22 23   return result
    23 24   }
    skipped 1 lines
    25 26   if key != "port" {
    26 27   result = append(result, fmt.Sprintf("[onyphe] %v %v|%v", query, key, value))
    27 28   }
     29 + }
     30 + cert := CertsInfo(query, info["ports"])
     31 + if cert != "" {
     32 + result = append(result, cert)
    28 33   }
    29 34   return result
    30 35  }
    skipped 9 lines
    40 45   return result
    41 46   }
    42 47   info := ParseShodan(content)
    43  - if options.Verbose {
     48 + if !options.Verbose {
    44 49   result = append(result, fmt.Sprintf("[shodan] %v ports|%v", query, info["ports"]))
    45 50   return result
    46 51   }
    skipped 1 lines
    48 53   if key != "port" {
    49 54   result = append(result, fmt.Sprintf("[shodan] %v %v|%v", query, key, value))
    50 55   }
     56 + }
     57 + cert := CertsInfo(query, info["ports"])
     58 + if cert != "" {
     59 + result = append(result, cert)
    51 60   }
    52 61   return result
    53 62  }
    skipped 104 lines
    158 167   
    159 168   // ports part
    160 169   var ports []string
    161  - doc.Find(".services").Each(func(i int, s *goquery.Selection) {
     170 + doc.Find(".services .service-long").Each(func(i int, s *goquery.Selection) {
    162 171   port := strings.Replace(strings.TrimSpace(s.Find(".service-details").Text()), "\n", "/", -1)
    163 172   port = strings.Replace(port, "///", "", -1)
    164 173   if port != "" {
    165 174   ports = append(ports, port)
    166 175   }
    167 176   })
     177 + //fmt.Println(ports)
    168 178   info["ports"] = strings.Join(ports, ",")
    169 179   return info
    170 180  }
    171 181   
     182 +// CertsInfo get cert info
     183 +func CertsInfo(query string, rports string) string {
     184 + var certs cert.Certs
     185 + var err error
     186 + var domains []string
     187 + cert.SkipVerify = true
     188 + ports := strings.Split(rports, ",")
     189 + 
     190 + for _, port := range ports {
     191 + if strings.Contains(port, "/") {
     192 + port = strings.Split(port, "/")[0]
     193 + }
     194 + raw := fmt.Sprintf("%v:%v", query, port)
     195 + core.DebugF("SSL Info: %v", raw)
     196 + certs, err = cert.NewCerts([]string{raw})
     197 + if err != nil {
     198 + continue
     199 + }
     200 + for _, certItem := range certs {
     201 + for _, domain := range certItem.SANs {
     202 + domains = append(domains, domain)
     203 + }
     204 + }
     205 + }
     206 + if len(domains) == 0 {
     207 + return ""
     208 + }
     209 + return fmt.Sprintf("[Cert] %v %v", query, strings.Join(domains, ","))
     210 +}
     211 + 
Please wait...
Page is in error, reload to recover