Advertisement
JamesBops

Untitled

Jan 19th, 2023
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #@CallMeRep
  3. #Reverse IP With CIDR Ranger Support Type of list like
  4. #google.com
  5. #google.com/16
  6. #https://google.com
  7. #1.1.1.1
  8. #1.1.1.1/16
  9. #https://google.com/asumemek/kontolgoreng
  10. #if you want add banned subdomains just input the subdomain. in banned_subdomains.txt
  11. #if your list already have cidr just input the cidr "auto"
  12. #if you dont want using cidr/range ip just input "0"
  13.  
  14. from threading import *
  15. from threading import Thread
  16. from queue import Queue
  17. from socket import gethostbyname
  18. import requests,re ,os, socket, os, urllib3, validators
  19. from urllib.parse import urlparse
  20. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  21. from netaddr import IPNetwork
  22.  
  23.  
  24. class Worker(Thread):
  25. def __init__(self, tasks):
  26. Thread.__init__(self)
  27. self.tasks = tasks
  28. self.daemon = True
  29. self.start()
  30.  
  31. def run(self):
  32. while True:
  33. func, args, kargs = self.tasks.get()
  34. try: func(*args, **kargs)
  35. except Exception as e: print(e)
  36. self.tasks.task_done()
  37.  
  38. class ThreadPool:
  39. def __init__(self, num_threads):
  40. self.tasks = Queue(num_threads)
  41. for _ in range(num_threads): Worker(self.tasks)
  42.  
  43. def add_task(self, func, *args, **kargs):
  44. self.tasks.put((func, args, kargs))
  45.  
  46. def wait_completion(self):
  47. self.tasks.join()
  48.  
  49. class RevIP:
  50. def __init__(self, iplist):
  51. self.result = []
  52. self.ip = iplist
  53. self.cidr = input("cidr : ")
  54. self.thread = input("thread : ")
  55.  
  56. def domainToIP(self):
  57. try:
  58. if self.ip.startswith( "http" ) or self.ip.startswith( "https" ):
  59. self.ip = urlparse(self.ip).netloc
  60. if "/" in self.ip:
  61. if self.ip.endswith("/"): self.ip = self.ip[:-1]
  62. cidrf = re.findall("/(.*)", self.ip)
  63. if cidrf: self.cidr = cidrf[0]
  64. ipf = re.findall("(.*)/", self.ip)
  65. if ipf : self.ip = ipf[0]
  66. self.ip = socket.gethostbyname( self.ip )
  67. except:
  68. pass
  69.  
  70.  
  71.  
  72. def rev(self,ips):
  73. head = {
  74. 'Origin': 'https://www.ipaddress.com',
  75. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.5304.107 Safari/537.36',
  76. 'Content-Type': 'application/x-www-form-urlencoded'
  77. }
  78. data = {"host" : ips}
  79. try:
  80. r = requests.post("https://www.ipaddress.com/reverse-ip-lookup", data=data, headers=head, timeout=25, verify=False, allow_redirects=False).text
  81. if "We found no hostnames for " not in r:
  82. selector = re.findall("site\/(.*?)\"", r)
  83. print(f"ip : {ips} result: {len(selector)}")
  84. for results in selector:
  85. results = results.replace("\n", "").replace("\r", "")
  86. banSubdo = open('banned_subdomains.txt', 'r').read().splitlines()
  87. site = re.sub(r'[^A-Za-z0-9.\\-]','', results)
  88. for ban in banSubdo:site = site.replace(ban, "")
  89. if site not in self.result:
  90. self.result.append(site)
  91. open( "reversed.txt", "a" ).write( site + "\n" )
  92. return self.result
  93.  
  94. else:
  95. print(f"ip : {ips} BAD-IPS [No-Results]")
  96.  
  97. except Exception as e:
  98.  
  99. print(e)
  100. pass
  101.  
  102. def ranger(self, cidr):
  103. pool = ThreadPool(int(self.thread))
  104. print(f"( ip : {self.ip} cidr : {cidr} )")
  105. for ip in IPNetwork(f"{self.ip}/{cidr}"):
  106. pool.add_task( self.rev, ip )
  107. print(f"list: {self.ip}/{cidr} total result: {len(self.result)}")
  108. pool.wait_completion()
  109.  
  110. def execute(self):
  111. pool2 = ThreadPool(int(self.thread))
  112. for url in self.ip:
  113. self.ip = url
  114. self.domainToIP()
  115. if self.cidr != "0" or self.cidr == "auto":
  116. self.ranger(self.cidr)
  117. else:
  118. pool2.add_task( self.rev, self.ip )
  119. pool2.wait_completion()
  120. print("Done Script")
  121.  
  122. if __name__ == '__main__':
  123. try:
  124. linux = 'clear'
  125. windows = 'cls'
  126. os.system([linux,windows][os.name == 'nt'])
  127. except:
  128. os.system(linux)
  129. try:
  130. print(f"""
  131. Simple Reverse IP Lookup ipaddress.com + Auto Range IP MultiThreaded
  132. Input CIDR "0" to not using The Range IP
  133. Credits : @CallMeRep
  134. """)
  135. list = open(input("list : "), encoding="utf8" ).read().splitlines()
  136. RevIP(list).execute()
  137. except Exception as f:
  138. print(f)
  139. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement