Created
July 12, 2019 12:52
-
-
Save nvssks/5c2bc4e9ebcf013ef8cf3282a29fb8d8 to your computer and use it in GitHub Desktop.
Burp plugin snippet to AES encrypt using Java native or run external
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from burp import IBurpExtender | |
import random | |
import string | |
#Java Imports | |
from javax.crypto import Cipher | |
from javax.crypto.spec import SecretKeySpec | |
#Imports for run external | |
import subprocess | |
class BurpExtender(IBurpExtender): | |
key="[REDACTED]" | |
def run_external(self, payload): | |
#https://github.com/externalist/aes-encrypt-decrypt-burp-extender-plugin-example | |
proc = subprocess.Popen(['python','./encrypt.py', self.key, payload],stdout=subprocess.PIPE) | |
output = proc.stdout.read().strip() | |
proc.stdout.close() | |
return output | |
def run_java_encrypt(self, payload): | |
#https://parsiya.net/blog/2018-12-24-cryptography-in-python-burp-extensions/#aes-cfb-nopadding | |
aesKey = SecretKeySpec(self.key, "AES") | |
cipher = Cipher.getInstance("AES/CBC/NOPADDING") | |
cipher.init(Cipher.ENCRYPT_MODE, aesKey) | |
encrypted = cipher.doFinal(payload) | |
return encrypted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment