Connecting GlastopfNG to a MySQL database

Other Languages: None

After my first success with the vulnerability emulator, I was keen enough to try something new: MySQL logging with a Jython plug-in using the MySQL/J database connector. To load this jar into the sys.path at runtime was a bit difficult. Sven found this nice classPathHacker from Steve Langer. With some modification, I was ready to finish the plug-in.

Here is my modified classPathHacker:

class classPathHacker():
    Author: SG Langer Jan 2007 
    Loads the MySQL/J jar at runtime
    import java.lang.reflect.Method
    import jarray
    def addFile(self, s):
        f =
        u = f.toURL()
        a = self.addURL(u)
        return a
    def addURL(self, u):
        sysloader =
        sysclass =
        method = sysclass.getDeclaredMethod("addURL", [])
        a = method.setAccessible(1)
        jar_a = self.jarray.array([u],
        b = method.invoke(sysloader, [u])
        return u

And loading the driver looks like this:

class MySQLReporter():
    Connects to the MySQL database and provides the sql methods.
    def __init__(self):
        from java.lang import Class
        jarLoad = classPathHacker()
        a = jarLoad.addFile("GlastopfNG_lib/mysql-connector-java-5.1.14-bin.jar")

And this function establishes the connection and execute a SELECT on the database:

    def mysql_connect(self):
        from java.sql import DriverManager
        url = "jdbc:mysql://" \
               + mysqlLog_server + "/" \
               + mysqlLog_database + "?user=" \
               + mysqlLog_username + "&password=" \
               + mysqlLog_password
        conn = DriverManager.getConnection(url)
        return conn
    def mysql_select(self, conn):
        stmt = conn.createStatement()
        rs = stmt.executeQuery("SELECT * FROM log")

Dein Kommentar:

Design von Robin Hastings - Farbanpassung von Ulysses Ronquillo