Skip to content

fix session-id lookup when sessions.list uses int keys - #11

Merged
setuidloot merged 8 commits into
mainfrom
fix/session-id-key-normalization
Apr 21, 2026
Merged

setuidloot merged 8 commits into
mainfrom
fix/session-id-key-normalization

Conversation

@setuidloot

Copy link
Copy Markdown
Owner

Summary

  • normalize client.sessions.list keys to strings before session existence checks
  • update send/post/terminate code paths to use normalized session maps
  • add regression coverage for int-keyed session IDs in session locking tests

Test plan

  • python3 -m pytest tests/test_session_locking.py -q
  • run an end-to-end exploit + send_session_command in container to confirm behavior in live RPC

Made with Cursor

pymetasploit3 returns sessions.list with integer keys, which caused string-based session lookups to fail and falsely report live sessions as missing. Normalize session keys once and add regression coverage for send/terminate flows.

Made-with: Cursor
Handle a pymetasploit3 regression where SessionManager.session() raises KeyError for live sessions by falling back to _create_session using normalized string-key maps. Add regression coverage so session command and termination flows remain stable.

Made-with: Cursor
Rename tool arguments to canonical msfconsole-style names across module, payload, search, format, and listener bind options so schemas and runtime behavior stay consistent for agents. This removes naming drift and keeps payload compatibility guidance keyed to the current API surface.

Made-with: Cursor
Replace run_with_output-based meterpreter execution with a prompt-aware read loop and add a caller-controlled inactivity timeout alongside the existing hard timeout cap. This reduces spurious timeouts for short interactive commands while preserving partial output and clearer completion reasons for callers.

Made-with: Cursor
Add GitHub Actions for pull request test validation and automated semantic version bumps on main so releases stay consistent without manual edits. Include a tested bump utility to keep version updates deterministic and auditable.

Made-with: Cursor
Scope the required GitHub Action check to the maintained timeout and locking suites plus the new version bump tests so PR gating stays reliable while broader legacy tests are still being reconciled.

Made-with: Cursor
Preserve shell-mode state after `shell` so subsequent commands use shell prompt/inactivity handling instead of meterpreter command parsing. Also include regression fixes for payload staging metadata, exploit job error surfacing, and hidden internal timeout params in inspect signatures.

Made-with: Cursor
Apply inactivity-timeout signature filtering against the underlying callable when tools are wrapped, preventing import-time TypeError on newer FastMCP/pytest stacks.

Made-with: Cursor
@setuidloot
setuidloot merged commit 00a11e7 into main Apr 21, 2026
1 check passed
setuidloot pushed a commit that referenced this pull request Apr 29, 2026
fix session-id lookup when sessions.list uses int keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant