├── requierements.txt ├── README.md └── shodomain.py /requierements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | sys 3 | json 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
3 | Shodan 4 |
5 | Shodomain 6 |
7 |

8 | 9 |

Shodan subdomain finder

10 | 11 | 12 | ### Introduction 13 | Shodomain is a python script able to grab and print subdomains from shodan API. 14 | 15 | ![demo](https://i.imgur.com/TiuvTD3.png) 16 | 17 | ### Requirements 18 | Shodomain only works with `Python 2` and has the following depencies: 19 | 20 | - `sys` 21 | - `requests` 22 | - `json` 23 | 24 | To install these dependencies, navigate to Shodomain directory and execute `pip install -r requirements.txt` 25 | 26 | ### Usage 27 | Using shodomain is pretty simple 28 | 29 | `python shodomain.py API-KEY example.com` 30 | 31 | -------------------------------------------------------------------------------- /shodomain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import requests, sys, json 3 | 4 | def tldSorting(subdomainList): 5 | localsortedlist = list() 6 | finallist = list() 7 | for item in subdomainList: 8 | Reverseddomain = ".".join(str(item).split('.')[::-1]) 9 | localsortedlist.append(Reverseddomain) 10 | 11 | sortedlist = sorted(localsortedlist) 12 | 13 | for item in sortedlist: 14 | reReverseddomain = ".".join(str(item).split('.')[::-1]) 15 | finallist.append(reReverseddomain) 16 | 17 | return finallist 18 | 19 | if __name__ == "__main__": 20 | if len (sys.argv) != 3 : 21 | print("Shodan Subdomain Finder by SmoZy\n\nUsage: ./shodan.py [API Key] [Domain]") 22 | sys.exit (1) 23 | 24 | apikey = sys.argv[1] 25 | domain = sys.argv[2] 26 | 27 | r =requests.get('https://api.shodan.io/dns/domain/' + domain + '?key=' + apikey) 28 | data = json.loads(r.text) 29 | subdomains = set() 30 | for item in data["data"]: 31 | entry = item["subdomain"] 32 | record_type = item["type"] 33 | value = item["value"] 34 | if record_type == 'CNAME' and domain in value: 35 | delim = value.split('.') 36 | match = delim[-2] + '.' + delim[-1] 37 | if match == domain: 38 | subdomains.add(value) 39 | 40 | for s in tldSorting(subdomains): 41 | print(s) 42 | 43 | --------------------------------------------------------------------------------