.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Th4sD0m
2 | Tool to identify all domains contained in an IP anonymously
3 |
4 | # How to install
5 |
6 | Install requirements with:
7 |
8 | pip install -r requirements.txt
9 |
10 | #How to use:
11 |
12 | Example of usage:
13 |
14 | python th4sd0m.py -i DIRECTION_IP -n 4 -e Y
15 |
16 |
17 | usage: th4sd0m.py [-h] -i IP -n NUM [-e EXPORT]
18 |
19 |
20 | This script identifies all domains contained in an IP
21 |
22 | optional arguments:
23 |
24 |
25 |
26 | -h, --help show this help message and exit
27 |
28 | -i IP, --ip IP The IP which wants to search
29 |
30 |
31 | -n NUM, --num NUM Indicate the number of the search which you want to do
32 |
33 | -e EXPORT, --export EXPORT
34 |
35 | Export the results to a json file (Y/N)
36 |
37 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | #Module dependencies (install via pip):
2 | beautifulsoup4==4.5.1
3 | requests==2.10.0
4 | argparse==1.4.0
5 | Python==2.7
6 | XlsxWriter==0.9.6
7 | json
8 | urllib2
9 |
--------------------------------------------------------------------------------
/th4sd0m.py:
--------------------------------------------------------------------------------
1 | import requests
2 | from urlparse import urlparse
3 | from bs4 import BeautifulSoup
4 | import argparse
5 | from argparse import RawTextHelpFormatter
6 | from urllib2 import urlopen
7 | from contextlib import closing
8 | import json
9 | #define vars
10 | bing_dork=["site:","-site:","language:","domain:","ip:"]
11 | urls = []
12 | urls_clean = []
13 | urls_final =[]
14 | delete_bing=["microsoft","msn","bing"]
15 | #********************************************************#
16 | def banner():
17 | print " _____ _ _ _ ___ __ "
18 | print " |_ _| |_| | | __| \ / \ _ __ "
19 | print " | | | ' \_ _(_-< |) | () | ' \ "
20 | print " |_| |_||_||_|/__/___/ \__/|_|_|_| "
21 | print "\n"
22 | print """
23 | ** Author: Ignacio Brihuega Rodriguez a.k.a N4xh4ck5
24 | ** DISCLAMER This tool was developed for educational goals.
25 | ** The author is not responsible for using to others goals.
26 | ** A high power, carries a high responsibility!
27 | ** Version 1.0"""
28 |
29 | def help():
30 | print """ \nTool to identify all domains contained in an IP anonymously
31 |
32 | Example of usage: python th4sd0m.py -i DIRECTION_IP -n 4 -e Y """
33 | """ FUNCTION SENDEQUEST """
34 | #Use Bing to obtain all domains contained in an IP
35 | def SendRequest(ip,num,initial):
36 | iteration = 0
37 | count_bing=9
38 | try:
39 | while (iteration < num):
40 | iteration = iteration +1
41 | if initial==True:
42 | print "\nSearching domains...\n"
43 | initial = False
44 | #First search in Bing
45 | SearchBing = "https://www.bing.com/search?q="+bing_dork[4]+ip
46 | else:
47 | #Bring the next Bing results - 50 in each page
48 | SearchBing = "https://www.bing.com/search?q="+bing_dork[4]+ip+"&first="+str(count_bing)+"&FORM=PORE"
49 | count_bing=count_bing+50
50 | try:
51 | #Use requests to do the search
52 | response=requests.get(SearchBing,allow_redirects=True)
53 | parser_html(response.text)
54 | except Exception as e:
55 | print e
56 | pass
57 | except Exception as e:
58 | print e
59 | pass
60 | #********************************************************#
61 | """ FUNCTION PARSER_HTML"""
62 | def parser_html(content):
63 | i = 0;
64 | soup = BeautifulSoup(content, 'html.parser')
65 | for link in soup.find_all('a'):
66 | try:
67 | if (urlparse(link.get('href'))!='' and urlparse(link.get('href'))[1].strip()!=''):
68 | urls.append(urlparse(link.get('href'))[1])
69 | except Exception as e:
70 | #print(e)
71 | pass
72 | try:
73 | #Delete duplicates
74 | [urls_clean.append(i) for i in urls if not i in urls_clean]
75 | except:
76 | pass
77 | try:
78 | #Delete not domains belongs to target
79 | for value in urls_clean:
80 | if (value.find(delete_bing[0]) == -1):
81 | #Delete Bing's domains
82 | if (value.find(delete_bing[1]) == -1):
83 | if (value.find(delete_bing[2]) == -1):
84 | urls_final.append(value)
85 | except:
86 | pass
87 | ######FUNCTION EXPORT RESULTS #######
88 | """ FUNCTION EXPORT RESULTS"""
89 | def ExportResults(data):
90 | #Export the results in json format
91 | with open ('output.json','w') as f:
92 | json.dump(data,f)
93 |
94 | """ FUNCTION VISU RESULTS """
95 | def VisuResults(ip):
96 | print "Information about the IP",ip+"\n"
97 | WhoismyIP(ip)
98 | print "\nDomains contained in the IP "+ip+" are:"
99 | #Read the list to print the value in a line
100 | for i in urls_final:
101 | if i not in newlist:
102 | newlist.append(i)
103 | print "\n"
104 | print "\t- " + i
105 |
106 | """FUNCTION WhoISMYIP"""
107 | def WhoismyIP(ip):
108 | url =""
109 | url = 'http://freegeoip.net/json/'+ip
110 | try:
111 | with closing(urlopen(url)) as response:
112 | location = json.loads(response.read())
113 | print location
114 | location_city = location['city']
115 | location_state = location['region_name']
116 | location_country = location['country_name']
117 | location_zip = location['zipcode']
118 | except:
119 | pass
120 | #MAIN
121 | parser = argparse.ArgumentParser(description='This script identifies all domains contained in an IP', formatter_class=RawTextHelpFormatter)
122 | parser.add_argument('-i','--ip', help="The IP which wants to search",required=True)
123 | parser.add_argument('-n','--num', help="Indicate the number of the search which you want to do",required=True)
124 | parser.add_argument('-e','--export', help='Export the results to a json file (Y/N)\n\n', required=False)
125 | args = parser.parse_args()
126 | banner()
127 | help ()
128 | #Asignation from arguments to variables.
129 | initial = True
130 | N = int (args.num)
131 | ip=args.ip
132 | output=args.export
133 | domains=[]
134 | content = ""
135 | if output is None:
136 | output = 'N'
137 | if ((output != 'Y') and (output != 'N')):
138 | print "The output option is not valid"
139 | exit(1)
140 | try:
141 | content = SendRequest(ip,N,initial)
142 | except:
143 | pass
144 | newlist=[]
145 | #Call the function to show results
146 | VisuResults(ip)
147 | #verify if the user wants to export results
148 | if output == 'Y':
149 | #Only it can enter if -e is put in the execution
150 | ExportResults(newlist)
--------------------------------------------------------------------------------