【PHP】 简单的SQL注入Demo
2015-01-05 14:07
555 查看
SQL注入原理是通过字符串的拼接组合来实现黑客想要实现的结果
以下为一个简单的注入Demo,当用户名填写为 ' or 1=1# 的时候,SQL语句变为
select * from users where username='' or 1=1#' and password=''
#后面内容为注释,这句话就相当于 select * form users; 从而实现了注入效果
原文链接 http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2012/0210/9803.html
以下为一个简单的注入Demo,当用户名填写为 ' or 1=1# 的时候,SQL语句变为
select * from users where username='' or 1=1#' and password=''
#后面内容为注释,这句话就相当于 select * form users; 从而实现了注入效果
<html> <head> <title>Sql注入演示</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> </head> <body > <form action="" method="post"> <fieldset > <legend>Sql注入演示</legend> <table> <tr> <td>用户名:</td> <td><input type="text" name="username"></td> </tr> <tr> <td>密 码:</td> <td><input type="text" name="password"></td> </tr> <tr> <td><input type="submit" value="提交"></td> <td><input type="reset" value="重置"></td> </tr> </table> </fieldset> </form> </body> </html> <?php if($_POST['username']){ $conn=@mysql_connect("localhost",'root','') or die("数据库连接失败!");; mysql_select_db("test",$conn) or die("您要选择的数据库不存在"); $name=$_POST['username']; $pwd=md5($_POST['password']); $sql="select * from users where username='$name' and password='$pwd'"; echo $sql."<br><br>"; $query=mysql_query($sql); $arr=mysql_fetch_array($query); if(is_array($arr)){ echo "登陆成功!"; }else{ echo "您的用户名或密码输入有误,请重新登录!"; } } ?>
原文链接 http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2012/0210/9803.html
相关文章推荐
- ZendStudio php WebService制作一:简单WebService Demo
- php websocket 简单DEMO
- PHP--简单Demo
- php防止sql注入简单分析
- 原生php文件上传简单demo
- ZendStudio php WebService制作一:简单WebService Demo
- 复习微信应用中,php采集简单demo
- php web开发安全之sql注入和防范:(一)简单的select语句注入和防范
- PHP简单代码防止SQL注入
- QtQuick和PHP 最简单的通信demo
- DAY5 php + mysql 写一个简单的sql注入平台
- php 防止sql注入的简单方法
- PHP简单预防sql注入的方法
- 无聊测试下php5多重继DEMO简单实现方法
- php+as3简单聊天室(总结一下前面仙剑demo都写了些什么)
- html中表单post方法与php还有sql交互的最简单demo
- RabbitMQ学习之(四)_PHP操作RabbitMQ简单Demo
- php 使用PDO,防止sql注入 简单说明
- C、go、python、java、php和node.js 简单循环累加运算速度测试[测试demo仅供参考]
- phpSQL注入的简单解决办法