当前位置:网站首页>oh-my-lotto
oh-my-lotto
2022-04-23 11:29:00 【succ3】
Knowledge point : Change the environment variable to bypass wget
md5 Blast
import hashlib
for i in range(1000000000):
a = hashlib.md5(str(i).encode('utf-8')).hexdigest()
if a[0:6] == '0c5fbf':
print(i)
print(a)
The key is three routes .
result route , Returns a value given by him , That's what we're going to predict .
@app.route("/result", methods=['GET'])
def result():
if os.path.exists("/app/lotto_result.txt"):
lotto_result = open("/app/lotto_result.txt", 'rb').read().decode()
else:
lotto_result = ''
return render_template('result.html', message=lotto_result)
forecast route , Mainly used to upload files .
@app.route("/forecast", methods=['GET', 'POST'])# Route for uploading files
def forecast():
message = ''
if request.method == 'GET':
return render_template('forecast.html')
elif request.method == 'POST':
if 'file' not in request.files:
message = 'Where is your forecast?'
file = request.files['file']
file.save('/app/guess/forecast.txt')
message = "OK, I get your forecast. Let's Lotto!"
return render_template('forecast.html', message=message)
lotto route , This is what we can get flag The place of , When the predicted value is the same as the given value this time, it will return flag.
@app.route("/lotto", methods=['GET', 'POST'])
def lotto():
message = ''
if request.method == 'GET':# If the reference is GET Go to lotto page
return render_template('lotto.html')
elif request.method == 'POST':# If the reference is post Then continue
flag = os.getenv('flag')# Get the value of the environment variable , If not, return to the meeting none, If it exists, return the key value
lotto_key = request.form.get('lotto_key') or ''
lotto_value = request.form.get('lotto_value') or ''# Get form values
try:
lotto_key = lotto_key.upper()# Convert lowercase letters to uppercase
except Exception as e:
print(e)
message = 'Lotto Error!'
return render_template('lotto.html', message=message)
if safe_check(lotto_key):
os.environ[lotto_key] = lotto_value
try:
# From the intranet lotto Get a random value
os.system('wget --content-disposition -N lotto')
if os.path.exists("/app/lotto_result.txt"):# Judge whether the file exists
lotto_result = open("/app/lotto_result.txt", 'rb').read()# Open and read
else:
lotto_result = 'result'# If the file does not exist, it will be assigned directly result
if os.path.exists("/app/guess/forecast.txt"):# Upload files locally
forecast = open("/app/guess/forecast.txt", 'rb').read()
else:
forecast = 'forecast'
if forecast == lotto_result:# If we predict the content and Intranet lotto_result.txt If the content is the same, return flag
return flag
else:
message = 'Sorry forecast failed, maybe lucky next time!'
return render_template('lotto.html', message=message)
except Exception as e:
message = 'Lotto Error!'
return render_template('lotto.html', message=message)
else:
message = 'NO NO NO, JUST LOTTO!'
return render_template('lotto.html', message=message)
There are three steps :
1. First visit lotto page .
2. Revisit result page , Get the value he gives .
3. Change the environment variable to PATH, Revisit lotto page .
analysis :
The first two steps are to get the current value , But next time the value will change , So you can't get flag 了 , How can we control the value to be constant or change the value ?
The third step is to control the random value of the intranet .
reason :
You can see that we can control the name and value of environment variables .
if safe_check(lotto_key):
os.environ[lotto_key] = lotto_value
try:
# From the intranet lotto Get a random value
os.system('wget --content-disposition -N lotto')
PATH
Variable is used to save the directory path that can be searched , If the program to be run is not in the current directory , The operating system can search in turn PATH
The directory recorded in the variable , If you find a program to run in these directories , The operating system can run directly , The premise is to have execution permission .
That is, we control the environment variables PATH
, So he can't find wget command , that wget --content-disposition -N lotto An error will be reported, resulting in the termination of the program ,/app/lotto_result.txt
The content has always been the first visit , The randomly generated value .
import requests
url = "http://127.0.0.1:8880/"
def lotto(key,value):
data = {
"lotto_key": key,
"lotto_value": value}
txt=requests.post(url + "lotto",data=data).text
print(txt)
def getResult():
txt=requests.get(url+"result").text
p=txt.split("<p>")[-1].split("</p>")[0]
print(p)
return p
lotto("","")
result= {
"file":getResult()}# Get predictions
requests.post(url + "forecast",files=result)# Upload predicted values
lotto("PATH","xxxx")
版权声明
本文为[succ3]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231110505183.html
边栏推荐
- Golang Pen & interview 01
- MySQL数据库10秒内插入百万条数据的实现
- Detailed explanation of MySQL creation stored procedure and function
- qt 64位静态版本显示gif
- ImportError: libX11. so. 6: cannot open shared object file: No such file or directory
- Significance of actively participating in middle school robot competition
- 解读2022机器人教育产业分析报告
- Study notes of C [8] SQL [1]
- Tensorflow使用keras创建神经网络的方法
- R-Drop:更强大的Dropout正则方法
猜你喜欢
Analyzing the role of social robots in basic science
Nacos Foundation (6): Nacos configuration management model
解析性能良好的机器人使用守则
QT 64 bit static version display gif
26. Delete duplicates in ordered array
Learn go language 0x04: Code of exercises sliced in go language journey
Interpretation of 2022 robot education industry analysis report
解析社交性机器人对基础科学的作用
云呐|固定资产盘点中,支持多种盘点方式(资产清查盘点)
RebbitMQ的初步了解
随机推荐
golang之筆試題&面試題01
docker MySQL主从备份
积极参与中学机器人竞赛的意义
Learning go language 0x08: practice using error in go language journey
Laravel绑定钉钉群警报(php)
Nacos Foundation (7): Configuration Management
Upgrade the functions available for cpolar intranet penetration
mysql分表之后如何平滑上线详解
Prevent SQL injection in web projects
采用百度飞桨EasyDL完成指定目标识别
Understanding of MQ
简易投票系统数据库设计
少儿编程结构的改变之路
How to count fixed assets and how to generate an asset count report with one click
ES6 learning notes II
RebbitMQ的初步了解
QT 64 bit static version display gif
Usage Summary of datetime and timestamp in MySQL
MQ在laravel中简单使用
Analyze the rules for the use of robots with good performance