File size: 1,030 Bytes
0d3476b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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