Search code examples
pythonjarcommand-promptburp

Burp and jar files usage for python files in command prompt


I'm using python 3.3 and working on an assignment where in i have to create a python script that takes in list of url's from the command prompt and runs burp suite on each of them dynamically.so i looked for sample demo code to get familiar with burp and found this one: Helloworld.py

from burp import IBurpExtender
from java.io import PrintWriter
from java.lang import RuntimeException

class BurpExtender(IBurpExtender):
    def registerExtenderCallbacks(self, callbacks):

        # set our extension name
        callbacks.setExtensionName("Hello world extension")

        # obtain our output and error streams
        stdout = PrintWriter(callbacks.getStdout(), True)
        stderr = PrintWriter(callbacks.getStderr(), True)

        # write a message to our output stream
        stdout.println("Hello output")

        # write a message to our error stream
        stderr.println("Hello errors")

        # write a message to the Burp alerts tab
        callbacks.issueAlert("Hello alerts")

        # throw an exception that will appear in our error stream
        raise RuntimeException("Hello exception")

The problem which i am facing is, IDLE constantly pops error stating that java.io not found

from java.io import PrintWriter
ImportError: No module named java.io

or

from burp import IBrupExtender
ImportError: No module name burp

that's cos it's a java library so i downloaded a jython standalone jar file and burp suite too and i passed it in command prompt along with the filename as

java -jar jython-standalone-2.5.3.jar -Xmx1024m burpsuite_pro_v.1.5.14.jar HelloWorld.py

but its still not working. I have all the three files in the same folder. Any suggestions? What needs to be done inorder to make this demo work? am i doing something wrong?


Solution

  • According to their documentation you can't directly use it with Python. However, you can use Jython (Python for the Java platform).

    Things you will have to do if you use Eclipse IDE:

    1. Go to Eclipse Marketplace (Help > Eclipse Marketplace) and look for PyDev plugin. Install it.

    2. You will download Jython-standalone jar file and configure Jython interpreter: Window > Preferences > PyDev > Interpreter-Jython. Click New. Type for interpreter name: Jython. For Interpreter executable, click browse and browse to Jython-standalone jar file. (Click OK, NEXT...)

    3. To create a Jython project: New > PyDevProject. Enter name of project. Under "Chose project type" select Jython. Under "Interpreter" choose Jython. Click OK.

    4. Now, how to add burp.jar to buildpath. Right click on your project > Properties > Select External Libraries tab > Add zip/jar/egg. Browse for burp.jar and finally click OK.

    5. Create new PyDevModule, choose template. and you are ready to go.

    Good luck!