Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [bits 64]
- section .text
- global _start
- org 0x08048000
- ehdr: ; Elf64_Ehdr
- db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; times 8 db 0
- ; We can replace ^ this with the following for a code cave inside the elf header itself
- _start:
- mov al, 60
- xor rdi, rdi
- syscall
- db 0 ; the code in the cave is 7 bytes long, so we need one byte of padding
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- dw 2 ; e_type
- dw 62 ; e_machine
- dd 1 ; e_version
- dq _start ; e_entry
- dq phdr - $$ ; e_phoff
- dq 0 ; e_shoff
- dd 0 ; e_flags
- dw ehdrsize ; e_ehsize
- dw phdrsize ; e_phentsize
- dw 1 ; e_phnum
- dw 0 ; e_shentsize
- dw 0 ; e_shnum
- dw 0 ; e_shstrndx
- ehdrsize equ $ - ehdr
- phdr: ; Elf64_Phdr
- dd 1 ; p_type
- dd 7 ; p_flags
- dq 0 ; p_offset
- dq $$ ; p_vaddr
- dq $$ ; p_paddr
- dq filesize ; p_filesz
- dq filesize ; p_memsz
- dq 0x1000 ; p_align
- phdrsize equ $ - phdr
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- filesize equ $ - $$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement