-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcesi_proxy.py
49 lines (41 loc) · 1.43 KB
/
cesi_proxy.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
# coding: utf-8
try:
from httplib import HTTPSConnection
from urllib import urlencode
except ImportError:
from http.client import HTTPSConnection
from urllib.parse import urlencode
import ssl
class Cesi:
def __init__(self, login, password):
self.username = login
self.password = password
self.gateway = "wifi.viacesi.fr:1003"
def reconnect(self):
r = HTTPSConnection('google.fr', context=ssl._create_unverified_context())
r.request('GET', '/')
try:
resp = r.getresponse()
except Exception as e:
print e.message
magic = resp.getheader('location').split('?')[-1]
page = "/%s" % resp.getheader('location').split('/')[-1]
r = HTTPSConnection(self.gateway, context=ssl._create_unverified_context())
try:
print r.request('GET', page)
r.getresponse()
except Exception as e:
print e.message
req = urlencode({'magic': magic, 'answer': '1', '4Tredir': 'https://google.fr/'})
r.request('POST', page, req)
try:
r.getresponse()
except Exception as e:
print e
req = urlencode(
{'magic': magic, 'username': self.username, 'password': self.password, '4Tredir': 'https://google.fr/'})
r.request('POST', page, req)
try:
r.getresponse()
except Exception as e:
print e