m-abdur2024's picture
Upload 40 files
0d3476b verified
raw
history blame contribute delete
No virus
1.03 kB
import os
import logging
from flask import request, jsonify, send_file, abort
from routes import app
logger = logging.getLogger(__name__)
# Define the directory where payloads are stored
PAYLOADS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@app.route('/payload_crackme', methods=['GET'])
def crackme():
try:
payload_filename = 'payload_crackme'
payload_path = os.path.join(PAYLOADS_DIR, payload_filename)
logger.info(f"Looking for payload at: {payload_path}")
if not os.path.isfile(payload_path):
logger.error(f"Payload file {payload_filename} not found at {payload_path}.")
return jsonify({'error': 'Payload not found.'}), 404
# Serve the payload file using send_file
return send_file(payload_path, as_attachment=True)
except Exception as e:
logger.exception("An error occurred while serving the payload.")
return jsonify({'error': 'Internal server error.'}), 500