简体   繁体   English

Golang 从 memory 中的二进制数据执行子进程

[英]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?我知道可以将可执行文件嵌入到 Golang 可执行文件中并运行它们,或者使用 Yaegi 等项目从字符串运行Golang代码,但是作为一个孩子,是否可以运行存储为变量的二进制文件而不将其写入文件过程? The binary is already in memory as a variable so is it possible to just execute it somehow?二进制文件已经作为变量存在于 memory 中,所以可以以某种方式执行它吗?

If I'm not mistaken there is a difference between executable memory and data memory so would that prevent this from being done?如果我没记错的话,可执行 memory 和数据 memory 之间存在差异,那么这会阻止这样做吗?

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.我的问题的原因是我正在编写一个开源 RAT/payload dropper 作为学习 Golang 的项目,并希望尽可能模块化,包括无文件更新和二进制(也是无文件)有效负载.

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++. EDIT2:根据这个SO 答案,这在 C++ 中是不可能的/非常困难的。 Seemingly, the main reason for this is dynamically linking libraries.看起来,这样做的主要原因是动态链接库。 As Golang is statically linked, would this be any easier?由于 Golang 是静态链接的,这会更容易吗?

No, there is no portable way to do this.不,没有便携的方法可以做到这一点。

Yes, try this way to do this.是的,尝试这种方式来做到这一点。 https://github.com/amenzhinsky/go-memexec https://github.com/amenzhinsky/go-memexec

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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