Initial commit
This commit is contained in:
BIN
pa/lab2/__pycache__/requests.cpython-313.pyc
Normal file
BIN
pa/lab2/__pycache__/requests.cpython-313.pyc
Normal file
Binary file not shown.
21
pa/lab2/chall_requests.py
Normal file
21
pa/lab2/chall_requests.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from requests import get
|
||||||
|
import re
|
||||||
|
|
||||||
|
BASE = "http://mustard.stt.rnl.tecnico.ulisboa.pt:25053"
|
||||||
|
|
||||||
|
resp = get(BASE+"/hello")
|
||||||
|
content = resp.content.decode('utf-8')
|
||||||
|
|
||||||
|
target = re.search(r"target ([0-9]+)", content).group(1)
|
||||||
|
print("Target:", target)
|
||||||
|
|
||||||
|
current = 0
|
||||||
|
|
||||||
|
while current != target:
|
||||||
|
resp = get(BASE+"/more", cookies=resp.cookies)
|
||||||
|
content = resp.content.decode('utf-8')
|
||||||
|
current = re.search(r"current value is: ([0-9]+)", content).group(1)
|
||||||
|
print("Current:", current)
|
||||||
|
|
||||||
|
resp = get(BASE+"/finish", cookies=resp.cookies)
|
||||||
|
print(resp.content)
|
||||||
27
pa/lab2/chall_requests2.py
Normal file
27
pa/lab2/chall_requests2.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from requests import get
|
||||||
|
import re
|
||||||
|
|
||||||
|
BASE = "http://mustard.stt.rnl.tecnico.ulisboa.pt:25054"
|
||||||
|
|
||||||
|
resp = get(BASE+"/hello")
|
||||||
|
content = resp.content.decode('utf-8')
|
||||||
|
print(content)
|
||||||
|
print(resp.cookies)
|
||||||
|
|
||||||
|
for cookie in resp.cookies:
|
||||||
|
if cookie.name == "remaining_tries":
|
||||||
|
cookie.value = "200"
|
||||||
|
|
||||||
|
target = re.search(r"target ([0-9]+)", content).group(1)
|
||||||
|
print("Target:", target)
|
||||||
|
|
||||||
|
current = 0
|
||||||
|
|
||||||
|
while current != target:
|
||||||
|
resp = get(BASE+"/more", cookies=resp.cookies)
|
||||||
|
content = resp.content.decode('utf-8')
|
||||||
|
current = re.search(r"current value is: ([0-9]+)", content).group(1)
|
||||||
|
print("Current:", current)
|
||||||
|
|
||||||
|
resp = get(BASE+"/finish", cookies=resp.cookies)
|
||||||
|
print(resp.content)
|
||||||
Reference in New Issue
Block a user