• DAY5 php + mysql 写一个简单的sql注入平台


    php mysql 在浏览器输入用户名,去数据库查询。查到则显示在浏览器,查不到则显示空。

    sql 里面三个字段 id username password

    create table t1 (id int(3) NOT NULL AUTO_INCREMENT,username char(10) NOT NULL,password varchar(20));

    insert into t1 values(1,'hello','world');

    index.php

    //php mysql 在浏览器输入用户名,去数据库查询。查到则显示在浏览器,查不到则显示空。
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
            <title>查询页面</title>
        </head>
    
         <body>
    
    <form name="form" method="post" action="select.php">    
                <center>
                <table>
                    <tr>
                        <td><br>请输入用户名:<input type="text" name="username"></td>
                    </tr>
                    <tr>
                    </tr>
                    <tr>
                        <td><br><input type="submit"  value="查询">    <input type="reset" value="重置"></td>
                         
                    </tr>
                    </br>
                    <br>
                        <br>
                        输入用户名能够查询到密码,如果不知道请使用sql注入测试
                </table>
                </center>
            </form>
    </body>
    </html>

    select.php

    //php mysql 在浏览器输入用户名,去数据库查询。查到则显示在浏览器,查不到则显示空。
    <?php
    error_reporting(E_ALL || ~E_NOTICE);
    $con = mysql_connect("localhost","wyl","123456");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db("wyl", $con);
    $nm = $_POST['username'];
    $result = mysql_query("  SELECT * FROM t1 where username='".$nm."' ");
    echo "<table border='1'>
    <tr>
    <th>username</th>
    <th>password</th>
    </tr>";
    while($row = mysql_fetch_array($result))
      {
                echo "<tr>";
                echo "<td>" . $row['username'] . "</td>";
                echo "<td>" . $row['password'] . "</td>";
                echo "</tr>";
      }
    echo "</table>";
    mysql_close($con);
    ?>
  • 相关阅读:
    双指针
    二分查找
    二叉树
    递归思想
    排序算法
    Java常用集合使用方法总结
    攻防世界-PHP文件包含
    正则表达式随笔
    ts 函数
    ts 联合类型
  • 原文地址:https://www.cnblogs.com/lt132024/p/5548766.html
Copyright © 2020-2023  润新知