Projects STRLCPY metabigor Commits 70415a12
🤬
  • ■ ■ ■ ■ ■ ■
    cmd/net.go
    skipped 109 lines
    110 110   wg.Done()
    111 111   }()
    112 112   
     113 + wg.Add(1)
     114 + go func() {
     115 + data = append(data, modules.OrgBgbView(options)...)
     116 + wg.Done()
     117 + }()
     118 + 
    113 119   // disable when enable trusted source
    114 120   if !options.Net.Optimize {
    115 121   wg.Add(1)
    skipped 37 lines
  • ■ ■ ■ ■ ■
    core/request.go
    skipped 3 lines
    4 4   "context"
    5 5   "crypto/tls"
    6 6   "fmt"
     7 + "log"
     8 + "os"
     9 + "path"
     10 + "path/filepath"
    7 11   "strconv"
    8 12   "strings"
    9 13   "time"
    skipped 4 lines
    14 18   
    15 19  // RequestWithChrome Do request with real browser
    16 20  func RequestWithChrome(url string, contentID string) string {
    17  - // opts := append(chromedp.DefaultExecAllocatorOptions[:],
    18  - // chromedp.Flag("headless", false),
    19  - // chromedp.Flag("disable-gpu", true),
    20  - // chromedp.Flag("enable-automation", true),
    21  - // chromedp.Flag("disable-extensions", false),
    22  - // )
    23  - ctx, cancel := chromedp.NewContext(context.Background())
     21 + // prepare the chrome options
     22 + opts := append(chromedp.DefaultExecAllocatorOptions[:],
     23 + chromedp.Flag("headless", true),
     24 + chromedp.Flag("ignore-certificate-errors", true),
     25 + chromedp.Flag("disable-gpu", true),
     26 + chromedp.Flag("enable-automation", true),
     27 + chromedp.Flag("disable-extensions", true),
     28 + chromedp.Flag("disable-setuid-sandbox", true),
     29 + chromedp.Flag("disable-web-security", true),
     30 + chromedp.Flag("no-first-run", true),
     31 + chromedp.Flag("no-default-browser-check", true),
     32 + )
     33 + 
     34 + allocCtx, bcancel := chromedp.NewExecAllocator(context.Background(), opts...)
     35 + allocCtx, bcancel = context.WithTimeout(allocCtx, 10*time.Second)
     36 + defer bcancel()
     37 + 
     38 + ctx, cancel := chromedp.NewContext(allocCtx, chromedp.WithLogf(log.Printf))
    24 39   ctx, cancel = context.WithTimeout(ctx, 10*time.Second)
    25 40   defer cancel()
    26 41   
    skipped 1 lines
    28 43   var data string
    29 44   err := chromedp.Run(ctx,
    30 45   chromedp.Navigate(url),
    31  - // chromedp.WaitVisible(contentID),
    32 46   chromedp.OuterHTML(contentID, &data, chromedp.NodeVisible, chromedp.ByID),
    33 47   )
     48 + 
     49 + // clean chromedp-runner folder
     50 + cleanUp()
     51 + 
    34 52   if err != nil {
    35 53   return ""
    36 54   }
     55 + return data
     56 +}
    37 57   
    38  - return data
     58 +func cleanUp() {
     59 + tmpFolder := path.Join(os.TempDir(), "chromedp-runner*")
     60 + if _, err := os.Stat("/tmp/"); !os.IsNotExist(err) {
     61 + tmpFolder = path.Join("/tmp/", "chromedp-runner*")
     62 + }
     63 + junks, err := filepath.Glob(tmpFolder)
     64 + if err != nil {
     65 + return
     66 + }
     67 + for _, junk := range junks {
     68 + os.RemoveAll(junk)
     69 + }
    39 70  }
    40 71   
    41 72  // SendGET just send GET request
    skipped 115 lines
  • ■ ■ ■ ■
    core/version.go
    skipped 1 lines
    2 2   
    3 3  const (
    4 4   // VERSION current Metabigor version
    5  - VERSION = "beta v1.3"
     5 + VERSION = "beta v1.4"
    6 6   // AUTHOR author of this
    7 7   AUTHOR = "@j3ssiejjj"
    8 8  )
    skipped 1 lines
  • ■ ■ ■ ■ ■ ■
    modules/netblock.go
    skipped 170 lines
    171 171   return result
    172 172  }
    173 173   
     174 + 
     175 +// OrgBgbView get Org infor from bgpview.io
     176 +func OrgBgbView(options core.Options) []string {
     177 + org := options.Net.Org
     178 + url := fmt.Sprintf(`https://bgpview.io/search/%v`, org)
     179 + core.InforF("Get data from: %v", url)
     180 + var result []string
     181 + content := core.RequestWithChrome(url, "results-tabs")
     182 + doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
     183 + if err != nil {
     184 + return result
     185 + }
     186 + 
     187 + // searching for data
     188 + doc.Find("a").Each(func(i int, s *goquery.Selection) {
     189 + href, _ := s.Attr("href")
     190 + // https://bgpview.io/prefix/176.96.254.0/24
     191 + if strings.Contains(href, "https://bgpview.io/prefix/") {
     192 + //cidr := strings.Replace(href, "https://bgpview.io/prefix/", "", -1)
     193 + cidr := s.Text()
     194 + result = append(result, fmt.Sprintf("%s", cidr))
     195 + }
     196 + })
     197 + return result
     198 +}
     199 + 
    174 200  // ASNLookup get Org CIDR from asnlookup
    175 201  func ASNLookup(options core.Options) []string {
    176 202   org := options.Net.Org
    skipped 18 lines
Please wait...
Page is in error, reload to recover