Skip to content

Instantly share code, notes, and snippets.

@thebsdbox
Created February 22, 2017 10:58
Show Gist options
  • Save thebsdbox/29e395299f89b52214b66269f5b33f7d to your computer and use it in GitHub Desktop.
Save thebsdbox/29e395299f89b52214b66269f5b33f7d to your computer and use it in GitHub Desktop.
Hello Docker World in 69 bytes
BITS 32
org 0x05000000
db 0x7F, "ELF"
dd 1
dd 0
dd $$
dw 2
dw 3
dd 0x0500001B
dd 0x0500001B
dd 4
mov dl, 19
mov ecx, msg
int 0x80
db 0x25
dw 0x20
dw 0x01
inc eax
int 0x80
msg db 'Hello Docker world!', 10
---------------
$ nasm -f bin -o hello <above_asm>.asm
$ chmod +x hello
$ ./hello
@thebsdbox
Copy link
Author

Lines 3 - 12 are a static ELF header format, which identifies it to the OS as a binary it understands. Lines 13-15 point to the data and perform a sys call to write to stdout. Lines 19-20 set the exit function and call it.

@pcaro
Copy link

pcaro commented Feb 22, 2017

So great!

@StefanScherer
Copy link

Fantastic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment