File tree Expand file tree Collapse file tree 2 files changed +34
-18
lines changed Expand file tree Collapse file tree 2 files changed +34
-18
lines changed Original file line number Diff line number Diff line change @@ -35,17 +35,25 @@ All you need is defining the **oracle function** to check whether the given ciph
35
35
from padding_oracle import *
36
36
37
37
import requests
38
+
39
+ # Create a requests.Session to enable connection pool
38
40
sess = requests.Session()
39
41
42
+ # Define a function to test if the cipher can be decrypted
40
43
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 )
50
58
51
59
```
Original file line number Diff line number Diff line change 1
1
from padding_oracle import *
2
2
3
3
import requests
4
+
5
+ # Create a requests.Session to enable connection pool
4
6
sess = requests .Session ()
5
7
8
+ # Define a function to test if the cipher can be decrypted
6
9
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 )
You can’t perform that action at this time.
0 commit comments