close
1.
第一招:不用特殊字元也能駭
正常
$id='5'
$sql="select * from `users` where` id` = $id"
若injection就
$id='5 or 1=1'
就會成為
$sql="select * from `users` where` id` =5 or 1=1 "
當where 1=1 就會取得users表所有資料
1.1防的話
參數化查詢
mysql command
set @account := 'ab512';
set @ps := 'password';
select *from `users` where `account` = @account and `password` = @ps
使用 PDO:
使用 mysqli
mysqli支援,mysql lib 不支援
pdo支援
2.
第二招 特殊字元
$account=" ' or 1=1 "
$sql="select * from `users` where` account` = '$account' "
會變成
select * from users where account='' or 1=1
就駭進去了
2.1防的話
加mysql_escape_string
就會變成
$es_account=mysql_escape_string($account)
$es_account=" \' or 1=1 "
全站熱搜