Skip to content

Instantly share code, notes, and snippets.

@flbuddymooreiv
Last active August 29, 2015 14:23
Show Gist options
  • Save flbuddymooreiv/69f94201992471374a04 to your computer and use it in GitHub Desktop.
Save flbuddymooreiv/69f94201992471374a04 to your computer and use it in GitHub Desktop.
Create a Hello World Binary in a single line in bash

Run this command in a shell (bash is what has been tested), and you will get a 64-bit ELF binary that prints Hello World.

printf '\x7F\x45\x4C\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00\x01\x00\x00\x00\x35\x40\xB3\x04\x2C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x34\x00\x20\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x40\xB3\x04\xB2\x0C\xEB\x1C\x62\x00\x00\x00\x62\x00\x00\x00\x05\x00\x00\x00\x00\x10\x00\x00\x48\x65\x6C\x6C\x6F\x20\x77\x6F\x72\x6C\x64\x0A\xB9\x4C\x40\xB3\x04\x93\xCD\x80\xEB\xFB' > z && chmod +x z && ./z

Compare the size of this file to a simple hello world C program. This program only makes a system call and does not link against any libraries.

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