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

Fix Meterpreter module tests on Windows host #16197

Merged

Conversation

adfoster-r7
Copy link
Contributor

Fixes an edge case when reading files on Windows, and fixes Ruby 3 crashes when reading files.

Windows fix

The file upload support of Meterpreter was broken on windows machines, which was doing additional EOL<->CRLF conversions on windows:

"b"  Binary file mode
     Suppresses EOL <-> CRLF conversion on Windows. And
     sets external encoding to ASCII-8BIT unless explicitly
     specified.

This meant the expected hashes didn't match

Verification

Open msfconsole on windows, and open a Python Meterpreter on windows:

use python/meterpreter_reverse_tcp
generate -o shell.py -f raw lhost=127.0.0.1
to_handler
python3 shell.py

Run the test:

loadpath test/modules
use test/meterpreter
run session=-1

Verify the md5/sha1 tests pass now

@sjanusz-r7
Copy link
Contributor

LGTM!

Before

msf6 post(test/meterpreter) > run session=-1

[*] Running against session -1
[*] Session type is meterpreter and platform is windows
[+] should enumerate supported core commands
[+] should support 3 or more core commands
[+] should return its own process id
[+] should return a list of processes
[+] should return a user id
[+] should return a sysinfo Hash
[+] should return network interfaces
[+] should have an interface that matches session_host
[+] should return network routes
[+] should return the proper directory separator
[+] should return the current working directory
[+] should list files in the current directory
[+] should stat a directory
[+] should create and remove a dir
[+] should change directories
[+] should create and remove files
[-] FAILED: should upload a file
[+] should move files
[+] should copy files
[-] FAILED: should do md5 and sha1 of files
[-] Passed: 18; Failed: 2
[*] Post module execution completed

After

msf6 post(test/meterpreter) > run session=-1

[*] Running against session -1
[*] Session type is meterpreter and platform is windows
[+] should return its own process id
[+] should return a list of processes
[+] should return a user id
[+] should return a sysinfo Hash
[+] should return network interfaces
[+] should have an interface that matches session_host
[+] should return network routes
[+] should return the proper directory separator
[+] should return the current working directory
[+] should list files in the current directory
[+] should stat a directory
[+] should create and remove a dir
[+] should change directories
[+] should create and remove files
[+] should upload a file
[+] should move files
[+] should copy files
[+] should do md5 and sha1 of files
[+] should enumerate supported core commands
[+] should support 3 or more core commands
[*] Passed: 20; Failed: 0
[*] Post module execution completed

@sjanusz-r7 sjanusz-r7 merged commit 7b7b5c6 into rapid7:master Feb 22, 2022
@sjanusz-r7
Copy link
Contributor

Release Notes

Fixes an edge case when reading files on Windows, and fixes Ruby 3 crashes when reading files.

@sjanusz-r7 sjanusz-r7 added the rn-fix release notes fix label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants