'Running python script from MySql trigger with sys_exec() gives exit code 1

I have a MySql server locally (on Windows 10) and want to run a python script from a trigger. For taht, i want to use sys_exec(). I got the lib_mysqludf_sys_64.dll from here: https://github.com/rapid7/metasploit-framework/tree/master/data/exploits/mysql

and set the UDF up as described here: https://osandamalith.com/2018/02/11/mysql-udf-exploitation/

sys_exec is working:

mysql> SELECT sys_exec('python --version')//
+------------------------------+
| sys_exec('python --version') |
+------------------------------+
|                            0 |
+------------------------------+
1 row in set (0.52 sec)

but when i want to run the script:

mysql> SELECT sys_exec('python C:\dbtest.py test')//
+--------------------------------------+
| sys_exec('python C:\dbtest.py test') |
+--------------------------------------+
|                                    2 |
+--------------------------------------+
1 row in set (0.07 sec)

As far as i understand, the 2 indicates, that the file was not found. How can i fix this?

When i use '\\', the exit code changes to 1 (Invalid_Function ?):

mysql> SELECT sys_exec('python C:\\dbtest.py test')//
+---------------------------------------+
| sys_exec('python C:\\dbtest.py test') |
+---------------------------------------+
|                                     1 |
+---------------------------------------+
1 row in set (0.57 sec)


Solution 1:[1]

the MySQL UDF SYS is not installed.

Here you can find the Answer to do that : Mysql sys_exec Can't open shared library 'lib_mysqludf_sys.so' (errno: 11, wrong ELF class: ELFCLASS32)

here also the git for download: https://github.com/mysqludf/lib_mysqludf_sys

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bernd Buffen