Skip to content

Instantly share code, notes, and snippets.

@Tsutou
Last active August 8, 2019 09:43
Show Gist options
  • Save Tsutou/5ac5ae976b620480e2fdc3b901012078 to your computer and use it in GitHub Desktop.
Save Tsutou/5ac5ae976b620480e2fdc3b901012078 to your computer and use it in GitHub Desktop.
Webセキュリティ覚書 : "攻撃" 編 [ 初学者向け ] ref: https://qiita.com/Tsutou/items/4fd498f8ab2638bd5650
SELECT * FROM users WHERE id='$user_id' and password='$password'
SELECT * FROM users WHERE id='$user_id' and password='' or '1' = '1'
http://hanzai.com?location=%0d%0d<script type=”text/javascript”>alert(“アホなの?”);</script>
<?xml version="1.0"?>
<str><data1>aaa</data1><data2>bbb</data2></str>
<?xml version="1.0"?>
<!DOCTYPE str [
<!ENTITY pass SYSTEM "/etc/password">
]>
<str><data1>&password;</data1><data2></data2></str>
SELECT * FROM users WHERE id= ? and password= ?
$sql = "SELECT * FROM users WHERE id= ? and password= ? ";
//プリペアードステートメント->実行したいSQLをコンパイルした一種のテンプレート
$sth = $dbh->prepare($sql);
//1つ目の?にバインド
$sth->bindParam(1, $user_id, PDO::PARAM_STR);
//2つ目の?にバインド
$sth->bindParam(2, $password, PDO::PARAM_INT);
//PDPStatement::excecute-> プリペアドステートメントを実行する
$sth->execute();
<input type="text" name= 'nickname' >
<?php echo $_POST['nickname']; ?>
<script type=”text/javascript”>
 alert("お前はアホなのか?");
</script>
& => &amp;
< => &lt;
> => &gt;
" => &quot;
' => &#39;
function escape($str) {
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
106662
106664
106666
106668
106669
106675
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment