π°Insert Query Injection
So here we will discuss on how a hacker can Abuse new record insertion process using Insert Query Injection.
You can achieve this using the following Injections
-------------------------------------------------------------
Exploitation using XPATH injection:
It will work when the developer have inserted the error function over there. else only 3rd injection will work
Query:
insert into posts (title,post_data,label) value ('$title','$post_data','$label')Injection:
' extractvalue(0x0a,concat(0x0a,(select database()))) '
" extractvalue(0x0a,concat(0x0a,(select database()))) "
' extractvalue(0x0a,concat(0x0a,(select database())))--+
" extractvalue(0x0a,concat(0x0a,(select database())))--+
' extractvalue(0x0a,concat(0x0a,(select database())))#
" extractvalue(0x0a,concat(0x0a,(select database())))#
' extractvalue(0x0a,concat(0x0a,(select database())))--
" extractvalue(0x0a,concat(0x0a,(select database())))--So actually the above query will output the data in form of error. for rest of Exploitation using XPATH read XPATH Injection
-------------------------------------------------------------
Exploitation using Sub-Query Injection:
Query:
Injection:
So actually the above query will output the data in form of error. for rest of Exploitation using Sub Query Injectoin. But it will only work when the developer is printing any error. So now lets start with our 3rd method.
-------------------------------------------------------------
Exploitation using Tempering the Insert Query input
Well this time we are not going to create any error assuming that the developer is not giving any error. So we will get the output by inserting the injection and then insert it. After that we will check the Inserted value to get the data.
Unlike Update Query Injection in insert query we are not usually bound to use the same variable space, as here we have multiple injectable parameters in a insert query.
So lets start the exploitation
Query:
Our Input is going to $title, $post_data, $label variable. This time we will inject and comment out rest of the query.
So our input in these variables goes this way:
So as per our input we have left the label field empty as we dont require it anymore. what we did is we added one more parameter in $post_data variable, which when injected in the SQL Query will be used for $label and the rest of the query will be skipped. Lets see how the Query will look like.
Query:
So if the Label is viewable you will see the database() string over there, and now you can start exploiting with the Following Queries.
Setting up post data to get the Tables:
Setting up post data to get the columns:
Setting up post data to get the columns data:
You can also use Limit if required, if you dont know how to use Limit go and read Death Row Injection.
-------------------------------------------------------------
Last updated