Detecting signs of sql injection or other injections

Discussion in 'Security' started by bvspoguk, May 23, 2007.

  1. #1
    I am planning to use log parser to daily scan on of my clients servers for any signs of sql injection or other injections. What kind of signs would you look for? So far i have come up with single quote ' or brackets used in the cs-uri-query

    Have i missed out on any?
     
    bvspoguk, May 23, 2007 IP
  2. syedwasi87

    syedwasi87 Active Member

    Messages:
    2,147
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #2
    hmm u run forum based on vb or phpbb? on vb i never experienced a sql injecton tho..
     
    syedwasi87, May 23, 2007 IP
  3. bvspoguk

    bvspoguk Peon

    Messages:
    103
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am not talking about a forum, its an application on of my client has made himself however it is quite large and certain parts of the site are not handling user input to make it safe, however i thought if i can premptively monitor the logs than i can watch for signs of SQL injections.
     
    bvspoguk, May 23, 2007 IP
  4. tandac

    tandac Active Member

    Messages:
    337
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Depending on how the application works the logs may not tell you a lot. If the app uses parameters passed via GET your access logs will show the attempts.

    If you use POST you may not see much of anything.

    Your client should make an effort to fix his application.
     
    tandac, May 27, 2007 IP
  5. selbourne

    selbourne Peon

    Messages:
    465
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #5
    consider -- for an SQL injection as well
     
    selbourne, May 27, 2007 IP
  6. scaturan

    scaturan Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if you're using Apache, look into mod_security which offers an extensive set of logging and filtering features.
     
    scaturan, Jun 2, 2007 IP
  7. nukepuppy

    nukepuppy Peon

    Messages:
    93
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    mod_security for sure..............
     
    nukepuppy, Jun 5, 2007 IP
  8. damonp

    damonp Peon

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    In the general case you could use a scanner such as Nikto and Nessus to do proactive scanning:
    http://www.cirt.net/code/nikto.shtml
    http://www.nessus.org/
     
    damonp, Jun 6, 2007 IP
  9. bvspoguk

    bvspoguk Peon

    Messages:
    103
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks for all the info, i have used nessus before however nessus does not help much with web application detection unless i missed something. At the moment the site is on a iis 6 server. I am using logparser to scan for certain characters in the get requests. I know i cant do much for post unless i implement and ids or something,
     
    bvspoguk, Jun 9, 2007 IP
  10. vizdak

    vizdak Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    just search for backtrack 2.0 in google. it's good for penetration testing. i cant post links for now. sorry.
     
    vizdak, Jun 10, 2007 IP
  11. scamp81

    scamp81 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Any GET request with EXEC in the query string will be a problem 99.99% of the time.
     
    scamp81, Jun 2, 2008 IP
  12. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You can modify your Apache logs to log the POST string as well as the GET string. You should be aware that this will log all POST variables including passwords in clear text. Format spec in the Apache Docs

    Since IP addresses are apparently "personally identifiable information" these days, you should probably be treating your access logs as if they had passwords in them anyway.

    I would probably try looking at SQL logs instead of Apache logs. When people are feeling their way through a vulnerable form looking for SQL injections they will often add things like
    ' OR 1=1; --
    Code (markup):
    which will return every row in the table. This is likely to take a long time to return and may well end up in your MySQL slow logs. It's good practice to look through your MySQL slow logs anyway.

    Another thing you could do would be to turn on binary logging in MySQL and use mysqlbinlog to examine them. This will cause every SQL query to be written to disk which will have an impact on the performance of your server however it will likely be a very small impact.
    Once you have binary logging enabled, write a script that greps out all the normal queries that your client's application makes and run it over the binary logs each day. If you see a query that doesn't match the regular expressions you have defined as "normal" then either your client has written a new SQL query or someone else has access to your database.
     
    Ladadadada, Jun 2, 2008 IP
  13. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #13
    an alternative to mod_security ,may be "snort"
    I am no snort - pro but as far as I understand snort, it's real time filtering with the option to ground OR log access containing certain ( wrong ) strings as used by hackers.
    as below listed by others before - this would require you to know which strings are to be considered "normal" to create your filter for all "other" strings.

    snort thus is to PREVENT hack/injections when used beyond its logging features.
     
    hans, Jun 11, 2008 IP