Skip to content

Instantly share code, notes, and snippets.

@nvssks
Created July 12, 2019 12:52
Show Gist options
  • Save nvssks/5c2bc4e9ebcf013ef8cf3282a29fb8d8 to your computer and use it in GitHub Desktop.
Save nvssks/5c2bc4e9ebcf013ef8cf3282a29fb8d8 to your computer and use it in GitHub Desktop.

Revisions

  1. nvssks created this gist Jul 12, 2019.
    27 changes: 27 additions & 0 deletions burp-jython-aes-encrypt.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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