Projects STRLCPY shodanidb Commits bc295ba4
🤬
  • ■ ■ ■ ■ ■ ■
    shodanidb.go
    skipped 67 lines
    68 68   
    69 69   targets = loadTargets(inputs, verbose)
    70 70   
    71  - channel := make(chan Response)
     71 + channel := make(chan Response, 10)
    72 72   var wg sync.WaitGroup
    73 73   
    74 74   for i := 0; i < len(targets); i++ {
    skipped 2 lines
    77 77   i := i
    78 78   
    79 79   go func() {
    80  - defer wg.Done()
    81  - jsonData := getData(targets[i], verbose)
     80 + jsonData := getData(&wg, targets[i], verbose)
    82 81   channel <- jsonData
    83 82   }()
     83 + }
    84 84   
     85 + if jsonFile == "" {
     86 + for i := 0; i < len(targets); i++ {
     87 + printResult(<-channel, noCPEs, noHostnames, noTags, noVulns, noColor)
     88 + }
    85 89   }
    86 90   
    87  - go func() {
    88  - wg.Wait()
    89  - close(channel)
    90  - }()
     91 + wg.Wait()
     92 + close(channel)
    91 93   
    92 94   if jsonFile != "" {
    93 95   saveJson(channel, jsonFile)
    94 96   return
    95  - }
    96  - 
    97  - for i := 0; i < len(targets); i++ {
    98  - printResult(<-channel, noCPEs, noHostnames, noTags, noVulns, noColor)
    99 97   }
    100 98  }
    101 99   
    skipped 23 lines
    125 123  }
    126 124   
    127 125   
    128  -func getData(ip string, verbose bool) Response {
     126 +func getData(wg *sync.WaitGroup, ip string, verbose bool) Response {
     127 + 
     128 + defer wg.Done()
    129 129   
    130 130   res, err := http.Get(
    131 131   fmt.Sprintf("https://internetdb.shodan.io/%s", ip),
    skipped 108 lines
Please wait...
Page is in error, reload to recover