Support shell switch in meterpreter session

This commit is contained in:
DullJZ
2025-07-14 07:18:16 +00:00
parent c24a645195
commit 675b7f2f9b
+11 -4
View File
@@ -1076,10 +1076,17 @@ async def send_session_command(
logger.debug(f"Using session.run_with_output for Meterpreter session {session_id}")
try:
# Use asyncio.wait_for to handle timeout manually since run_with_output doesn't support timeout parameter
output = await asyncio.wait_for(
asyncio.to_thread(lambda: session.run_with_output(command)),
timeout=timeout_seconds
)
if command == "shell":
output = session.run_with_output(command, end_strs=['created.'])
session.read() # Clear buffer
elif command == "exit":
session.read() # Clear buffer
session.detach()
else:
output = await asyncio.wait_for(
asyncio.to_thread(lambda: session.run_with_output(command)),
timeout=timeout_seconds
)
status = "success"
message = "Meterpreter command executed successfully."
logger.debug(f"Meterpreter command '{command}' completed.")