Recent SQL injectio...
 
Notifications
Clear all

Recent SQL injection attacks

8 Posts
6 Users
0 Likes
754 Views
(@secret_squirrel)
Posts: 38
Eminent Member
Topic starter
 

Hi all,

There have been a slew of SQL injection attacks since about Jan 08.

I have worked a few of them.

Attacker uses a 'cast' option to declare a variable and then exec it. the result of this attack is that a database has now been riddled with <script src=> tags.

In my experience, this attack has always left an easy to follow trail(IIS logs).

I am currently looking at an incident where there are numerous delcare/cast entries throughout the logs. The problem is, after exporting the cs-uri-query entries to a csv, removed duplicates, decoded and I have NOT found a matching entry for the script src tags that were appended to the database fields.

The only thing I can think is that there is another web app somewhere using this db. Of course no documentation at all.

Anyway, to my question, what can i do on an MSSQL server to log activity to a particular database (as verbose as possible)?

Or any other advise?

 
Posted : 14/10/2008 6:52 am
(@bithead)
Posts: 1206
Noble Member
 

Some tomes I have been following

Microsoft Security Advisory (954462)
Rise in SQL Injection Attacks Exploiting Unverified User Data Input

Advanced SQL Injection

Recent SQL Injection Attacks against Server

MSSQL and Security (Check out the Audit section)

 
Posted : 14/10/2008 8:10 am
ecophobia
(@ecophobia)
Posts: 127
Estimable Member
 

I recently came across a few Hex based SQL Injection attacks, most of them being automated (bots). Unfortunately there are still a lot of easy targets for these attacks; even Firefox plugins such as SQL Injection 1.2 or HackBar are often successful.
If you look at the weekly download statistics for these plugins .
… roll

 
Posted : 14/10/2008 4:26 pm
(@mkel2000)
Posts: 24
Eminent Member
 

Hi all,

Anyway, to my question, what can i do on an MSSQL server to log activity to a particular database (as verbose as possible)?

Or any other advise?

The first thing you might want to look for is any Event Log entries related to that activity. While it won't log the computer they came from, they will give you some external data on the activity itself.

Now, to answer your question, there is a type of SQL logging available called "C2 logging." C2 is a government security rating that certifies a system has secured its resources and has sufficient auditing capabilities. It is turned on by the DBA using the SQL command line tool, osql.exe. Once C2 is enabled, all types of database access are logged into a trace file. In my experience, though you may or may not find anything in these logs, depending on the nature of the exploit. I know for a fact that many Metasploit SQL exploits will leave no trace in these or any other logs.

I'm not a DBA, so you may want to see if you can find one locally to help you if you want to set up C2 logging. However, I do have the commands needed so you can PM me if you need additional information.

Mark

 
Posted : 21/10/2008 6:19 am
keydet89
(@keydet89)
Posts: 3568
Famed Member
 

Mark,

The first thing you might want to look for is any Event Log entries related to that activity. While it won't log the computer they came from, they will give you some external data on the activity itself.

What are the event IDs and sources that one should look for, and in which Event Log?

 
Posted : 21/10/2008 7:33 am
(@arbert)
Posts: 14
Active Member
 

Hi all,

There have been a slew of SQL injection attacks since about Jan 08.

I have worked a few of them.

Attacker uses a 'cast' option to declare a variable and then exec it. the result of this attack is that a database has now been riddled with &lt;script src=&gt; tags.

In my experience, this attack has always left an easy to follow trail(IIS logs).

I am currently looking at an incident where there are numerous delcare/cast entries throughout the logs. The problem is, after exporting the cs-uri-query entries to a csv, removed duplicates, decoded and I have NOT found a matching entry for the script src tags that were appended to the database fields.

The only thing I can think is that there is another web app somewhere using this db. Of course no documentation at all.

Anyway, to my question, what can i do on an MSSQL server to log activity to a particular database (as verbose as possible)?

Or any other advise?

Run SQL profiler and filter the text data for any statements that have CAST or CONVERT. Might also look at a quick and dirty application firewall that will filter this stuff to start with (microsoft released an update to URLScan that will do this). It's really clever how some of these have been working. They pass a binary string to SQL Server, cast it back to character text and then EXEC it. ON the bright side, most have been pretty benign–at least you can easily remove their script as opposed to them changing data beyond repair (restore).

 
Posted : 21/10/2008 7:39 am
(@mkel2000)
Posts: 24
Eminent Member
 

Mark,

What are the event IDs and sources that one should look for, and in which Event Log?

Whether or not you have any Event log entries is dependent upon the audit level set in the SQL Server properties. These events will be generated in the Windows Application Event Log. Default logging of normal user logins is not enabled, but failed and successful logins for the SQL Admin account is. You can set logging for all failed and successful logins in the settings for the SQL Server.

The information I have in front of me is that the Event ID for SQL logins is 17055. However, you might want to filter on all events with a Source of MSSQLSERVER. As I said earlier, this will not tell you where the connection came from, but it could help isolate the activity's date and time when looking through other logs like firewall or IIS logs. Those logs might then identify your source or give you a place to start looking.

Mark

 
Posted : 22/10/2008 10:26 pm
(@arbert)
Posts: 14
Active Member
 

Mark,

What are the event IDs and sources that one should look for, and in which Event Log?

Whether or not you have any Event log entries is dependent upon the audit level set in the SQL Server properties. These events will be generated in the Windows Application Event Log. Default logging of normal user logins is not enabled, but failed and successful logins for the SQL Admin account is. You can set logging for all failed and successful logins in the settings for the SQL Server.

The information I have in front of me is that the Event ID for SQL logins is 17055. However, you might want to filter on all events with a Source of MSSQLSERVER. As I said earlier, this will not tell you where the connection came from, but it could help isolate the activity's date and time when looking through other logs like firewall or IIS logs. Those logs might then identify your source or give you a place to start looking.

Mark

Right, but if it's a web application, failed logins aren't going to do you a lot of good (unless you have your SQL Server open to the world and someone is actually hitting that directly).

 
Posted : 22/10/2008 10:36 pm
Share: