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);
    ?>
  • 相关阅读:
    Jquery
    JavaScript
    poj--2115 C Looooops
    poj--3970 party
    poj 1061 青蛙的约会
    hdu1250--Hat's Fibonacci
    2318--TOYS
    扩展欧几里得--让你一次刷个够
    关于大数加法的解法
    有关环形数组的约瑟夫问题
  • 原文地址:https://www.cnblogs.com/lt132024/p/5548766.html
Copyright © 2011-2022 走看看