-
Notifications
You must be signed in to change notification settings - Fork 0
/
VIT Wifi.py
76 lines (59 loc) · 2.36 KB
/
VIT Wifi.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
import requests
from subprocess import check_output
from time import sleep
vit_ssids = ['VIT5G', 'VIT2.4G', 'test']
login_url = "http://phc.prontonetworks.com/cgi-bin/authlogin"
logout_url = 'http://phc.prontonetworks.com/cgi-bin/authlogout'
reg_no = ''
password = ''
def login(ssid):
for _ in range(5):
try:
r = requests.post(login_url, data = {'userId': reg_no, 'password': password,
'serviceName': 'ProntoAuthentication', 'Submit22': 'Login'}, timeout=2)
if r.ok:
print(f'You have been successfully logged in to {ssid}')
input()
return True
except requests.exceptions.ConnectionError:
sleep(0.5)
return False
check_status = check_output('netsh wlan show interface')
check_status = check_status.decode().split('\r\n')
network_status = dict()
for line in check_status:
if ':' in line:
split = line.split(':')
network_status[split[0].strip()] = split[1].strip()
if 'SSID' in network_status:
connected_ssid = network_status['SSID']
if connected_ssid in vit_ssids:
try:
logged_in = requests.get('https://1.1.1.1').ok
for _ in range(5):
try:
if requests.get(logout_url, timeout=2).ok:
print(f'You have been successfully logged out of {connected_ssid}')
sleep(1)
disconnect_output = check_output('netsh wlan disconnect').decode()
print(disconnect_output, end='')
input()
break
except requests.exceptions.ConnectionError:
sleep(0.5)
else:
print(f'Logout Failed. Try going to "{logout_url}"')
input()
except requests.exceptions.SSLError:
login(connected_ssid)
else:
print(f'You may be connected to another wifi network.')
input()
else:
for ssid in vit_ssids:
connection_output = check_output(f'netsh wlan connect {ssid}', shell=True).decode()
print(connection_output, end='')
if login(ssid): break
else:
print(f'Connection/Login failed. Try going to "{login_url}"')
input()