Giter VIP home page Giter VIP logo

go-x64-executable's Introduction

ELF x86-64 Linux Executable by hand

Generate an ELF 64-bit executable by hand. This is an example of how to manually create an ELF 64 executable for linux that will print out some string and then exit using sys_write and sys_exit linus system calls.

It will generate the ELF header, then 2 Program Headers (one for the .text segment and one for the .data segment). Then the .text segment and .data segment are outputted to the binary.

The .text segment will do a sys_write using the data offset from where the .data segment is located and then it will do a sys_exit.

The .data segment contains just the string data.

This doesn't currently do back-patching. The data segment is always known since the ELF header and text segment aren't changing. This needs to be fixed, but I don't know a good way to do it.

$ go run main.go
wrote binary to tiny-x64
$ ./tiny-x64
Hello World, this is my tiny executable
$ ls -hal ./tiny-x64
-rwxr-xr-x 1 vishen vishen 257 Jun 21 08:58 ./tiny-x64*

# Or run with a desired string to output in the binary
$ go run main.go -output hello-world -word "Hello, World!"
wrote binary to hello-world
$ ./hello-world
Hello, World!
$ ls -hal ./hello-world
-rwxr-xr-x 1 vishen vishen 231 Jun 21 08:59 ./hello-world*

Resources

go-x64-executable's People

Contributors

vishen avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.