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);
    ?>
  • 相关阅读:
    循环选择判断文件类型
    SpringBoot+MyBatis+Mysql+Durid实现动态多数据源
    Spring 常用注解
    Spring IOC容器中那些鲜为人知的细节
    java8 Stream对List<Map>的分组合并操作
    Java8的CompletableFuture 使用详解
    Spring MVC源码分析
    Spring AOP源码分析
    Spring中AOP必须明白的几个概念
    UriComponentsBuilder和UriComponents url编码
  • 原文地址:https://www.cnblogs.com/lt132024/p/5548766.html
Copyright © 2011-2022 走看看