Need urgent!help with Writing Resource (API), not Project Resource. - Burhan.Raxa - Apr 14, 2012
Hello HF.
I already searched the forum, I did use google as well.
I'm learning about crypter's coded in vb.net.
I'm currently experimenting on this crypter called "1 Scantime Crypter".
All I want to know, how to write the output Data into Resource?
here is the code I got from the very same forum, I'm not sure but I guess it belongs to "Deathader"
and below it is the crypter code.
my only question, how to write data into resources?
any kind of help will be greatly appreciated 🙂
Resource API:
Imports System.Runtime.InteropServices
Module ResourceWriter
Private Function ToPtr(ByVal data As Object) As IntPtr
Dim h As GCHandle = GCHandle.Alloc(data, GCHandleType.Pinned)
Dim ptr As IntPtr
Try
ptr = h.AddrOfPinnedObject()
Finally
h.Free()
End Try
Return ptr
End Function
<DllImport("kernel32.dll", SetLastError:=True)>
Private Function UpdateResource(ByVal hUpdate As IntPtr, ByVal lpType As String, ByVal lpName As String, ByVal wLanguage As UShort, ByVal lpData As IntPtr, ByVal cbData As UInteger) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)>
Private Function BeginUpdateResource(ByVal pFileName As String, <MarshalAs(UnmanagedType.Bool)> ByVal bDeleteExistingResources As Boolean) As IntPtr
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Function EndUpdateResource(ByVal hUpdate As IntPtr, ByVal fDiscard As Boolean) As Boolean
End Function
Public Function WriteResource(ByVal filename As String, ByVal bytes As Byte()) As Boolean
Try
Dim handle As IntPtr = BeginUpdateResource(filename, False)
Dim file1 As Byte() = bytes
Dim fileptr As IntPtr = ToPtr(file1)
Dim res As Boolean = UpdateResource(handle, "RCDATA", "1", 0, fileptr, Convert.ToUInt32(file1.Length))
EndUpdateResource(handle, False)
Catch ex As Exception
Return False
End Try
Return True
End Function
End Module
Crypter :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim filein, filename, stub As String
Dim sfd As New SaveFileDialog
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
filename = sfd.FileName
Else : Exit Sub
End If
FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
filein = Space(LOF(1))
FileGet(1, filein)
FileClose(1)
FileOpen(1, Application.StartupPath & "\Stub.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
stub = Space(LOF(1))
FileGet(1, stub)
FileClose(1)
FileOpen(1, filename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(1, stub & filesplit & rc4(filein, "MyBigAssDrunkenPassword"))
FileClose(1)
MsgBox("Crypted")
Me.Close()
End Sub
|