[FIXED] Executing Multiple SQL statements using execute()

Issue

I am trying to do an SQL injection in a server of mine. I am using the command :

cursor.execute("select * from some_table")

to execute the SQL commands in my server. But is there a way to execute multiple commands using the same execute() function.
I tried :

cursor.execute("select * from some_table ; INSERT INTO ...")

DBMS is mariadb


Solution

Here is an overview of SQL injection strategies. The one you are trying to do is called stacking queries. It seems that at least this strategy is prevented by most database APIs.

You mention MariaDB which is basically more or less the same as MySQL.

And although python is not listed explicitly, I would also assume that the python database API prevents query stacking.

Update: When you check the API of execute() you can see there is a parameter multi which defaults to False. As long as you don't set it to True, you should be safe.



Answered By - Stefan Winkler
Answer Checked By - Dawn Plyler (sql.easybugfix Volunteer)

Related Posts

Post a Comment