hide and seek
经过注册登陆后发现有上传点,发现只能上传zip文件,然后发现zip中压缩的文件内容会被解压后输出在页面上,上传php马失败
尝试读取linux下的环境变量:/proc/self/environ
1 | UWSGI_ORIGINAL_PROC_NAME=/usr/local/bin/uwsgiSUPERVISOR_GROUP_NAME=uwsgiHOSTNAME=c52b2c48ec0bSHLVL=0PYTHON_PIP_VERSION=18.1HOME=/rootGPG_KEY=0D96DF4D4110E5C43FBFB17F2D347EA6AA65421DUWSGI_INI=/app/it_is_hard_t0_guess_the_path_but_y0u_find_it_5f9s5b5s9.iniNGINX_MAX_UPLOAD=0UWSGI_PROCESSES=16STATIC_URL=/staticUWSGI_CHEAPER=2NGINX_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-8SUPERVISOR_ENABLED=1PYTHON_VERSION=3.6.8NGINX_WORKER_PROCESSES=autoSUPERVISOR_SERVER_URL=unix:///var/run/supervisor.sockSUPERVISOR_PROCESS_NAME=uwsgiLISTEN_PORT=80STATIC_INDEX=0PWD=/app/hard_t0_guess_n9f5a95b5ku9fgSTATIC_PATH=/app/staticPYTHONPATH=/appUWSGI_RELOADS=0 |
找到 /app/it_is_hard_t0_guess_the_path_but_y0u_find_it_5f9s5b5s9.ini文件
得到:
1 | [uwsgi] module = hard_t0_guess_n9f5a95b5ku9fg.hard_t0_guess_also_df45v48ytj9_main callable=app |
再读/app/hard_t0_guess_n9f5a95b5ku9fg/hard_t0_guess_also_df45v48ytj9_main.py
得到
1 | # -*- coding: utf-8 -*- |
发现随机数种子不安全:由uuid.getnode()获得为固定mac地址
1 | random.seed(uuid.getnode()) |
所以读取mac地址/sys/class/net/eth0/address
mac:02:42:ac:11:00:02–>2485377892354
用python3执行
1 | python3 -c "import random;random.seed(2485377892354);print (str(random.random()*100))" |
得到secret_key=42.42408197657815
伪造session: eyJ1c2VybmFtZSI6ImFkbWluIn0.XFk6SQ.dp9Uh_Kd6tGKQ12uY7eqoSzvrPo
得到flag:hctf{2495e2ef667b367a0738f5eae9d6afb983c2}
贴上百度找的脚本
1 | #!/usr/bin/env python3 |