zoukankan      html  css  js  c++  java
  • 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);
    ?>
  • 相关阅读:
    __name__使用方法,模块查找顺序和模块的绝对导入
    模块
    ATM程序结构
    迭代器
    常用内置方法
    生成式,匿名函数及内置函数部分使用方法
    算法之二分法和三元表达式
    redis配置文件
    PythonStudy——shutil 模块
    PythonStudy——pickle 模块 (泡菜)
  • 原文地址:https://www.cnblogs.com/lt132024/p/5548766.html
Copyright © 2011-2022 走看看