Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File.expand_path to fix no such file error #18623

Merged
merged 1 commit into from Dec 18, 2023

Conversation

gardnerapp
Copy link
Contributor

@gardnerapp gardnerapp commented Dec 15, 2023

With issue #18602 a "No such file or directory" error is given when using the -o flag to write the payload to a file. This change uses the FIle.expand_path function to allow for files to be written to the home path of the current user with the ~ character.

Verification

Running the -o option with a file path using ~ now works!

~/metasploit-framework msfconsole
msf6 > reload_all

msf6 > use payload/osx/armle/shell/reverse_tcp 
msf6 payload(osx/armle/shell/reverse_tcp) > set LHOST 10.255.104.146
LHOST => 10.255.104.146
msf6 payload(osx/armle/shell/reverse_tcp) > generate -o ~/payload_test
[*] Writing 1244 bytes to ~/payload_text...

# In a regular shell
$ ls ~/payload*
payload_test

Copy link
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old on the right, new on the left.

image

There's probably plenty more instances like this. Msfconsole doesn't claim to be a shell like bash or zsh which is what's typically responsible for this type of expansion.

@smcintyre-r7 smcintyre-r7 merged commit a4d6026 into rapid7:master Dec 18, 2023
36 checks passed
@smcintyre-r7
Copy link
Contributor

Release Notes

This updates the file handling of the generate command's -o parameter to expand file system paths.

@zgoldman-r7 zgoldman-r7 added the rn-enhancement release notes enhancement label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy enhancement rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants