Skip to content

Conversation

0xGrooted
Copy link

Hey there,
My code replaces the deprecated, manual file handling logic within cmd_edit with the robust, high-level client.fs.file.edit(path) utility.

The manual logic was flawed because the remote file was removed immediately when the handler attempted to open it to read its contents, causing complete data loss if the local editor crashed or the session was interrupted before re-upload.

The fix ensures the edit command now follows the atomic procedure:

  • Safely downloads the remote file to a local temporary file.
  • Launches the local editor ($EDITOR).
  • Uploads the file back to the remote host (overwriting the original) only upon successful exit from the editor.

This (hopefully) Fixes #20574.

@0xGrooted
Copy link
Author

please see comment this should be completed now! Let me know if it needs any more changes.

@0xGrooted 0xGrooted closed this Oct 5, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Metasploit Kanban Oct 5, 2025
@0xGrooted 0xGrooted reopened this Oct 5, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Metasploit Kanban Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

meterpreter edit truncates file before editing (data loss) — Metasploit 6.4.91-dev (apt)
2 participants