forked from the-robot/sqliv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverseip.py
More file actions
53 lines (38 loc) · 1.38 KB
/
reverseip.py
File metadata and controls
53 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Reverse Domain Lookup
import sys
import urllib
import urllib2
import json
from urlparse import urlparse
from web import useragents
def reverseip(url):
"""return domains from given the same server"""
# get only domain name
url = urlparse(url).netloc if urlparse(url).netloc != '' else urlparse(url).path.split("/")[0]
source = "http://domains.yougetsignal.com/domains.php"
useragent = useragents.get()
contenttype = "application/x-www-form-urlencoded; charset=UTF-8"
# POST method
opener = urllib2.build_opener(
urllib2.HTTPHandler(), urllib2.HTTPSHandler())
data = urllib.urlencode([('remoteAddress', url), ('key', '')])
request = urllib2.Request(source, data)
request.add_header("Content-type", contenttype)
request.add_header("User-Agent", useragent)
try:
result = urllib2.urlopen(request).read()
except urllib2.HTTPError, e:
print >> sys.stderr, "[{}] HTTP error".format(e.code)
except urllib2.URLError, e:
print >> sys.stderr, "URL error, {}".format(e.reason)
except:
print >> sys.stderr, "HTTP exception"
obj = json.loads(result)
# if successful
if obj["status"] == 'Success':
domains = []
for domain in obj["domainArray"]:
domains.append(domain[0])
return domains
print >> sys.stderr, "[ERR] {}".format(obj["message"])
return []