简体   繁体   中英

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 an open-source RAT/payload dropper as a project to learn Golang 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?

No, there is no portable way to do this.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM