26 lines
718 B
Python
26 lines
718 B
Python
from flask import Flask, request, jsonify
|
|
import subprocess
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/execute', methods=['POST'])
|
|
def execute_command():
|
|
data = request.json
|
|
# The 'command' key in the JSON request should contain the command to be executed.
|
|
command = data.get('command', '')
|
|
|
|
# Execute the command without any safety checks.
|
|
try:
|
|
subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
return jsonify({
|
|
'status': 'success',
|
|
})
|
|
except Exception as e:
|
|
return jsonify({
|
|
'status': 'error',
|
|
'message': str(e)
|
|
}), 500
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True, host="0.0.0.0")
|