![]() |
|
[C#] Adding resources to a compiled binary with Mono.Cecil - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Adding resources to a compiled binary with Mono.Cecil (/showthread.php?tid=3833995) |
Adding resources to a compiled binary with Mono.Cecil - Deliriumâ„¢ - Oct 29, 2013 Heya C# folks. I wrote this snippet to help people who are interested in Mono.Cecil or generally in C# learn how to add resources to a compiled binary or generally an existing .NET executable. Of course, in order to use the following code, you need to have referenced Mono.Cecil.dll in your project and add using Mono.Cecil; on top of it. The code is the following: Add the following statements on top of your source file: Code using Mono.Cecil;Then within a class in the same source file, add the following: Code public static string CreateResourceFile(byte[] FileData)Example Usage: Code string ResourceFile = CreateResourceFile(File.ReadAllBytes("C:/Users/Coder/Desktop/ImageExample.jpg"));Deleting the generated resource file should be done in case you don't want it anymore or you're using the above code to inject resources on a crypter's (or generally any) stub. Also note, that I wrote an overload method which supports adding multiple resources! Using it should be easy, just follow the example above and instead of a byte[] parameter, pass a List<byte[]> parameter to it. Enjoy. * - Only3 - Oct 30, 2013 u can put it in 1 Code public static void AddResourceFile(string Target, byte[] FileData, string ResName)* - Deliriumâ„¢ - Oct 30, 2013 (Oct 30, 2013 01:49 PM)Only3 Wrote: u can put it in 1 I know, I just made the code cleaner. * - .Death - Oct 31, 2013 you can even use reflection to make it support obfuscated assemblies. mono crashes quite often * - Lugus - Oct 31, 2013 Thank you for the tutorial mate. In fact I have a question for you and I apologize if it was a bit offensive. I need to know if there is an actual use of this snippet, I mean why would you inject a random resource into a random binary unless the last one has a method that will use the injected resource and if that's the case, couldn't you just add the needed resources in the solution explorer it would a lot easier this way. Thank you for understanding. * - Only3 - Oct 31, 2013 u can use it in many ways if u can use ur brain * - Deliriumâ„¢ - Oct 31, 2013 (Oct 31, 2013 11:26 AM)Lugus Wrote: Thank you for the tutorial mate. In fact I have a question for you and I apologize if it was a bit offensive. You can use it in crypters if you're deploying them with a precompiled stub. You can use it in other forms of programs that require stubs with variable resources. |