Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to inject sql to delete statement?

i built website that uses sql server and have this sql for deleting items by id that im getting from querystring:

DELETE FROM tablename WHERE GUID = 'param'

is it possible to inject sql that will return db_name() for example?

i know that i can inject sql only for select statements something like this

select name from tablename where 'parems' 
union all
select db_name()

but what about delete statements

i know that i can drop table insert to table, but in this stage i need know if i can get kind of data, for ex.: db_name()

like image 525
Sasha Avatar asked Dec 20 '25 06:12

Sasha


2 Answers

Sure. This value of param:

' OR ''='

will result in this statement:

DELETE FROM tablename WHERE GUID ='' OR '' = ''

which will delete all data in the table.

like image 88
Quassnoi Avatar answered Dec 24 '25 04:12

Quassnoi


Yes, a query always returns a result, so if the database driver allows it you can simply add another query after the delete.

An input like this:

x'; select db_name() --

would give:

DELETE FROM tablename WHERE GUID = 'x'; select db_name() --'
like image 28
Guffa Avatar answered Dec 24 '25 04:12

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!