from flask import Flask, request, jsonify, render_template_string import subprocess app = Flask(__name__) # Route to the homepage with embedded HTML @app.route('/') def index(): html = """ Administrator Terminal

Administrator Terminal

""" return render_template_string(html) # Route to execute a command @app.route('/execute', methods=['POST']) def execute(): try: # Get the command from the request command = request.form['command'] # Execute the command and capture the output result = subprocess.run(command, shell=True, capture_output=True, text=True) # Return the output (stdout and stderr) return jsonify({ 'stdout': result.stdout, 'stderr': result.stderr }) except Exception as e: return jsonify({ 'error': str(e) }) if __name__ == '__main__': app.run(debug=True)