SQL Injection DROP TABLE not working

I need to demonstrate SQL Inject using PHP/MySQL. I want to inject a DROP TABLE query in a login form but it never works. (TRUNCATE table works fine OTOH). After I input '; drop table users; # '; drop table users; # '; drop table users; # as field input; query turns out to be

SELECT * FROM `users` WHERE `email` = ''; DROP TABLE users; #' AND `password` LIKE '3232';

But it never works using mysql_query() function. When I copy/paste this query in PHPmyAdmin directly, it works perfectly and table gets dropped. What can be the issue?


This is not possible in php/MySQL as php does not support stacked queries. The moment you inject semicolon (;) it will fail.

You can do many other much more creative exploits using sql injection in a php-mysql application though.

  • Enumerate all databases
  • Table Names and Column Names
  • Values stored in tables
  • Upload a php backdoor
  • Check Out for SQL-Map as well.


    MULTIPLE SQL Execution is not enabled by defaults.

    So SQL Injection like ;drop table won't work. please enable multiple sql execution. this could be enabled like http://php.net/manual/en/mysqli.quickstart.multiple-statement.php if you are using mysqli.

    useful SQL Injection is :

    SELECT COUNT(*) FROM users
    WHERE user_id = '$user_id' AND passwd = '$passwd'
    

    and user inserts passwd to ' || '1' = '1 ' || '1' = '1 .

    链接地址: http://www.djcxy.com/p/93982.html

    上一篇: HTML5 <input type =“date”>

    下一篇: SQL注入DROP TABLE不起作用