Projects STRLCPY shodanidb Commits a43d6b6d
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    README.md
    skipped 11 lines
    12 12   
    13 13  ## Usage
    14 14   
    15  -```
     15 +```shell
    16 16  echo [ip] | shodanidb [options]
    17 17   
    18 18   
    skipped 4 lines
    23 23   -nv Hide vulnerabilities
    24 24   -nocolor Disable color in output
    25 25   -json Save output to JSON format
     26 + -compare Compare new results with a JSON file
     27 + -url Show only IP and Port
    26 28   -v Verbose mode
    27 29   
    28 30   
    29  -Examples:
    30  - shodanidb [ip]
    31  - echo [ip] | shodanidb -nt
    32  - cat ips.txt | shodanidb -nh
    33  - cat ips.txt | shodanidb -json output.json
    34  - cat 8.8.8.0/24 | shodanidb
     31 +# Simple Usage:
     32 +echo 149.202.182.140 | shodanidb
     33 + 
     34 +# CIDR Input:
     35 +echo 149.202.182.140/24 | shodanidb
     36 + 
     37 +# Use Filters (Hide CPEs, Hostnames and Tags):
     38 +echo 149.202.182.140 | shodanidb -nc -nh -nt
     39 + 
     40 +# Show Only IP and Ports:
     41 +echo 149.202.182.140/24 | shodanidb -url
     42 + 
     43 +# Save Output to a JSON File:
     44 +cat ips.txt | shodanidb -json output.json
     45 + 
     46 +# Show New Results by Comparing With The Old JSON File:
     47 +cat ips.txt | shodanidb -compare output.json
     48 + 
    35 49  ```
    36 50   
    37 51   
    skipped 1 lines
    39 53   
    40 54  The original tool is [nrich](https://gitlab.com/shodan-public/nrich). I wanted to learn Go and write this tool with Go for practice.
    41 55   
     56 +Also the idea for `-url` switch was gotten from [sdlookup](https://github.com/j3ssie/sdlookup).
  • ■ ■ ■ ■ ■
    shodanidb.go
    skipped 52 lines
    53 53   var compareFile string
    54 54   flag.StringVar(&compareFile, "compare", "", "Compare data with a JSON file")
    55 55   
     56 + var url bool
     57 + flag.BoolVar(&url, "url", false, "Show URLs only")
     58 + 
    56 59   flag.Parse()
    57 60   
    58 61   
    skipped 29 lines
    88 91   
    89 92   if jsonFile == "" && compareFile == "" {
    90 93   for i := 0; i < len(targets); i++ {
    91  - printResult(<-channel, noCPEs, noHostnames, noTags, noVulns, noColor)
     94 + printResult(<-channel, noCPEs, noHostnames, noTags, noVulns, noColor, url)
    92 95   }
    93 96   }
    94 97   
    skipped 181 lines
    276 279  }
    277 280   
    278 281   
    279  -func printResult(jsonData Response, noCPEs bool, noHostnames bool, noTags bool, noVulns bool, noColor bool) {
     282 +func printResult(jsonData Response, noCPEs bool, noHostnames bool, noTags bool, noVulns bool, noColor bool, url bool) {
    280 283   
    281 284   builder := &strings.Builder{}
    282 285   
    skipped 1 lines
    284 287   return
    285 288   }
    286 289   
    287  - fmt.Println(jsonData.IP)
     290 + ports := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jsonData.Ports)), ", "), "[]")
    288 291   
    289  - ports := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(jsonData.Ports)), ", "), "[]")
     292 + if url {
     293 + if (jsonData.Ports == nil) {
     294 + return
     295 + }
     296 + for _, port := range jsonData.Ports {
     297 + fmt.Println(jsonData.IP + ":" + fmt.Sprint(port))
     298 + }
     299 + return
     300 + }
     301 + 
     302 + fmt.Println(jsonData.IP)
    290 303   
    291 304   if !noColor {
    292 305   builder.WriteString("Ports: " + aurora.Green(ports).String() + "\n")
    skipped 42 lines
Please wait...
Page is in error, reload to recover