-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse_engineer_box.py
77 lines (67 loc) · 2.78 KB
/
reverse_engineer_box.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
#!/usr/bin/env python
# coding: utf-8
import requests
import json
from datetime import datetime
import pytz
from prettytable import PrettyTable
prefix = "3e673c0f"
cookies = {
prefix + '/accept-language': 'fr,fr-FR',
'UILang': 'fr',
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0',
'Accept': '*/*',
'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
'Authorization': 'X-Sah-Login',
'Content-Type': 'application/x-sah-ws-4-call+json',
'Origin': 'https://192.168.1.1',
'DNT': '1',
'Connection': 'keep-alive',
'Referer': 'https://192.168.1.1/homeAuthentificationRemote.html',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
}
data = '{"service":"sah.Device.Information","method":"createContext","parameters":{"applicationName":"webui","username":"adminremote","password":"r5HWGRro"}}'
loginResponse = requests.post('https://192.168.1.1/ws', headers=headers, cookies=cookies, data=data, verify = False)
# loginResponse.cookies.get_dict()['45b4c072/sessid']
# json.loads(loginResponse.text)['data']['contextID']
cookies = {
prefix + '/accept-language': 'fr,fr-FR',
'UILang': 'fr',
prefix + '/sessid': loginResponse.cookies.get_dict()[prefix + '/sessid'],
'sah/contextId': json.loads(loginResponse.text)['data']['contextID'],
}
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0',
'Accept': '*/*',
'Accept-Language': 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
'X-Sah-Request-Type': 'idle',
'Content-Type': 'application/x-sah-ws-4-call+json',
'Authorization': 'X-Sah ' +json.loads(loginResponse.text)['data']['contextID'],
'X-Context': json.loads(loginResponse.text)['data']['contextID'],
'Origin': 'https://192.168.1.1',
'DNT': '1',
'Connection': 'keep-alive',
'Referer': 'https://192.168.1.1/homeAuthentificationRemote.html',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
}
data = '{"service":"TopologyDiagnostics","method":"buildTopology","parameters":{"SendXmlFile":false}}'
dataResponse = requests.post('https://192.168.1.1/ws', headers=headers, cookies=cookies, data=data, verify=False)
t = PrettyTable(['A', 'B', 'C', "D"])
for i in json.loads(dataResponse.text)['status'][0]['Children'][0]['Children']:
if 'Children' in i:
for j in i['Children']:
if j['Active']==True and 'IPAddress' in j:
current_time = datetime.now().astimezone(pytz.timezone("Europe/Paris")).strftime('%Y-%m-%d %H:%M:%S')
t.add_row([current_time,j['Name'],j['Key'],j['IPAddress']])
t.header=False
t.align='l'
t.border=False
with open("log.txt", "a") as file:
file.write(str(t))
file.write("\n\n")