Skip to content

Conversation

@jheysel-r7
Copy link
Contributor

This first part of #enum_user_directories parses /etc/passwd and adds for example /home/msfuser to the user_dirs array.

    passwd = '/etc/passwd'
    if file_exist?(passwd)
      read_file(passwd).each_line do |passwd_line|
        user_dirs << passwd_line.split(':')[5]
      end
    end

The second part #enum_user_directories runs the cmd_exec command below and adds for example/home/msfuser\n to the user_dirs array. Every directory contains a new line at the end of the string except for the last entry, which is why we've added .chomp so that the duplicate entries will now get removed by the .uniq call at the end of the method.

user_dirs << cmd_exec('ls /home').each_line.map { |l| "/home/#{l.chomp}" }

Verification

Test this in isolation or run a post module such as the new ssh_key persistence module which calls #enum_user_directories to see how it was evaluating some home directories twice before this fix. Note this wasn't causing issues but figured it should be corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant