写了一个前端验证,html也忘记了,页面写的很粗略,将就看一下,毕竟是我人生第一个自己写的漏洞

 

 

 

主界面,省略掉测试他是否有漏洞。

 

 

Id处输入: 1’ or 1=1#

 

省略中间步骤,直接爆一下东西:

输入:1’ and 1=2 union select 1,2,group_concat(username,0x3a,password) from user#

 

 

这里贴一下我的代码

 <html>
<head>
    <title>M3tar的第一个注入</title>
    <meta http-equiv="content-type"content="text/html"charset="Unicode">
</head>
<body>
<form action="M-star.php" method="post">
    <h1>Sql注入</h1>

    <table>
      <tr>
         <td>id</td>
         <td><input type="text" name="id"></td>
       </tr>
        <tr>
        <td>用户名</td>
        <td><input type="text" name="username"></td>
      </tr>
      <tr>
        <td>密 码</td>
        <td><input type="password" name="password"></td>
      </tr>
      <tr>
        <td><input type="submit" value="提交"></td>
        <td><input type="reset" value="重置"></td>
      </tr>
    </table>

</form>
</body>
</html>


<?php
if($_POST){
  $con=mysql_connect("localhost","root","root");
  mysql_select_db("csm",$con);

  $id = $_POST['id'];
  $sql="select * from user where id='$id'";
  $query=mysql_query($sql,$con);
  $arr=mysql_fetch_array($query, MYSQL_ASSOC);

  if(!empty($arr)){
     echo '<pre>',print_r($arr,1),'</pre>';
  }else{
      echo "输入有误";
  }
}
?>

 

关于写代码学到的一点点心得

1)php:写这个还是要对php有那么一点点的了解,对于数据库编程的内容也要有一些了解:

数据库的三层结构:客户端 mysql dbms 数据对象

2)可以总结一下mysql扩展库操作mysql数据库的步骤

3)关于phpstudy的理解:

  以前只是下了phpstudy,知道往WWW下扔东西,才知道还可以秒切换版本,很不错的功能,希望以后能多加应用。因为写一==这个个简单的sql注入漏洞的界面,emmm,很难受,写不来数据库,百度了半天,很瓜,原来phpstudy里面就可以新建数据库(phpMyadmin、Mysql-front),赶紧照着百度依葫芦画瓢,第一次接触这个自己后台的数据库,非常的兴奋。还有其他问题,现在还没有怎么遇到,以后再补充。

4)html和css感觉白学了,都记不得了,要抓紧时间补足啊。

5)POST和GET参数分别的优势和劣势 http://www.cnblogs.com/hyddd/archive/2009/03/31/1426026.html 详细的可以看这个资料

 posted on 2017-08-10 21:14  M3tar  阅读(353)  评论(0编辑  收藏  举报