-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteacher.py
52 lines (37 loc) · 1.1 KB
/
teacher.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
import requests
import time
import json
import os
TOKEN = "fd0dfef2a3c2c358446125688051a2fb10046ff45f87f11ad80e813b3e0c2150"
CSRFTOK = "e8e1a4d2ccc825cdfa5b0bd6e4adc37a87d3871df516ded2f25a8dcace195431"
while True:
url = 'http://localhost:8081/pending'
headers = {
'Accept': 'application/json'
}
cookies = {
'token': TOKEN
}
params = {
'csrftok': CSRFTOK
}
# Get waiting users
response = requests.get(url, headers=headers, cookies=cookies)
data = json.loads(response.text)
waitingUsers = data['students']
#Denying users
for user in waitingUsers:
path = f"deny/{user}"
#Simulating the traversal made by the browser:
normalized_path = os.path.normpath(path)
url = f'http://localhost:8081/{normalized_path}'
try:
requests.post(url, params=params, headers=headers, cookies=cookies)
print(url)
except:
print("invalid path")
time.sleep(2)
#print(response.status_code)
#print(response.text)
# Wait 1 min until denying again
time.sleep(60)