; rot13.asm ; compile with nasm -f bin -o rot13 rot13.asm ; ; Note: I've managed down to 103 bytes, with random segfaults, due to ; the slightly insane values some parts of the ELF header get, ; causing it to be hyper-sensitive to the amount of free memory. ; ; Note2: This code requires an ELF capable system to run, and it also ; horribly breaks the ELF standard, which may cause some problems. ; It *should* work on Linux-2.x.y. BITS 32 org 0x08048000 ehdr: ; Elf32_Ehdr db 0x7F, "ELF", 1 ; e_ident _start: xor dl, dl inc dl mov ecx, esp jmp read dw 2 ; e_type dw 3 ; e_machine dd 1 ; e_version dd _start ; e_entry dd phdr - $$ ; e_phoff exit: mov al, byte 1 xor bl, bl int 0x80 db 0,0 dw ehdrsize ; e_ehsize dw phdrsize ; e_phentsize phdr: dw 1 ; e_phnum p_type times 6 db 0 ehdrsize equ $ - ehdr dd $$ ; p_vaddr dd $$ ; p_paddr dd filesize ; p_filesz dd filesize ; p_memsz db 4 ; times 7 db 0 phdrsize equ $ - phdr read: mov al, byte 3 xor bl, bl ; phdrsize equ $ - phdr int 0x80 cmp al, byte 0 je exit mov al, [esp] and al, byte 95 cmp al, byte 65 jl write cmp al, byte 90 jg write cmp al, byte 77 jg dec13 inc13: add [esp], byte 26 dec13: add [esp], byte -13 write: mov al, byte 4 inc bl int 0x80 jmp read filesize equ $ - $$