From 1cedbf433c29673ad40e3f6adf2c952a344187ba Mon Sep 17 00:00:00 2001 From: Didas72 Date: Thu, 20 Nov 2025 17:46:30 +0000 Subject: [PATCH] Initial commit --- pa/lab2/__pycache__/requests.cpython-313.pyc | Bin 0 -> 1090 bytes pa/lab2/chall_requests.py | 21 +++++++++++++++ pa/lab2/chall_requests2.py | 27 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 pa/lab2/__pycache__/requests.cpython-313.pyc create mode 100644 pa/lab2/chall_requests.py create mode 100644 pa/lab2/chall_requests2.py diff --git a/pa/lab2/__pycache__/requests.cpython-313.pyc b/pa/lab2/__pycache__/requests.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ff469dc1f78a55c43140e478c46968312efa7b24 GIT binary patch literal 1090 zcmb_aO-~b16n)dqM`s>|C`hRWY=|E;mJU`LX;Vo=iHWF-jyuQ2&_3FU(@uReBVktK zO3J3)n6QKuamP>aC(sN87^7lbvBU5Od_!r=!bBI|#eMh9z4zR6?!41*SOCQ8sq1Pq z0KiZG(lO>dIQ>Qe@DWHrq87kY3R5vZ4lD$4KnmiZOpOCMDAALoJWVQn!?aB2&yd^q zj?afXQSX$PZWkj5^8LL`CmIJ5D>G@r&$s-g_Ic4uTo;3v1yUc9`A)sh7DE}ze0CWC zWf6dL#=Os%@Eo~_)Q%+~6Zr2M;6H1CXBzrs*wfJEPqy&9ry=}T4P+aC{uiB%#Xu<# z??3j1$0;vZLgouwESqL6D~c7%Fcn-(8m5`VRV`_vLRBs3NlR0WMO{hO%xo$>mA+@Q zVi{?gZZnp-G&y4rkS+ogn|L)fnR$IDe(b*sn|pcoHET0sMaPIt;|jX|Mn#5wwP0b4 zs%Gq+qFE@W8rg2I9eUKxWo=GeQmd*_j)%PvMsF=-m$YTwp;6mABN?5mQ9@{49F*U4`D(-wd_TT&`a7sMzCd9H{L1IxYDu!s_ zf>>J-4MSfNHDxg+cIGE*D_$s9(TkRbX7Lbd^tBq_i8~2W6!jI1d;$CsH{;MhIAL|V z8LB^Uxu`=Q2>p#jJ+Uv0wuI63k}KSDxFa4mqHEEe!J8Y)E-&u$=@y^fR$P9@VGjZ0 zsLkPBFmfb7Qp$##!!8>+48hgM%}D*(#*MASW}+1mouLCb(8$$u`*5rU$JUo!c-x5_ zz;Gk8mf5+I+J53flACM6xzBf9IPXLbDb}%@_jjplCp_T#o5Oo-z}( literal 0 HcmV?d00001 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)