forked from gfek/Lepus
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Riddler.py
82 lines (60 loc) · 2.52 KB
/
Riddler.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import requests
from json import loads
from urllib.parse import quote
from termcolor import colored
from configparser import RawConfigParser
def init(domain):
riddler = []
print(colored("[*]-Searching Riddler...", "yellow"))
parser = RawConfigParser()
parser.read("config.ini")
RIDDLER_USERNAME = parser.get("Riddler", "RIDDLER_USERNAME")
RIDDLER_PASSWORD = parser.get("Riddler", "RIDDLER_PASSWORD")
if RIDDLER_USERNAME == "" or RIDDLER_PASSWORD == "":
print(" \__", colored("No Riddler API credentials configured", "red"))
return []
else:
auth = {"email": RIDDLER_USERNAME, "password": RIDDLER_PASSWORD}
auth_url = "https://riddler.io/auth/login"
headers = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0", "content-type": "application/json"}
try:
auth_response = requests.post(auth_url, json=auth, headers=headers)
auth_response_json = loads(auth_response.text)
if auth_response_json["meta"]["code"] == 200:
auth_token = auth_response_json["response"]["user"]["authentication_token"]
search = {"query": "pld:{0}".format(quote(domain)), "output": "host"}
search_url = "https://riddler.io/api/search"
headers = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0", "content-type": "application/json", "authentication-token": auth_token}
search_response = requests.post(search_url, json=search, headers=headers)
if search_response.status_code == 500:
print(" \__", colored("Internal Server Error.", "red"))
return riddler
else:
search_response_json = loads(search_response.text)
for item in search_response_json:
riddler.append(item["host"])
riddler = set(riddler)
print(" \__ {0}: {1}".format(colored("Subdomains found", "cyan"), colored(len(riddler), "yellow")))
return riddler
else:
print(" \__", colored("Invalid Riddler API credentials.", "red"))
return []
except requests.exceptions.RequestException as err:
print(" \__", colored(err, "red"))
return []
except requests.exceptions.HTTPError as errh:
print(" \__", colored(errh, "red"))
return []
except requests.exceptions.ConnectionError as errc:
print(" \__", colored(errc, "red"))
return []
except requests.exceptions.Timeout as errt:
print(" \__", colored(errt, "red"))
return []
except ValueError as errv:
print(" \__", colored(errv, "red"))
return []
except Exception:
print(" \__", colored("Something went wrong!", "red"))
return []
#Depricated?