bytecode77 / self-morphing-csharp-binary

Executable that mutates its own code
https://bytecode77.com/self-morphing-csharp-binary
BSD 2-Clause "Simplified" License
368 stars 105 forks source link

[ QUESTIONβ€Ž ] β€” Hey @bytecode77, I have some doubts about this very interesting old project. πŸ’­ #4

Open fSociety-Protected opened 1 week ago

fSociety-Protected commented 1 week ago

Well, first of all... πŸ’­

I hope you are well and everything β€Ž β€Ž β€Ž is going great in your life! πŸ’•

Well, I've been keeping an eye on this project and I've got some interesting ideas! β€Ž β€Ž But... I also have some doubts that I hope you can help me to solve! πŸ’―

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

Well, in your web page, you say the following about the executable named β€œpayload.exe”: β€Ž β€œRemember, that the payload is a separate and replaceable executable file.” -bytecode77

Now, I have tried to simply replace the payload.exe file with another one, β€Ž β€Ž like for example the β€œ$77-Example.exe” file from your r77 project, but apparently, β€Ž β€Ž β€Ž β€Žβ€Ž when trying to run the auto-morphic launcher, β€œ$77-Example.exe” is never executed. πŸ€” β€Ž

Is there something I'm not understanding or β€Ž β€Ž β€Ž something should I need to know @bytecode77? πŸ˜“ β€Ž

Thanks for everything @bytecode77 and I hope you can β€Ž β€Ž β€Ž β€Ž get back to me when you have some free time, thanks! πŸ™ πŸ’•

bytecode77 commented 1 week ago

Hey there. This is just a PoC that demonstrates a C# executable that morphs its own code. It isn't in and of itself useful, so you can't swap out the Payload to "chain together" your own payload. It's merely a code demo.

Also, Payload.exe is a .NET payload, which I assume you replaced by a native payload.

fSociety-Protected commented 1 week ago

Hey there. This is just a PoC that demonstrates a C# executable that morphs its own code. It isn't in and of itself useful, so you can't swap out the Payload to "chain together" your own payload. It's merely a code demo.

Also, Payload.exe is a .NET payload, which I assume you replaced by a native payload.

γ…€ So... there is no way to do exactly the same thing, γ…€but importing a non-.NET binary? πŸ₯΄

I mean, instead of compressing/encrypting the code, γ…€just encrypt the payload.exe stored in the resources. πŸ€”

Because the truth would be a very good way to protect a project... γ…€I mean, if there was a way to use as an executable launcher, γ…€γ…€your automorphic project, it would be awesome! πŸ’―πŸ’―

bytecode77 commented 6 days ago

Nah... To protect a project from AV, use in-memory techniques. This is really just a PoC and can't be combined with unrelated techniques.

fSociety-Protected commented 6 days ago

Nah... To protect a project from AV, use in-memory techniques. This is really just a PoC and can't be combined with unrelated techniques. γ…€

γ…€ Wow, what a disappointment I just got Β«@byteΒ», because I've been all night, γ…€trying with all my strength to make such a loader come true. πŸ₯΄πŸ€¦β€β™‚️ γ…€ γ…€ As an automorphic loader, that would be able to carry a binary (an .EXE, but not ONLY .NET, any . EXE) γ…€as an embedded resource in encrypted form and that when running the automorphic launcher, decrypt the γ…€γ…€ resource in memory, execute the resource in memory using P/Invoke, re-encrypt the resource with a random γ…€γ…€γ…€ key and compile the whole launcher morphing and obfuscating all variables, strings, etc... as it already does... πŸ”Ž γ…€ γ…€ But if you say that's NOT possible... I guess I'm going to abandon my little project of being able to γ…€ create an automorphic launcher that can and will be able to host any binary executable as an embedded γ…€γ…€ resource and be able to decrypt it and run it in memory. 😞 γ…€ γ…€ For me you are a real inspiration @bytecode77, γ…€ seriously, for me you are the best. πŸ’•πŸ’― γ…€ γ…€ And if apparently, it's you, who tells me that this is not possible, γ…€...then I won't be the one to question it, really. πŸ˜“ γ…€

bytecode77 commented 6 days ago

If you're developing your own crypter and decided that it should be morphing, then you can implement that, sure. All I'm saying is that you cannot use this PoC as it is and swap out the Payload, as a PoC is generelly not designed to be used in-place as it is.

So, if you're working on your own crypter, then you can look at how polymorphism and morphing stubs work from my project, etc. and do your own implementation.

Keep going...

fSociety-Protected commented 6 days ago

If you're developing your own crypter and decided that it should be morphing, then you can implement that, sure. All I'm saying is that you cannot use this PoC as it is and swap out the Payload, as a PoC is generelly not designed to be used in-place as it is.

So, if you're working on your own crypter, then you can look at how polymorphism and morphing stubs work from my project, etc. and do your own implementation.

Keep going... γ…€

γ…€ So I'm not wasting my time? πŸ₯΄ γ…€Is it possible to do what I say? πŸ”Ž γ…€ γ…€ I mean, create a launcher which has as an embedded resource my own *.exe payload, native, not .NET γ…€and when running the launcher, in turn, decrypt the payload in memory and run the payload directly in γ…€γ…€memory to avoid any kind of footprint on the disk and then, after having run the payload, encrypt the resource γ…€γ…€γ…€with a new random key and use polyformism to mutate the launcher code and auto-compile itself? πŸ’­ γ…€ γ…€ Is it worth it? Is it possible to create something like that? πŸ€” γ…€I wouldn't want to go round in circles for nothing. πŸ˜“ γ…€ γ…€ Any advice @byte for choosing γ…€the best way or practice to follow? 🧐 γ…€

bytecode77 commented 6 days ago

Not sure what exactly you're up to. You can achieve a morphing binary, or any other type of obfuscation. AV isn't affected as much by the morphing of the binary as by the evasion techniques used.

fSociety-Protected commented 6 days ago

Not sure what exactly you're up to. You can achieve a morphing binary, or any other type of obfuscation. AV isn't affected as much by the morphing of the binary as by the evasion techniques used.

γ…€ What I am looking for is to create a launcher which can store in an encrypted way a *.EXE binary, γ…€which does not have to be a .NET binary and that when executing the launcher, let's call it β€˜LOADER.EXE’, γ…€γ…€this in turn, decrypts the embedded binary that is inside, let's call it, β€˜PAYLOAD.EXE’ and is executed directly γ…€γ…€γ…€in memory, without at any time is written to disk, to avoid leaving any trace or track. πŸ—’οΈπŸͺΆπŸ’­ γ…€

And at the end of the execution of β€˜PAYLOAD.EXE’, then, the launcher β€˜LOADER.EXE’, γ…€applies the automorphosis that you show in this project, encrypting with a new random γ…€γ…€key the embedded binary β€˜PAYLOAD.EXE’. πŸ€”πŸ§ γ…€

More than a technique to evade AV's, it would be extremely useful to protect γ…€my projects against reverse engineering techniques, debugging, etc... πŸ”Ž γ…€

I hope you now understand much γ…€better what I want to do @bytecode77. πŸ’―πŸ’•

bytecode77 commented 5 days ago

RunPE is the keyword for you, if you want to run a native executable in memory.

Good luck!

fSociety-Protected commented 5 days ago

RunPE is the keyword for you, if you want to run a native executable in memory.

Good luck!

Okay @bytecode77, thanks for the tip. πŸ™πŸ’•