forked from ShiftLeftSecurity/shiftleft-python-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_injection.py
More file actions
35 lines (24 loc) · 826 Bytes
/
Copy pathcommand_injection.py
File metadata and controls
35 lines (24 loc) · 826 Bytes
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
30
31
32
33
34
35
import subprocess
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def index():
with open('menu.txt','r') as f:
menu = f.read()
return render_template('command_injection.html', menu=menu)
@app.route('/menu', methods=['POST'])
def menu():
param = request.form['suggestion']
command = 'echo ' + param + ' >> ' + 'menu.txt'
subprocess.call(command, shell=True)
with open('menu.txt','r') as f:
menu = f.read()
return render_template('command_injection.html', menu=menu)
@app.route('/clean')
def clean():
subprocess.call('echo Menu: > menu.txt', shell=True)
with open('menu.txt','r') as f:
menu = f.read()
return render_template('command_injection.html', menu=menu)
if __name__ == '__main__':
app.run(debug=True)