Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

EDIT : Sorry, my question clearly wasn't clear. I don't want to report attempted server attacks internally; we already have systems that log. record and report that activity.

What I was keen to do was to report the attacks to the perpetrator's ISP or somesuch.

Original question:

Our sites are immune to SQL Injection (AFAIK!), but of course we still get targeted regularly.

Is there some way I could automate reporting of attempted attacks - reverse DNS lookup etc.?

Although I guess its only worthwhile if, overall, it would be doing the community a favour.

Ditto I suppose for all the other attacks we see - probing for wide-open BBS, MySQL, PHPAdmin, etc.

share|improve this question

migrated from stackoverflow.com Oct 16 '09 at 10:48

This question came from our site for professional and enthusiast programmers.

    
Who are you thinking of reporting this information to? –  John Gardeniers Oct 16 '09 at 11:55

6 Answers 6

up vote 2 down vote accepted

Donate your logs to SANS! They have a client for most firewalls that will pull the logs and send them to the DShield database.

share|improve this answer
    
That looks useful, thanks. Not sure I can detect this at the firewall, but their format for client-submissions doens't look too onerous. –  Kristen Oct 16 '09 at 12:03

Either everyone else understood something else or I did, but from what I can understand you are trying to report the people attempting SQL injections to their ISPs.

This will usually be a dead end, and you're better off just blocking the users attempting the attacks, as most machines performing attacks are not usually owned by the 'hacker', and instead they could be compromised machines, or someone abusing a website which offers free vulnerability scans or something similar.

share|improve this answer
    
You did understand, thanks. I've clarified my question. On re-reading it it is clear to me that "Report" was ambiguous. –  Kristen Oct 16 '09 at 11:56

By SQL injection from sites, I take it: (a) you have some web forms, (b) there's a SQL back-end, (c) you use methods which prevent user input from being mis-interpreted as SQL (parameterized queries, etc.)

But still you would like to detect attempts at SQL injection. Ok.

One of the standard ways to attempt SQL injection is to probe around seeking an input field which is incorporated to a SQL query by using string insertion. For example:

snprintf(buf, dimensionof(buf), "SELECT calory_limit FROM user_diets WHERE user_firstname='%s' AND user_surname='%s'", firstname, surname);

Where surname and firstname are unfiltered inputs from a web form. In this example, a user could provide the name firstname=Johnny', surname='-';DROP DATABASE;--

The sprintf would result in:

SELECT calory_limit FROM user_diets WHERE user_firstname='Johnny'' AND user_surname=''-';DROP DATABASE;--'

Because '' (two single quotes) in SQL is interpreted as an escaped ' which is part of the string, we have "broken open" the string delimiter in the intended original statement. This lets us convert what later should have been string, surname, into commmand.

In short, look for people entering fields which:

  • End in a single quote mark
  • Begin with a single quote mark
  • Contain a "--" at or near the end (The purpose of wrapping the attack payloads up with a SQL comment delimiter is that without that, the attacker's distortion of the intended query could leave some unparsable command bits at the end. These could generate an error message to a log and alert you.)

Also, you might consider the same heuristics after, e.g., UTF-8 decoding the input. Or UTF-8 decoding it twice over. The penetration tester will be thinking about bugs that might be in your code, so they will try inputs which seem not to make sense -- such as twice-UTF-8-encoded single quote marks.

Also, look for " and other HTML entity sequences.

You can search arxiv.org and find some papers which detail certain specific attack flavors: cross-site scripting, SQL injection, URL modification. Reading some papers there will lead you to more.

share|improve this answer

Most ISPs have an abuse@ispname.com email address for reporting such things.. If you can revers lookup the ISP name from the IP I would send the info there.

share|improve this answer

Check for quote symbols and if there are any look for SQL commands?

share|improve this answer

Playing devils advocate, it's almost always pointless to waste your time reporting these machines. Most attacks come from zombies machines that the user has no idea is even occurring. So even if you report them to their ISP and their ISP cuts their connection until they have their machine cleaned they will most likely just end up infected again later or even if they don't the fact you removed 1 zombie machine from the internet is a meaningless achievement.

The only time I would say it's worth reporting these attempts is if the machine is part of a hosted network like ThePlanet. Taking a compromised server off the internet is a big deal especially since the owner of the server might not even realize it's compromised. The other difference is the scale of attacks the server is capable of versus the home pc.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.