user9123
user9123

Reputation: 601

Golang execute child process from binary data in memory

I know that it is possible to embed executables in Golang executables and run them, or run Golang code from a string using projects like Yaegi, but is it possible to run a binary stored as a variable without writing it to a file, as a child process? The binary is already in memory as a variable so is it possible to just execute it somehow?

If I'm not mistaken there is a difference between executable memory and data memory so would that prevent this from being done?

The reason for my question is that I'm writing a RAT/payload dropper as a project to learn Go(lang) and would like to make is as modular as possible, including file-less updates and binary (also file-less) payloads.

EDIT: Any solution is welcome, but cross-platform solutions are preferred.

EDIT2: According to this SO answer, this is not possible / very difficult in C++. Seemingly, the main reason for this is dynamically linking libraries. As Golang is statically linked, would this be any easier?

Upvotes: 5

Views: 3519

Answers (2)

opensource
opensource

Reputation: 748

Yes, try this way to do this. https://github.com/amenzhinsky/go-memexec

Upvotes: 1

Volker
Volker

Reputation: 42413

No, there is no portable way to do this.

Upvotes: 1

Related Questions