Files
wapifuzz/tests/command_injection/handler.py
2019-10-09 13:24:35 +02:00

26 lines
761 B
Python

import os
import urllib.parse
from http.server import BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'plain/text')
self.end_headers()
def do_GET(self):
self._get_path_parameters()
self._set_headers()
self.wfile.write(b'OK')
def _get_path_parameters(self):
path = urllib.parse.unquote(self.path)[len("/pets?attributeName="):]
if path.startswith("sleep "):
self._try_to_execute_command(path)
def _try_to_execute_command(self, path):
os.system(path)
def send_error(self, code, message=None, explain=None):
pass