File tree 1 file changed +8
-2
lines changed 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import requests
7
7
8
-
8
+ # This function has to be implemented and will be passed to the PaddingOracle constructor.
9
+ # It gets a hex encoded cipher text and has to return True if it can be decrypted successfully,
10
+ # False otherwise.
11
+ #
12
+ # Here is an example implementation that I used for P.W.N. CTF 2018.
9
13
def oracle (cipher_hex ):
10
14
headers = {'Cookie' : 'vals={}' .format (cipher_hex )}
11
15
r = requests .get ('http://converter.uni.hctf.fun/convert' , headers = headers )
@@ -17,9 +21,11 @@ def oracle(cipher_hex):
17
21
return False
18
22
19
23
24
+ # Instantiate the helper with the oracle implementation
20
25
o = PaddingOracle (oracle , max_retries = - 1 )
21
26
22
- # Decrypt the plain text
27
+ # Decrypt the plain text.
28
+ # To make the guesswork faster, use an alphabet optimized for JSON data.
23
29
cipher = 'b5290bd594ba08fa58b1d5c7a19f876c338191a51eeeac94c2b434bdb8adbfb8596f996d6eddca93c059e3dc35f7bef36b57a5611250ec4528c11e1573799d2178c54c034b9ea8fda8ae9a4a41c67763'
24
30
plain , padding = o .decrypt (cipher , optimized_alphabet = json_alphabet ())
25
31
print ('Plaintext: {}' .format (plain ))
You can’t perform that action at this time.
0 commit comments