├── README.md ├── requirements.txt └── reverseip.py /README.md: -------------------------------------------------------------------------------- 1 | # reverseip_py 2 | Domain parser for IPAddress.com Reverse IP Lookup. Writen in Python 3. 3 | 4 | ## What is Reverse IP? 5 | Reverse IP refers to the process of looking up all the domain names that are hosted on a particular IP address. This can be useful for a variety of reasons, such as identifying all the websites that are hosted on a shared hosting server or finding out which websites are hosted on the same IP address as a particular website. 6 | 7 | ## Requirements 8 | - beautifulsoup4 9 | - requests 10 | - urllib3 11 | 12 | Tested on **Debian** with **Python 3.10.8** 13 | 14 | ### Install Requirements 15 | ``` 16 | pip3 install -r requirements.txt 17 | ``` 18 | ## How to Use 19 | Help Menu 20 | ``` 21 | python3 reverseip.py -h 22 | usage: reverseip.py [-h] [-t target.com] 23 | 24 | options: 25 | -h, --help show this help message and exit 26 | -t target.com, --target target.com 27 | Target domain or IP 28 | ``` 29 | Reverse IP 30 | ``` 31 | python3 reverseip.py -t google.com 32 | ``` 33 | ## Screenshot 34 | ![ReverseIP](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhM4Z6zSF5yjADs6toEeqYSJs71tGp-8H-E4t0udDQ5qUBqHXOa5fFaUGowEvVSpKw5vSeuBPaGwRrDOsl3TxYB2P9MYC-5gWw9ued2E4iFWybbJz_yiargjToQpYMnalQtiQja7kVOmc1nQfsHLc7xB2wh_BHZ1NWOUABHOYGh0wdCkApkoEl7GvfH0A/s742/reverse-ip.png "ReverseIP") 35 | 36 | ## Disclaimer 37 | Any actions and or activities related to the material contained within this tool is solely your responsibility.The misuse of the information in this tool can result in criminal charges brought against the persons in question. 38 | 39 | Note: modifications, changes, or changes to this code can be accepted, however, every public release that uses this code must be approved by author of this tool (yuyudhn). -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4 2 | requests 3 | urllib3 4 | -------------------------------------------------------------------------------- /reverseip.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | import sys 3 | import urllib3 4 | import argparse 5 | import requests 6 | from requests import RequestException 7 | from bs4 import BeautifulSoup as bs 8 | import sys 9 | import re 10 | import io 11 | 12 | urllib3.disable_warnings() 13 | parser = argparse.ArgumentParser() 14 | parser.add_argument('-t', '--target', metavar='target.com', type=str, help='Target domain or IP') 15 | args = parser.parse_args() 16 | ip_target = args.target 17 | ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.5304.107 Safari/537.36" 18 | 19 | #Target validator 20 | def argscheck(): 21 | if len(sys.argv)==1: 22 | parser.print_help(sys.stderr) 23 | sys.exit(1) 24 | elif ip_target == None: 25 | parser.print_help(sys.stderr) 26 | print() 27 | print(f"Error: Target is mandatory") 28 | sys.exit(1) 29 | elif "://" in ip_target: 30 | print(f"Input only IP or domain. Example: target.com") 31 | sys.exit(1) 32 | def re_addr(): 33 | headers = { 34 | 'Origin': 'https://www.ipaddress.com', 35 | 'User-Agent': ua, 36 | 'Content-Type': 'application/x-www-form-urlencoded' 37 | } 38 | payload = {"host" : ip_target} 39 | ipaddr_host = "https://www.ipaddress.com/reverse-ip-lookup" 40 | fn = ip_target+".txt" 41 | try: 42 | r = requests.post(ipaddr_host, data=payload, headers=headers) 43 | rd = r.text 44 | soup = bs(rd, 'html.parser') 45 | hx = soup.find(string = re.compile("We found no hostnames for")) 46 | hr = soup.find(string = re.compile("Hostname could not be resolved to an IP address")) 47 | hf = soup.find(string = re.compile(r"We found\ (\d+) hostnames for")) 48 | _mip = soup.find(string = re.compile("resolves to more than one IP address. Please select one from the list below.")) 49 | if _mip: 50 | try: 51 | for _aip in soup.find_all("input", {"name": "host"}): 52 | _ipv4 = _aip.get('value') 53 | if _ipv4: 54 | _mtarget = _ipv4 55 | payload = {"host" : _mtarget} 56 | print(f"Retrieving domain from {_mtarget}") 57 | r = requests.post(ipaddr_host, data=payload, headers=headers) 58 | rd = r.text 59 | soup = bs(rd, 'html.parser') 60 | for h in soup.findAll('ol'): 61 | dcount = 0 62 | par = h.find_all('a', attrs={'href': re.compile("https://www.ipaddress.com/site/")}) 63 | for link in par: 64 | dcount += 1 65 | dl = link.text 66 | with io.open(fn, "a") as f: 67 | f.write(dl + '\n') 68 | f.close() 69 | print(f"Found {dcount} domain for {_mtarget}") 70 | else: 71 | pass 72 | except: 73 | print("Error!") 74 | finally: 75 | print(f"Result saved at {fn}") 76 | elif hx: 77 | print(f"Found 0 domain for {ip_target}") 78 | elif hr: 79 | print(f"Domain or IP not Resolved") 80 | elif hf: 81 | for h in soup.findAll('ol'): 82 | dcount = 0 83 | par = h.find_all('a', attrs={'href': re.compile("https://www.ipaddress.com/site/")}) 84 | for link in par: 85 | dcount += 1 86 | dl = link.text 87 | with io.open(fn, "a") as f: 88 | f.write(dl + '\n') 89 | f.close() 90 | print(f"Found {dcount} domain for {ip_target}") 91 | print(f"Result saved at {fn}") 92 | else: 93 | print(f"Error!") 94 | except RequestException as err: 95 | print(f"{type(err).__name__} was raised: {err}") 96 | if __name__ == '__main__': 97 | try: 98 | argscheck() 99 | re_addr() 100 | except Exception as err: 101 | print(f"{type(err).__name__} was raised: {err}") 102 | --------------------------------------------------------------------------------