-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack.py
More file actions
executable file
·97 lines (76 loc) · 2.54 KB
/
hack.py
File metadata and controls
executable file
·97 lines (76 loc) · 2.54 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/python3
from openpyxl import load_workbook
from bs4 import BeautifulSoup
from requests import *
import json, re, os
class Users:
users = {}
def loadUsers(self, wb):
sheet = wb['Table 1']
for i in range(2, sheet.max_row+1):
self.users.update( {sheet.cell(row=i, column=3).value: sheet.cell(row=i, column=4).value} )
def __len__(self):
return len(self.users)
def learn(login, password):
s = Session()
response = s.get(url = "http://dist.kait20.ru/login/index.php")
response = BeautifulSoup(response.text, 'html.parser')
inputs = response.find('input', {'name': 'logintoken'})
token = inputs.get('value')
response = s.post(url = "http://dist.kait20.ru/login/index.php", data = {
'anchor': '',
'logintoken': token,
'username': login,
'password': password
})
pattern = re.compile(r"M.cfg = (\{.*?});", re.MULTILINE | re.DOTALL)
response = BeautifulSoup(response.text, 'html.parser')
script = response.find('script', text=pattern)
obj = {}
if script:
obj = pattern.search(script.text).group(1)
obj = json.loads(obj)
else:
print("Cannot prepare script to get SESSKEY")
return
sesskey = obj['sesskey']
data = [{
"index":0,
"methodname":"core_course_get_enrolled_courses_by_timeline_classification",
"args":
{
"offset":0,
"limit":24,
"classification":"all",
"sort":"fullname"
}
}]
response = s.post(url = "http://dist.kait20.ru/lib/ajax/service.php", params = {
'sesskey': sesskey,
'info': 'core_cource_get_enrolled_courses_by_timeline_classification'
}, json = data)
try:
answer = response.json()
URL = answer[0]['data']['courses'][0]['viewurl']
except:
print('Cannot find any course in dashboard\nShutdown...')
return
response = s.get(url = URL)
response = BeautifulSoup(response.text, 'html.parser')
ids = response.find_all('input', {'name':'id'})
idValues = []
for inputs in ids:
idValues.append(inputs.get('value'))
for idValue in idValues:
response = s.post(url = "http://dist.kait20.ru/course/togglecompletion.php", data={
'id':idValue,
'completionstate':1,
'fromajax':1,
'sesskey':sesskey
})
bots = Users()
i = input("Paste database you want to use (in the same partition): ")
bots.loadUsers(load_workbook(os.getcwd()+'/'+i))
for login, password in bots.users.items():
print(login, password)
learn(login, password)