Skip to content

Instantly share code, notes, and snippets.

@NaxAlpha
Last active March 9, 2016 16:13
Show Gist options
  • Save NaxAlpha/2c84b3fc77578bcd7ee9 to your computer and use it in GitHub Desktop.
Save NaxAlpha/2c84b3fc77578bcd7ee9 to your computer and use it in GitHub Desktop.
Portable Shellcode
;Suppose our code will be located at
;Following address in memory
org 0xDEADBEEF
mov eax, Sleep ;Sleep means [0xDEADBEEF+Sleep]
push Time ;Time means [0xDEADBEEF+Time]
call eax
Sleep dw 0x74c37990
Time dw 1000
;This shellcode is independent of its origin
bits 32
call Here ;Issue a near call
Here: ;Now EIP will be in stack
pop edi ;Store it to data register (data index)
sub edi,5 ;Point edi to base of shellcode
;Load sleep value in eax
mov eax,[edi+Sleep]
;Load value of Time in ebx
mov ebx,[edi+Time]
;Call Sleep
push ebx
call eax
;Data
Sleep dq 0x74c37990
Time dq 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment