1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

SQL injection

Discussion in 'Databases' started by sheva249, Jan 22, 2010.

  1. #1
    Hi friends,
    my anti virus has detected a virus which is categorized as sql injection. plz tell me what it is? rather i have done coding in the sql server but never knew such kind of thing. if possible give an example for me. thanks in advance.
     
    sheva249, Jan 22, 2010 IP
  2. donmarcos

    donmarcos Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I wander how your antivirus detected an sql injection and onto what ?
     
    donmarcos, Jan 23, 2010 IP
  3. sheva249

    sheva249 Guest

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Avira detected it when i was downloading something via torrent and because of it the whole downloading just got wasted.
     
    sheva249, Jan 24, 2010 IP
  4. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In Simple Language :: SQL injection is a Method to Hack Simple Login Systems of Websites where the Website Programmer were Lazy and didnt Put all the Necessary Validation Required for the Username and Password Input.

    I wonder How can Your Antivirus DETECT it. I would Advice you some other Antivirus Software.

    Regards
     
    fundoobuddy, Jan 24, 2010 IP
  5. bestnow

    bestnow Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That sounds REALLY suspicious that a virus scanner would detect a SQL injection. Are you running some kind of DBMS on your machine?
     
    bestnow, Jan 25, 2010 IP
  6. viewz

    viewz Member

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #6
    is SQL injection dangerous to our database? and how to prevent it to happen to our site?
     
    viewz, Jan 27, 2010 IP
  7. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    No, Its Not Dangerous to Databases... Its like, Some gets access to your members area by Putting Some Crap in Username and Password Field. Its Just That they were able to fool your Login Check.
     
    fundoobuddy, Jan 27, 2010 IP
  8. viewz

    viewz Member

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    If that so... can you tell me how to prevent that, because even it not dangerous to Databases, but seem like it will dangerous to our business, right?
     
    viewz, Jan 27, 2010 IP
  9. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ya, sure it can be harmfull to your business.

    to avoid it, make sure that your site programmer is doing all the necessary checks on the user input data like username and password.

    For a Ex. for selecting The user, a sql query of following type is generally used

    so if User enteres something like
    then it would lead to selecting all the usernames and then something similar for the password field.

    A better approach would be

    $actual_pass = md5($result['password']);
    $user_entered_pass = md5($_GET['password']);

    if($actual_pass == $user_entered_pass)
    {
    // User Good
    }
    else
    {
    // Invalid Login
    }

    That was just an Example. Hope that Helps.
     
    fundoobuddy, Jan 28, 2010 IP
  10. sheva249

    sheva249 Guest

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I don't think something suspicious about my AV. It is working really very well also it detects jokes, phishing, game and many kind of virus. Yes i am using mysql 5 on my machine.


    Hey thanks a lot for helping me.

    I think you have provided a very good tut for the beginners which may help them to understand the phenomenon of sql injection.

    I still thinks that it may be of other kinds too. like as for getting authentication in database, sending database to a remote places. so i think there may be many kind of Sql injections which may contain Trojans too.
     
    sheva249, Jan 28, 2010 IP
  11. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    It could be a trojan which would try SQL injection on your Databases or something like that. As "SQL Injection" is a Method.

    Also, In my post above, it was just an example, for eye opener. there are qide varieties of SQL injection.

    Regards.
     
    fundoobuddy, Jan 28, 2010 IP
  12. pr0xy122

    pr0xy122 Peon

    Messages:
    1,649
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #12
    phishing is not a type of virus. How can it detect that? What is your anti-virus?...
     
    pr0xy122, Jan 28, 2010 IP
  13. D4rk357

    D4rk357 Peon

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    What yu are talking about is basic Sql injection Bypass . There can be Blind Sql injection,Sql Injection through Pages of your websites as well etc.

    The Information Schema Thing In mysql 5 + version makes themeasy targets if inputs not validated correctly .

    Hackers, often use GET method to inject their “union+select+” queries or POST method from one server to another, if authentication has javascript filtering using their OR 1=1 method and the last but not the least, cookies. Cookies are used by very few hackers, however with the use of session cookies, their successful attempts are limited to minimum.
    addslashes() is one of the function that a developer can use if !(get_magic_quotes_gpc). But, adding this line can be troublesome in most cases, where amount of variables are really high, it may make the code look sluggish to have mysql_real_escape_string() in every variable passed. To get rid of all these:
    Go to your php.ini file and set:

    magic_quotes_gpc = On

    magic_quotes_gpc is by default set to Off for optimal performance of the server.

    However, if you are using a shared/paid hosting and do not have access to php.ini file then add the following to your .htaccess file.

    php_flag magic_quotes_gpc on

    However, cannot promise that above mentioned “tweak” will work till eternity. You can never know what 0-day comes up!
     
    D4rk357, Jan 29, 2010 IP
  14. K.Meier

    K.Meier Well-Known Member

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #14
    If the hacker can insert DELETE, UPDATE commands through the SQL Injection, then he can delete your whole Database! So yes I would say it can be VERY dangerous!
     
    K.Meier, Jan 30, 2010 IP
  15. D4rk357

    D4rk357 Peon

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Absolutely correct it is very dangerous
     
    D4rk357, Jan 30, 2010 IP
  16. Hawkthalas

    Hawkthalas Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    If you are worried with sql injection, this post may be helpful.

    www owasp org/index.php/SQL_Injection_Prevention_Cheat_Sheet

    Hope it is what you need.
     
    Hawkthalas, Feb 9, 2010 IP
  17. JoeWJ

    JoeWJ Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    If you pregmatch your login page to letters and numbers only that should stop it.
    Although you have to remember to pregmatch your register aswell because if someone makes a account called example_1 they couldn't get on.
     
    JoeWJ, Feb 12, 2010 IP
  18. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #18
    except for the fact that someone can add a drop table command in the injection... making it, you know.. dangerous.
     
    killaklown, Mar 7, 2010 IP
  19. killaklown

    killaklown Well-Known Member

    Messages:
    2,666
    Likes Received:
    87
    Best Answers:
    0
    Trophy Points:
    165
    #19
    i agree, before querying the database, check if the value entered by the user has suspicious values, ie : %, DROP, LIKE, ", ', ;, *

    Not saying that those values work in all cases, but for something like a username, or someones name, chances are they wont have a name of username containing that (for DROP and LIKE, check for spaces after/before, since a username/name COULD have that word in their name)
     
    killaklown, Mar 7, 2010 IP