Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:16:35+00:00 2026-05-27T06:16:35+00:00

Possible Duplicate: What does mysql_real_escape_string() do that addslashes() doesn't? I have been reviewing articles

  • 0

Possible Duplicate:
What does mysql_real_escape_string() do that addslashes() doesn't?

I have been reviewing articles on how/why PHP’s addslashes function is vulnerable to sql injection. Everything I have read says there are problems with specific mysql encoding types (default-character-set=GBK), or there are problems if magic_quotes are enabled. However, I have been unable break out of the addslashes() function in this scenario and do something malicious – such as login as an administrator.

    $user = addslashes($_POST['user']);
    $pass = sha1($_POST['pass']);
    $sql = "SELECT * FROM admins WHERE user = '".$user."' AND `pass` = '".$pass."'";

    $nums = mysql_num_rows(mysql_query($sql));

    if($nums==1){
    $_SESSION['admin_user'] = $user;
    $_SESSION['admin_pass'] = $pass;

This is a (minor) security audit for a client and I will recommend that they utilize PDO, but I need to display their current vulnerability.

References:

  • http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string
  • http://hakipedia.com/index.php/SQL_Injection#addslashes.28.29_.26_magic_quotes_gpc
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:16:36+00:00Added an answer on May 27, 2026 at 6:16 am

    Shiflett shows a full working exploit in his blog entry. The code you show above doesn’t seem to be following that example as it’s not using the character set that exhibits the vulnerability. Still, the hole definitely exists.

    Even if it happens to be safe in the specific scenario, the practice of using addslashes() is still dangerous and Shiflett’s article should give you enough material to argue with, even though the circumstances the exploit requires are very esoteric, and they’re not entirely trivial to reproduce.

    If your client doesn’t accept the danger without seeing a live exploit on their specific system, then they’re not worth doing a security audit for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Does SQL Server 2005 have an equivalent to MySql’s ENUM data type?
Possible Duplicate: Does Java guarantee that Object.getClass() == Object.getClass()? If I have a class
Possible Duplicate: Headers already sent by PHP My problem is that I have a
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Does std::list::remove method call destructor of each removed element? I have a
Possible Duplicate: E-mail validation in php? please help I have Ajax sign up form.
Possible Duplicate: Does a finally block always run? I learned that the finally clause
Possible Duplicate: Does std::list::remove method call destructor of each removed element? I have a
Possible Duplicate: Does an abstact classes have a VTABLE? Does a vtable gets created
Possible Duplicate: Does <STYLE> have to be in the <HEAD> of an HTML document?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.