Created
June 17, 2019 21:47
-
-
Save abd1rahmane/fcaea5c7e69a75c987f55df2e5ae87eb to your computer and use it in GitHub Desktop.
Bash as Rest service (unsecure)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from flask import Flask | |
from flask import jsonify, request, render_template | |
import subprocess | |
app = Flask(__name__) | |
@app.route('/bash/run/', methods=['GET']) | |
def run_script(): | |
command = request.args.get('command', default = '', type = str) | |
print(command) | |
ok = False | |
try: | |
subprocess.Popen(command, shell=True,stdin=None, stdout=None, stderr=None, close_fds=True) | |
#print(p.read()) | |
ok = True | |
except Exception as e: | |
print(e) | |
print(ok) | |
return jsonify(ok) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0',port='5050',debug=False) # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://127.0.0.1:5050/bash/run/?command=firefox