MCPcopy
hub / github.com/t3l3machus/hoaxshell / do_POST

Method do_POST

hoaxshell.py:509–546  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

507
508
509 def do_POST(self):
510
511 global prompt
512 timestamp = int(datetime.now().timestamp())
513 Hoaxshell.last_received = timestamp
514 self.server_version = Hoaxshell.server_version
515 self.sys_version = ""
516 session_id = self.headers.get(Hoaxshell.header_id)
517 legit = True if session_id == Hoaxshell.SESSIONID else False
518
519 # cmd output
520 if self.path == f'/{Hoaxshell.post_res}' and legit and Hoaxshell.execution_verified:
521
522 try:
523 self.send_response(200)
524 self.send_header('Access-Control-Allow-Origin', '*')
525 self.send_header('Content-Type', 'text/plain')
526 self.end_headers()
527 self.wfile.write(b'OK')
528 content_len = int(self.headers.get('Content-Length'))
529 output = self.rfile.read(content_len)
530 output = Hoaxshell.cmd_output_interpreter(self, output, constraint_mode = args.constraint_mode)
531
532 if output:
533 print(f'\r{GREEN}{output}{END}')
534
535
536 except ConnectionResetError:
537 print(f'[{FAILED}] There was an error reading the response, most likely because of the size (Content-Length: {self.headers.get("Content-Length")}). Try redirecting the command\'s output to a file and transfering it to your machine.')
538
539 rst_prompt(prompt = prompt)
540 Hoaxshell.prompt_ready = True
541
542 else:
543 self.send_response(200)
544 self.end_headers()
545 self.wfile.write(b'Move on mate.')
546 pass
547
548
549

Callers

nothing calls this directly

Calls 2

rst_promptFunction · 0.70

Tested by

no test coverage detected