search

Home  >  Q&A  >  body text

mysql - 这个sql注入该怎么解释呢?

http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php

这是个防止sql注入的一个问题。这个问题有点看不懂,

$unsafe_variable = $_POST['user_input']; 

mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");
INSERT INTO `table` (`column`) VALUES('value'); DROP TABLE table;--')

这个是怎么做到sql注入的,一条查询语句可以执行insert to 语句和drop table 语句??

怪我咯怪我咯2770 days ago484

reply all(2)I'll reply

  • 迷茫

    迷茫2017-04-17 13:43:30

    The parameter passed in

    is value'); DROP TABLE table;--. Do you understand?

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:43:30

    mysql_query cannot execute multiple statements, but it can be used by updatexml and extendvalue to obtain other data information.

    INSERT INTO users (id, username, password) VALUES (2,'Olivia' or updatexml(1,concat(0x7e,(version())),0) or'', 'Nervo');
    
    INSERT INTO users (id, username, password) VALUES (2,'Olivia' or extractvalue(1,concat(0x7e,database())) or'', 'Nervo');
    

    Reference: Use insert, update and delete injection to obtain data

    reply
    0
  • Cancelreply