Last active
June 23, 2021 01:10
-
-
Save netspooky/152701763e481ecf3c971bcf7f561345 to your computer and use it in GitHub Desktop.
For writeup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BITS 64 | |
org 0x100000000 ; Where to load this into memory | |
;----------------------+------+-------------+----------+------------------------ | |
; ELF Header struct | OFFS | ELFHDR | PHDR | ASSEMBLY OUTPUT | |
;----------------------+------+-------------+----------+------------------------ | |
db 0x7F, "ELF" ; 0x00 | e_ident | | 7f 45 4c 46 | |
_start: mov al,0x3c ; 0x04 | ei_class | | b0 | |
; 0x05 | ei_data | | 3c | |
xor rdi,rdi ; 0x06 | ei_version | | 48 31 ff | |
syscall ; 0x09 | u | | 0f 05 | |
nop ; 0x0b | n | | 90 | |
nop ; 0x0c | u | | 90 | |
nop ; 0x0d | s | | 90 | |
nop ; 0x0e | e | | 90 | |
nop ; 0x0f | d | | 90 | |
;----------------------+------+-------------+----------+------------------------ | |
; ELF Header struct ct.| OFFS | ELFHDR | PHDR | ASSEMBLY OUTPUT | |
;----------------------+------+-------------+----------+------------------------ | |
dw 2 ; 0x10 | e_type | | 02 00 | |
dw 0x3e ; 0x12 | e_machine | | 3e 00 | |
dd 1 ; 0x14 | e_version | | 01 00 00 00 | |
dd _start - $$ ; 0x18 | e_entry | | 04 00 00 00 | |
;----------------------+------+-------------+----------+------------------------ | |
; Program Header Begin | OFFS | ELFHDR | PHDR | ASSEMBLY OUTPUT | |
;----------------------+------+-------------+----------+------------------------ | |
phdr: dd 1 ; 0x1C | ... | p_type | 01 00 00 00 | |
dd phdr - $$ ; 0x20 | e_phoff | p_flags | 1c 00 00 00 | |
dd 0 ; 0x24 | ... | p_offset | 00 00 00 00 | |
dd 0 ; 0x28 | e_shoff | ... | 00 00 00 00 | |
dq $$ ; 0x2C | ... | p_vaddr | 00 00 00 00 | |
; 0x30 | e_flags | ... | 01 00 00 00 | |
dw 0x40 ; 0x34 | e_shsize | p_addr | 40 00 | |
dw 0x38 ; 0x36 | e_phentsize | ... | 38 00 | |
dw 1 ; 0x38 | e_phnum | ... | 01 00 | |
dw 2 ; 0x3A | e_shentsize | ... | 02 00 | |
dq 2 ; 0x3C | e_shnum | p_filesz | 02 00 00 00 00 00 00 00 | |
dq 2 ; 0x44 | | p_memsz | 02 00 00 00 00 00 00 00 | |
dq 2 ; 0x4C | | p_align | 02 00 00 00 00 00 00 00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment