Closed fullfill13 closed 5 months ago
This is not supported. However, there's project called exe_to_dll that might work.
Thanks, but the converted dll file doesn't work!
Building agent as shared library is possible in Windows, I will implement it if I have time to work on it.
Maybe I can merge main_windows.go and buildAgent.go into a C.go file , and compile it as a dll file, but that's too difficult
The biggest issue here is cross-building agent as DLL on Linux is quite impossible, perhaps it's an issue with Go itself (and the error is hard to debug).
My plan is to build a DLL stub (just like the exe), and add an option in gen_agent
so it can be configured for use.
Maybe you can build the DLL on Windows with this command:
CGO_ENABLED=1 go build -buildmode=c-shared cmd/agent
And in main_windows.go
, export the main
function:
import "C"
//export main
func main() {}
This should work.
i can generate main_windows and main_windows.h ,but not dll. May need to keep compiling? https://merlin-c2.readthedocs.io/en/latest/agent/dll.html
and the dll is a DLL stub , Will buildAgent.go work with this stub?
i can generate main_windows and main_windows.h ,but not dll. May need to keep compiling? https://merlin-c2.readthedocs.io/en/latest/agent/dll.html
It's merlin-c2, which uses a very different approach to generate DLL. It won't work here. Have you tested the method I just posted?
and the dll is a DLL stub , Will buildAgent.go work with this stub?
Yes it will.
I generated the stub dll file, but the last generated is still an exe, which is generated by buildAgent.go, I simply changed the suffix to dll, but then there is no export function, how do I start the dll?
the stub dll has main export, but the final file does not have it
I simply changed the suffix to dll
Executable and shared library are two different things, changing file names don't change the file.
the stub dll has main export, but the final file does not have it
Why would it have exported functions? It's still an exe.
Right now the whole thing is being experimented on, it's not implemented so you won't be able to use emp3r0r to generate any DLLs.
Can you just wait until this feature is implemented?
Of course, and I'm going to try it
Now the DLL seems to be working, I will test it further and fix the bugs.
Why is the export function missing after the buildagent.go function reads the stub data, replaces some of the data and rewrites it?
It's not done yet. Right now I can only say the DLL file is working, agent configuration is not.
Currently only able to generate windows agent in exe format, is it possible to add functionality?