Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: Urgent: Dec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 17 of 18 Topic 11036 of 11517
Post > Topic >>

Re: Urgent: Deciphering binary code executed against the database

by anojjona@[EMAIL PROTECTED] May 13, 2008 at 03:46 PM

On May 13, 2:18=A0pm, Eric <eisa...@[EMAIL PROTECTED]
> wrote:
> Here's the news link I found...back from April 23...
>
> http://www.pcpro.co.uk/news/192051/hackers-infect-half-a-million-webs...
>
> This seems to describe what happened.

Yeah...a lot of sites are affected.  And what I've heard is happening
is that when someone hits an infected web page, trojans get installed
on that person's computer, which may not only steal user passwords,
but also send out more attacks using that person's computer.  The
places this thing points to are constantly changing.

Now another thing, for those who are interested...the idea posted
before that one could use the same logic to reverse the damage
apparently won't work.  That's because it uses the convert() command
to convert the data to varchar.  That does two things:  It allows the
script to work on text fields (somehow varchar fails when used in
dynamic SQL within an exec statement); but also, since there is no
field length specified, SQL Server seems to default to 30.  So, the
data gets cut off after 30 characters (plus any spaces are trimmed
with the rtrim), and then the malicious code is inserted after that.

Every day or two, more attacks come, perhaps from infected computers,
until the site is stopped or SQL injection holes patched.  When that
happens, the old malicious code is replaced with the new (because of
the truncation at 30 characters).  But each of these seems to end with
the end-script tag.  However, since sometimes the Javascript is there
only to use do***ent.write() to put in an iframe, it's possible that
some of these exploits may just insert iframes instead of JavaScript.

(Iframes to websites that have ActiveX controls is perhaps one of the
exploits they were talking about when they said disabling JavaScript
isn't enough?)

By the way, does anyone know if the 30 character thing is standard, or
if it's configurable per installation?

Anyhow, given the data loss, restoring from backup seems to be the
only way.

Here's a little script I wrote to at least get a record of the
damage.

--Do the create table once in the session:
--Create table #re****t(Tablename varchar(255), columnname
varchar(255), datatype int, affectedrows int)

DECLARE @[EMAIL PROTECTED]
 varchar(10)
DECLARE @[EMAIL PROTECTED]
 varchar(255),@[EMAIL PROTECTED]
 varchar(255),@[EMAIL PROTECTED]
 int

Set @[EMAIL PROTECTED]
 =3D '</script>'
DECLARE Table_Cursor1 CURSOR FOR select a.name,b.name,b.xtype
  from sysobjects a,syscolumns b
  where a.id=3Db.id and a.xtype=3D'u' and (b.xtype=3D99 or b.xtype=3D35 or
b.xtype=3D231 or b.xtype=3D167)

delete from #re****t

OPEN Table_Cursor1
  FETCH NEXT FROM  Table_Cursor1 INTO @[EMAIL PROTECTED]
  WHILE(@[EMAIL PROTECTED]
)
    BEGIN
     exec('Declare @[EMAIL PROTECTED]
 int;
SELECT @[EMAIL PROTECTED]
 =3D COUNT(1)
FROM ['+@[EMAIL PROTECTED]
']
WHERE RIGHT(convert(varchar(4000),['+@[EMAIL PROTECTED]
']),9) =3D '''+@[EMAIL PROTECTED]
''';
if @[EMAIL PROTECTED]
 > 0 begin
	INSERT INTO #re****t select '''+@[EMAIL PROTECTED]
''', '''+@[EMAIL PROTECTED]
''', '''+@[EMAIL PROTECTED]
''',
COUNT(1)
	FROM ['+@[EMAIL PROTECTED]
']
	WHERE RIGHT(convert(varchar(4000),['+@[EMAIL PROTECTED]
']),9) =3D '''+@[EMAIL PROTECTED]
'''
end;')

      FETCH NEXT FROM  Table_Cursor1 INTO @[EMAIL PROTECTED]
    END CLOSE Table_Cursor1
DEALLOCATE Table_Cursor1

select * from #re****t
 




 18 Posts in Topic:
Urgent: Deciphering binary code executed against the database
anojjona@[EMAIL PROTECTED  2008-05-12 17:00:52 
Re: Urgent: Deciphering binary code executed against the databas
eisaacs@[EMAIL PROTECTED]  2008-05-12 17:24:41 
Re: Urgent: Deciphering binary code executed against the databas
Matthias Klaey <mpky@[  2008-05-13 02:31:17 
Re: Urgent: Deciphering binary code executed against the databas
eisaacs@[EMAIL PROTECTED]  2008-05-12 17:41:18 
Re: Urgent: Deciphering binary code executed against the databas
anojjona@[EMAIL PROTECTED  2008-05-12 17:43:43 
Re: Urgent: Deciphering binary code executed against the databas
Matthias Klaey <mpky@[  2008-05-13 03:18:19 
Re: Urgent: Deciphering binary code executed against the databas
anojjona@[EMAIL PROTECTED  2008-05-12 17:46:54 
Re: Urgent: Deciphering binary code executed against the databas
eisaacs@[EMAIL PROTECTED]  2008-05-12 17:52:35 
Re: Urgent: Deciphering binary code executed against the databas
eisaacs@[EMAIL PROTECTED]  2008-05-12 18:06:10 
Re: Urgent: Deciphering binary code executed against the databas
Eric <eisaacs@[EMAIL P  2008-05-12 18:25:54 
Re: Urgent: Deciphering binary code executed against the databas
MacLeonard Starkey <se  2008-05-13 23:02:29 
Re: Urgent: Deciphering binary code executed against the databas
MacLeonard Starkey <se  2008-05-13 23:08:34 
Re: Urgent: Deciphering binary code executed against the databas
anojjona@[EMAIL PROTECTED  2008-05-12 22:37:28 
Re: Urgent: Deciphering binary code executed against the databas
Pumba <takvinge@[EMAIL  2008-05-13 01:58:09 
Re: Urgent: Deciphering binary code executed against the databas
anojjona@[EMAIL PROTECTED  2008-05-13 07:57:54 
Re: Urgent: Deciphering binary code executed against the databas
Eric <eisaacs@[EMAIL P  2008-05-13 11:18:32 
Re: Urgent: Deciphering binary code executed against the databas
anojjona@[EMAIL PROTECTED  2008-05-13 15:46:03 
Re: Urgent: Deciphering binary code executed against the databas
Erland Sommarskog <esq  2008-05-14 22:05:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 1:19:50 CST 2008.