Skip to content

Commit c25c5f6

Browse files
committed
Make linux gather post modules compatible with meterpreter
1 parent 4eeab66 commit c25c5f6

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

lib/msf/core/post/common.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ def cmd_exec(cmd, args=nil, time_out=15)
104104
end
105105

106106
session.response_timeout = time_out
107+
p "[*] executing #{cmd}"
107108
process = session.sys.process.execute(cmd, args, {'Hidden' => true, 'Channelized' => true})
108109
o = ""
109110
while (d = process.channel.read)
111+
p "[*] reading channel #{d}"
110112
break if d == ""
111113
o << d
112114
end
115+
o.chomp! if o
113116
process.channel.close
114117
process.close
115118
when /shell/

modules/post/linux/gather/enum_configs.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def initialize(info={})
2323
[
2424
'ohdae <bindshell[at]live.com>',
2525
],
26-
'Platform' => [ 'linux' ],
27-
'SessionTypes' => [ 'shell' ]
26+
'Platform' => ['linux'],
27+
'SessionTypes' => ['shell', 'meterpreter']
2828
))
2929
end
3030

@@ -74,7 +74,7 @@ def find_configs
7474

7575
configs.each do |f|
7676
output = read_file("#{f}")
77-
save(f, output) if output !~ /No such file or directory/
77+
save(f, output) if output && output !~ /No such file or directory/
7878
end
7979
end
8080
end

modules/post/linux/gather/enum_network.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def initialize(info={})
2626
'ohdae <bindshell[at]live.com>', # minor additions, modifications & testing
2727
'Stephen Haywood <averagesecurityguy[at]gmail.com>', # enum_linux
2828
],
29-
'Platform' => [ 'linux' ],
30-
'SessionTypes' => [ 'shell' ]
29+
'Platform' => ['linux'],
30+
'SessionTypes' => ['shell', 'meterpreter']
3131
))
3232
end
3333

modules/post/linux/gather/enum_protections.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def initialize(info={})
2828
[
2929
'ohdae <bindshell[at]live.com>'
3030
],
31-
'Platform' => [ 'linux' ],
32-
'SessionTypes' => [ 'shell' ]
31+
'Platform' => ['linux'],
32+
'SessionTypes' => ['shell']
3333
))
3434
end
3535

@@ -58,7 +58,11 @@ def get_host
5858
end
5959

6060
def which(env_paths, cmd)
61+
print_status("#{env_paths}")
62+
print_status("#{cmd}")
6163
for path in env_paths
64+
output = cmd_exec("/bin/ls #{path} | /bin/grep '#{cmd}'")
65+
print_status(output)
6266
if "#{cmd}" == cmd_exec("/bin/ls #{path} | /bin/grep '#{cmd}'")
6367
return "#{path}/#{cmd}"
6468
end
@@ -74,6 +78,12 @@ def find_apps
7478
"psad", "wireshark", "nagios", "nagios", "apparmor", "honeyd", "thpot"
7579
]
7680

81+
#output = cmd_exec("echo $PATH")
82+
#print_status("#{Rex::Text.to_hex_dump(output)}")
83+
#print_status("#{Rex::Text.to_hex_dump(output.chomp)}")
84+
85+
#return
86+
7787
env_paths = cmd_exec("echo $PATH").split(":")
7888

7989
apps.each do |a|

modules/post/linux/gather/enum_system.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def initialize(info={})
2929
'ohdae <bindshell[at]live.com>', # Combined separate mods, modifications and testing
3030
'Roberto Espreto <robertoespreto[at]gmail.com>', # log files and setuid/setgid
3131
],
32-
'Platform' => [ 'linux' ],
33-
'SessionTypes' => [ 'shell' ]
32+
'Platform' => ['linux'],
33+
'SessionTypes' => ['shell', 'meterpreter']
3434
))
3535

3636
end

modules/post/linux/gather/enum_users_history.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def initialize(info={})
2626
# based largely on get_bash_history function by Stephen Haywood
2727
'ohdae <bindshell[at]live.com>'
2828
],
29-
'Platform' => [ 'linux' ],
30-
'SessionTypes' => [ 'shell' ]
29+
'Platform' => ['linux'],
30+
'SessionTypes' => ['shell', 'meterpreter']
3131
))
3232

3333
end
@@ -123,14 +123,14 @@ def get_sql_history(users, user)
123123
else
124124
vprint_status("Extracting SQL history for #{user}")
125125
sql_hist = cat_file("/home/#{user}/.mysql_history")
126-
vprint_status(sql_hist)
127-
save("SQL History for #{user}", sql_hist) unless sql_hist =~ /No such file or directory/
126+
vprint_status(sql_hist) if sql_hist
127+
save("SQL History for #{user}", sql_hist) unless sql_hist && sql_hist =~ /No such file or directory/
128128
end
129129
end
130130

131131
def get_vim_history(users, user)
132132
if user == "root" and users != nil
133-
users = users.chomp.split()
133+
users = users.chomp.split
134134
users.each do |u|
135135
if u == "root"
136136
vprint_status("Extracting VIM history for #{u}")

0 commit comments

Comments
 (0)