├── LICENSE ├── README.md └── main.go /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Javier Olmedo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

ipdiscover

2 |

🔍 A simple tool to obtain long lists of ips from domains using goroutines

3 |

4 | 5 | 6 | 7 | 8 | 9 |

10 | 11 | ## About ipdiscover 12 | ipdiscover is a golang tool designed to obtain long lists of IPs from domains. It helps penetration tester and bug bounty hunters to quickly collect IPs to work with other tools, for example, nmap. 13 | 14 | ## Install 15 | 16 | ``` 17 | ▶ go get -u github.com/JavierOlmedo/ipdiscover 18 | ``` 19 | 20 | ## Usage 21 | 22 | ipdiscover accepts line-delimited domains on `stdin`: 23 | 24 | ``` 25 | ▶ cat domains.txt 26 | google.es 27 | google.net 28 | google.com 29 | google.edu 30 | ▶ cat domains.txt | ipdiscover 31 | google.es;172.217.16.227 32 | google.net;216.58.211.36 33 | google.com;172.217.17.14 34 | google.edu;Unknown 35 | ``` 36 | 37 | Only one domain: 38 | ``` 39 | ▶ ipdiscover google.es 40 | google.es;172.217.16.227 41 | ``` 42 | 43 | ## Concurrency 44 | 45 | You can set the concurrency level with the `-t` flag and specifying a number (default 23 concurrencies): 46 | 47 | ``` 48 | ▶ cat domains.txt | ipdiscover -t 99 49 | ``` 50 | 51 | ## All IPs Nslookup 52 | 53 | You can get all ips of a domain that solves nslookup using the `-a` flag: 54 | 55 | ``` 56 | ▶ cat domains.txt | ipdiscover -a 57 | ``` 58 | 59 | ## Credit 60 | This tool was inspired by @tomnomnom [scripts](https://github.com/tomnomnom?utf8=%E2%9C%93&tab=repositories&q=&type=&language=go). Thanks to them I learned to program in Go! 61 | 62 | > *Made with ❤️ in Spain* -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "flag" 6 | "fmt" 7 | "io" 8 | "net" 9 | "os" 10 | "strings" 11 | "sync" 12 | ) 13 | 14 | func main() { 15 | 16 | var all bool 17 | var threads int 18 | flag.BoolVar(&all, "a", false, "Get all IPs found") 19 | flag.IntVar(&threads, "t", 23, "Set numbers of threads")// ¯\_(ツ)_/¯ 20 | flag.Parse() 21 | 22 | var domains io.Reader 23 | domains = os.Stdin 24 | 25 | domain := flag.Arg(0) 26 | if domain != "" { 27 | domains = strings.NewReader(domain) 28 | } 29 | 30 | out := make(chan string) 31 | var wg sync.WaitGroup 32 | 33 | for i := 0; i < threads; i++ { 34 | wg.Add(1) 35 | 36 | go func() { 37 | 38 | for u := range out { 39 | ip := getIP(u) 40 | 41 | if len(ip) == 0 { 42 | fmt.Println(strings.Join([]string{u, ";", "Unknown"}, "")) 43 | continue 44 | } 45 | 46 | if all { 47 | for _, i := range ip { 48 | fmt.Println(strings.Join([]string{u, ";", i}, "")) 49 | } 50 | 51 | } else { 52 | fmt.Println(strings.Join([]string{u, ";", ip[0:1][0]}, "")) 53 | } 54 | } 55 | 56 | wg.Done() 57 | }() 58 | } 59 | 60 | sc := bufio.NewScanner(domains) 61 | for sc.Scan() { 62 | domain := strings.ToLower(sc.Text()) 63 | out <- domain 64 | } 65 | 66 | close(out) 67 | 68 | if err := sc.Err(); err != nil { 69 | fmt.Fprintf(os.Stderr, "failed to read input: %s\n", err) 70 | } 71 | 72 | wg.Wait() 73 | } 74 | 75 | func getIP(domain string) []string { 76 | var array []string 77 | 78 | addrs, err := net.LookupIP(domain) 79 | if err != nil { 80 | return nil 81 | } 82 | 83 | for _, addr := range addrs { 84 | array = append(array, addr.String()) 85 | } 86 | return array 87 | } 88 | --------------------------------------------------------------------------------