Skip to content

Instantly share code, notes, and snippets.

@mpgn
Last active March 20, 2024 23:52
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mpgn/fce3c3f2aaa2eeb8fac5 to your computer and use it in GitHub Desktop.
Save mpgn/fce3c3f2aaa2eeb8fac5 to your computer and use it in GitHub Desktop.
# Padding Oracle Attack against PKCS7
# From https://github.com/mpgn/Padding-oracle-attack
# martial puygrenier
####################################
# CUSTOM YOUR RESPONSE ORACLE HERE #
####################################
''' the function you want change to adapte the result to your problem '''
def test_validity(response, error):
# oracle repsonse with data in the DOM
data = response
if data.find(error) == -1:
return 1
return 0
################################
# CUSTOM YOUR ORACLE HTTP HERE #
################################
import socket
HOST = 'host.com'
PORT = 50100
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
def call_oracle(up_cipher, s):
s.send(up_cipher+"\n")
data = s.recv(1024)
return 1, data
# comment the lines
1. connection.close()
2. print "[+] HTTP ", response.status, response.reason
@noraj
Copy link

noraj commented Apr 8, 2017

You also need to change:

-connection, response = call_oracle(host,cookie,url,post,method,up_cipher)
+connection, response = call_oracle(up_cipher, s)

@noraj
Copy link

noraj commented Apr 8, 2017

And also change useless arg for raw TCP socket:

-parser.add_argument("--host",                       required=True,              help='url example: /page=')
-parser.add_argument('-u', "--urltarget",            required=True,              help='url example: /page=')
+parser.add_argument("--host",                       required=False,              help='url example: /page=')
+parser.add_argument('-u', "--urltarget",            required=False,              help='url example: /page=')

@noraj
Copy link

noraj commented Apr 8, 2017

You also fixed the error message so error message arg must not be required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment