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 support for shell sessions to post/windows/gather/enum_hostfile #12585

Merged
merged 1 commit into from Nov 18, 2019

Conversation

@bcoles
Copy link
Contributor

bcoles commented Nov 16, 2019

The post/windows/gather/enum_hostfile module declares:

'SessionTypes'  => [ 'meterpreter', 'shell' ]

This is a blatant lie, as the module uses session.fs.file.new.

This PR updates the module to support both meterpreter and shell sessions by using the read_file method from the Msf::Post::File mixin.

This method checks the session.type and uses the appropriate session.fs.file.new method for meterpreter sessions if available.

  def read_file(file_name)
    if session.type == 'meterpreter'
      return _read_file_meterpreter(file_name)
    end

    return nil unless session.type == 'shell'

    if session.platform == 'windows'
      return session.shell_command_token("type \"#{file_name}\"")
    end

The enum_hostfile module should probably also nil check the result, but whatever.

@busterb busterb self-assigned this Nov 18, 2019
@busterb

This comment has been minimized.

Copy link
Member

busterb commented Nov 18, 2019

Exactly, thanks @bcoles

busterb added a commit that referenced this pull request Nov 18, 2019
@busterb busterb merged commit f5fbdca into rapid7:master Nov 18, 2019
3 checks passed
3 checks passed
Metasploit Automation - Sanity Test Execution Successfully completed all tests.
Details
Metasploit Automation - Test Execution Successfully completed all tests.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@busterb

This comment has been minimized.

Copy link
Member

busterb commented Nov 18, 2019

Release Notes

This corrects the windows/gather/enum_hostfile module to use the post-exploitation API to work with Meterpreter and shell session types.

msjenkins-r7 added a commit that referenced this pull request Nov 18, 2019
@bcoles bcoles deleted the bcoles:enum_hostfile branch Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.