SQL injection and Quote escaping

Discussion in 'Ethical hacking' started by tradesun, Jun 28, 2015.

  1. tradesun

    tradesun New Member

    Joined:
    Jun 28, 2015
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    $name = $_GET['name']
    Select * from table where name = '{$name}'

    Is there any way to exploit this kind of code,
    considering that it is part of a wordpress app (which mean quotes are being escaped)
    so stuff like this will not wok - Page.php?name='; drop table table;
    (php and mysql)

    I read about a vulnerability only on GBK charset - let say it uses a different charset.

    Does it mean that it is completely safe - can any one exploit it?
     
  2. Avantika Pandey

    Avantika Pandey New Member

    Joined:
    Feb 22, 2023
    Messages:
    20
    Likes Received:
    4
    Trophy Points:
    3
    Gender:
    Female
    Although quotes are being escaped, it is still possible to exploit this kind of code if the input is not properly sanitized. Even if the quotes are being escaped, other characters such as semicolons, parentheses, and backticks can be used to inject malicious code.

    For example, an attacker could use the input ' OR 1=1;-- which would result in the following SQL query:
    Select * from table where name = '' OR 1=1;--'

    The double hyphen at the end of the query is used to comment out the remaining part of the original query, which prevents any syntax errors.

    Therefore, it is important to properly sanitize all user input, and to use prepared statements or parameterized queries instead of building SQL queries with user input.

    Regarding the vulnerability related to the GBK charset, it is specific to the way that character encoding is handled by MySQL. It is not related to WordPress or PHP. However, it is still important to properly sanitize all user input, regardless of the character encoding being used.
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice