-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (39 loc) · 2.29 KB
/
main.py
File metadata and controls
44 lines (39 loc) · 2.29 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
import requests
ips_relogio_lg = ['10.193.57.50', '10.193.57.51', '10.193.57.52', '10.193.57.53', '10.193.57.54', '10.193.57.55', '10.193.57.56', '10.193.57.57', '10.193.57.58', '10.193.57.59', '10.193.57.60', '10.193.57.61',
'10.194.173.15', '10.194.173.16', '10.194.173.17', '10.194.173.12', '10.194.173.11', '10.194.173.13', '10.194.173.18', '10.194.173.14', '10.194.173.19', '10.194.173.20', '10.193.57.72', '10.193.57.73',
'10.193.57.74', '10.193.57.75', '10.193.57.76', '10.193.57.77', '10.193.57.78', '10.193.57.79', '10.193.57.80', '10.193.57.81', '10.193.57.82', '10.193.57.83', '10.193.57.84', '10.193.57.85', '10.193.57.86',
'10.193.57.87', '10.193.57.88', '10.193.57.89', '10.193.57.90', '10.193.57.91', '10.193.57.92', '10.193.57.93', '10.193.57.94', '10.193.57.95', '10.193.57.96', '10.193.57.97', '10.193.57.98', '10.193.57.99', '10.193.57.100', '10.193.57.101']
def autenticar_relogio(ip, login_payload):
try:
login_url = f'https://{ip}/login.fcgi'
response = requests.post(login_url, json=login_payload, verify=False)
response.raise_for_status()
session = response.json()['session']
return session
except requests.exceptions.RequestException as e:
print(f"Erro ao autenticar o relógio {ip}: {e}")
return None
def obter_informacoes_relogio(ip, session):
try:
get_inf_system_url = f'https://{ip}/get_system_information.fcgi'
json_datas = {'session': session}
response = requests.post(get_inf_system_url, params=json_datas, verify=False)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Erro ao obter informações do relógio {ip}: {e}")
return None
login_payload = {'login': "admin", 'password': "admin"}
for ip in ips_relogio_lg:
session = autenticar_relogio(ip, login_payload)
if session:
print(f"\nRelógio: {ip}")
print("Autenticação bem-sucedida.")
informacoes = obter_informacoes_relogio(ip, session)
if informacoes:
print("Informações:")
for key, value in informacoes.items():
print(f"{key}: {value}")
else:
print(f"\nRelógio: {ip}")
print("Falha na autenticação.")