98byte ELF executable
Posted: Sun Nov 17, 2024 11:17 am
A whole executable program, in 98bytes, hows that happen?
Code: Select all
❯ hexdump -C a.out
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 50 80 04 08 34 00 00 00 |........P...4...|
00000020 00 00 00 00 00 00 00 00 34 00 20 00 01 00 00 00 |........4. .....|
00000030 00 00 00 00 01 00 00 00 00 00 00 00 00 80 04 08 |................|
00000040 00 80 04 08 62 00 00 00 62 00 00 00 05 00 00 00 |....b...b.......|
00000050 b0 04 b3 01 8d 0d 60 80 04 08 b2 02 cd 80 eb f0 |......`.........|
00000060 3a 33 |:3|
00000062
^ thats how
and it aint a lame exit 0 either, nah it actually does stuff
Code: Select all
:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3:3
^ very :3
Heres the source code
Code: Select all
BITS 32
org 0x08048000
ehdr:
db 0x7f, "ELF"
db 1, 1, 1, 0
times 8 db 0
dw 2
dw 3
dd 1
dd _start
dd phdr - $$
dd 0
dd 0
dw 52
dw 32
dw 1
dw 0
dw 0
dw 0
phdr:
dd 1
dd 0
dd $$
dd $$
dd _end - $$
dd _end - $$
dd 5
_start:
mov al, 4
mov bl, 1
lea ecx, [msg]
mov dl, 2
int 0x80
jmp _start
msg: db ":3"
_end:
thanks to @GAIA for the idea of using smaller registers :3
feel free to make any optimizations or ur own version in the replies