MCPcopy Create free account
hub / github.com/sqlmapproject/sqlmap / _controlMsfCmd

Method _controlMsfCmd

lib/takeover/metasploit.py:490–581  ·  view source on GitHub ↗
(self, proc, func)

Source from the content-addressed store, hash-verified

488 send_all(proc, "getuid\n")
489
490 def _controlMsfCmd(self, proc, func):
491 initialized = False
492 start_time = time.time()
493 stdin_fd = sys.stdin.fileno()
494
495 while True:
496 returncode = proc.poll()
497
498 if returncode is None:
499 # Child hasn't exited yet
500 pass
501 else:
502 logger.debug("connection closed properly")
503 return returncode
504
505 try:
506 if IS_WIN:
507 timeout = 3
508
509 inp = b""
510 _ = time.time()
511
512 while True:
513 if msvcrt.kbhit():
514 char = msvcrt.getche()
515
516 if ord(char) == 13: # enter_key
517 break
518 elif ord(char) >= 32: # space_char
519 inp += char
520
521 if len(inp) == 0 and (time.time() - _) > timeout:
522 break
523
524 if len(inp) > 0:
525 try:
526 send_all(proc, inp)
527 except (EOFError, IOError):
528 # Probably the child has exited
529 pass
530 else:
531 ready_fds = select.select([stdin_fd], [], [], 1)
532
533 if stdin_fd in ready_fds[0]:
534 try:
535 send_all(proc, blockingReadFromFD(stdin_fd))
536 except (EOFError, IOError):
537 # Probably the child has exited
538 pass
539
540 out = recv_some(proc, t=.1, e=0)
541 blockingWriteToFD(sys.stdout.fileno(), getBytes(out))
542
543 # For --os-pwn and --os-bof
544 pwnBofCond = self.connectionStr.startswith("reverse")
545 pwnBofCond &= any(_ in out for _ in (b"Starting the payload handler", b"Started reverse"))
546
547 # For --os-smbrelay

Callers 3

pwnMethod · 0.95
smbMethod · 0.95
bofMethod · 0.95

Calls 12

_loadMetExtensionsMethod · 0.95
send_allFunction · 0.90
blockingReadFromFDFunction · 0.90
recv_someFunction · 0.90
blockingWriteToFDFunction · 0.90
getBytesFunction · 0.90
filenoMethod · 0.80
debugMethod · 0.80
isOsMethod · 0.80
selectMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected