commit 1cedbf433c29673ad40e3f6adf2c952a344187ba Author: Didas72 Date: Thu Nov 20 17:46:30 2025 +0000 Initial commit diff --git a/pa/lab2/__pycache__/requests.cpython-313.pyc b/pa/lab2/__pycache__/requests.cpython-313.pyc new file mode 100644 index 0000000..ff469dc Binary files /dev/null and b/pa/lab2/__pycache__/requests.cpython-313.pyc differ diff --git a/pa/lab2/chall_requests.py b/pa/lab2/chall_requests.py new file mode 100644 index 0000000..6f88658 --- /dev/null +++ b/pa/lab2/chall_requests.py @@ -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) diff --git a/pa/lab2/chall_requests2.py b/pa/lab2/chall_requests2.py new file mode 100644 index 0000000..07328f7 --- /dev/null +++ b/pa/lab2/chall_requests2.py @@ -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)