@@ -154,37 +154,43 @@ def set_desktop( session=-1, station='WinSta0', name='Default', switch=false )
154
154
def screenshot ( quality = 50 )
155
155
request = Packet . create_request ( 'stdapi_ui_desktop_screenshot' )
156
156
request . add_tlv ( TLV_TYPE_DESKTOP_SCREENSHOT_QUALITY , quality )
157
+
157
158
# include the x64 screenshot dll if the host OS is x64
158
159
if ( client . sys . config . sysinfo [ 'Architecture' ] =~ /^\S *x64\S */ )
159
160
screenshot_path = MeterpreterBinaries . path ( 'screenshot' , 'x64.dll' )
160
161
if screenshot_path . nil?
161
162
raise RuntimeError , "screenshot.x64.dll not found" , caller
162
163
end
163
- screenshot_path = :: File . expand_path ( screenshot_path )
164
+
164
165
screenshot_dll = ''
165
166
::File . open ( screenshot_path , 'rb' ) do |f |
166
167
screenshot_dll += f . read ( f . stat . size )
167
168
end
169
+
168
170
request . add_tlv ( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_BUFFER , screenshot_dll , false , true )
169
171
request . add_tlv ( TLV_TYPE_DESKTOP_SCREENSHOT_PE64DLL_LENGTH , screenshot_dll . length )
170
172
end
173
+
171
174
# but always include the x86 screenshot dll as we can use it for wow64 processes if we are on x64
172
175
screenshot_path = MeterpreterBinaries . path ( 'screenshot' , 'x86.dll' )
173
176
if screenshot_path . nil?
174
177
raise RuntimeError , "screenshot.x86.dll not found" , caller
175
178
end
176
- screenshot_path = :: File . expand_path ( screenshot_path )
179
+
177
180
screenshot_dll = ''
178
181
::File . open ( screenshot_path , 'rb' ) do |f |
179
182
screenshot_dll += f . read ( f . stat . size )
180
183
end
184
+
181
185
request . add_tlv ( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_BUFFER , screenshot_dll , false , true )
182
186
request . add_tlv ( TLV_TYPE_DESKTOP_SCREENSHOT_PE32DLL_LENGTH , screenshot_dll . length )
187
+
183
188
# send the request and return the jpeg image if successfull.
184
189
response = client . send_request ( request )
185
190
if ( response . result == 0 )
186
191
return response . get_tlv_value ( TLV_TYPE_DESKTOP_SCREENSHOT )
187
192
end
193
+
188
194
return nil
189
195
end
190
196
0 commit comments