-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEducomWebSms.py
executable file
·66 lines (48 loc) · 2.09 KB
/
EducomWebSms.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
import requests
common_headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'DNT': '1',
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': '1',
'Referer': 'https://educom.kontomanager.at/',
'Origin': 'https://educom.kontomanager.at/'
}
def generate_session_id():
response = requests.post('https://educom.kontomanager.at/', headers=common_headers)
if 'PHPSESSID' not in response.headers['Set-Cookie']:
return ""
for header in response.headers['Set-Cookie'].split(';'):
if 'PHPSESSID' in header:
return header.split('=')[1]
def generate_session(username, password):
session_id = generate_session_id()
headers = common_headers.copy()
headers['Content-Type'] = 'application/x-www-form-urlencoded'
headers['Cookie'] = 'PHPSESSID=' + session_id
data = {
'login_rufnummer': username,
'login_passwort': password
}
response = requests.post('https://educom.kontomanager.at/index.php', headers=headers, data=data)
# contains alert if no successful login -> no header change
if 'alert-warning' in str(response.content):
raise ConnectionError("Login failed.")
headers = common_headers.copy()
headers['Cookie'] = 'PHPSESSID=' + session_id
requests.post('https://educom.kontomanager.at/kundendaten.php', headers=headers)
return session_id
def send_sms(session_id, target_network, target_number, text):
headers = common_headers.copy()
headers['Content-Type'] = 'application/x-www-form-urlencoded'
headers['Cookie'] = 'PHPSESSID=' + session_id
data = {
'telefonbuch': '-',
'to_netz': target_network,
'to_nummer': target_number,
'nachricht': text
}
requests.post('https://educom.kontomanager.at/websms_send.php', headers=headers, data=data)
session = generate_session("e@mail.com", "password")
send_sms(session, "0043699", "12345678", "Hello World!")