File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -29,32 +29,33 @@ Tested on [0x09] Cathub Party from EDU-CTF:
29
29
30
30
## Usage
31
31
32
- Let's say we are going to test ` https://the.target.site /api/?token=BASE64_ENCODED_TOKEN `
32
+ E.g. testing ` https://vulnerable.website /api/?token=M9I2K9mZxzRUvyMkFRebeQzrCaMta83eAE72lMxzg94%3D ` :
33
33
34
34
``` python
35
35
from padding_oracle import padding_oracle, base64_encode, base64_decode
36
36
import requests
37
37
38
38
sess = requests.Session() # use connection pool
39
- url = ' https://example.com /api/'
39
+ url = ' https://vulnerable.website /api/'
40
40
41
41
def oracle (ciphertext : bytes ):
42
42
resp = sess.get(url, params = {' token' : base64_encode(ciphertext)})
43
43
44
44
if ' failed' in resp.text:
45
- return False
45
+ return False # e.g. token decryption failed
46
46
elif ' success' in resp.text:
47
47
return True
48
48
else :
49
49
raise RuntimeError (' unexpected behavior' )
50
50
51
- ciphertext = base64_decode(' BASE64_ENCODED_TOKEN' )
52
- # becomes IV + block1 + block2 + ...
51
+ ciphertext: bytes = base64_decode(' M9I2K9mZxzRUvyMkFRebeQzrCaMta83eAE72lMxzg94=' )
52
+ # len(ciphertext) is 32
53
+ # possibly be "IV + cipher block" if block size is 16
53
54
54
- assert len (cipher ) % 16 == 0
55
+ assert len (ciphertext ) % 16 == 0
55
56
56
57
plaintext = padding_oracle(
57
- ciphertext, # cipher bytes
58
+ ciphertext,
58
59
block_size = 16 ,
59
60
oracle = oracle,
60
61
num_threads = 16 ,
You can’t perform that action at this time.
0 commit comments