Cara membuat Injector DLL dengan Visual Basic 6.0
Halo! bersama lagi bersama saya :)
Pada pelajaran hari ini saya akan membuat aplikasi Injector DLL dengan program Visual Basic 6.0
Bahan yang di butuhkan untuk membuat adalah :
Visual Studio 6.0 Professional Edition [ Download ] / Enterpize Edition [ Download ]
Langsung saja ke TKP! hehehe...
1. Pertama buka VB 6.0
2. Setelah membuka VB 6.0-nya, lalu pilih Standard EXE, klik Open
3. Pada Form1, pilih BorderStyle : 0 - None, di bagian Properties
4. Pada Caption, terserah anda, misalnya Trainer CS 1.6 By SamFX
5. Pada Icon, cari sendiri icon yang anda miliki
6. Pada ShowInTaskbar, pilih True
7. Pada StartUpPosition, pilih 3 - CenterScreen
8. Dan buat 1 Form lagi bernama : Form2
9. Seperti diatas tetapi lihat di bawah ini :
( Tip : Jika kurang jelas, silahkan di klik )
Contoh programnya |
Option Explicit
'Created Date: 15 September 2013
'Form1 Counter Strike 1.6 Injector by M.Sammy Budiarjo
'Email : samfx66@gmail and sfxpm.inc@gmail
'Editan : Ya
Private winHwnd As Long
Private NamaDll As String
Private Keluardariprogram As String
Private Const WM_NCLBUTTONDOWN As Long = &HA1
Private Const HTCAPTION As Integer = 2
Private Declare Sub ReleaseCapture Lib "user32" ()
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Form_Load()
NamaDll = App.Path & "\CounterStrike1.6Injector.dll" 'Tidak diberbolehkan spasi
FileTarget = "hl.exe"
Check1.Value = 1
End Sub
Private Sub Form_MouseMove(Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
Screen.MousePointer = vbDefault
End Sub
Private Sub lblAbout_Click()
Form2.Show
End Sub
Private Sub lblClose_Click()
Keluardariprogram = MsgBox(" Close this program?", vbYesNo, "Exit")
If Keluardariprogram = vbYes Then Unload Me
End Sub
Private Sub Timer1_Timer()
winHwnd = GetProcessWndByName(FileTarget)
If Not winHwnd = 0 Then
NTProcessList
InjectExecute NamaDll
If Check1.Value = 1 Then
End
End If
Else
Label1.Caption = "Waiting hl.exe"
End If
End Sub
Yang warna merah silahkan anda edit
Yang warna orange jangan di edit
11. Masukkan kode di bawah ini pada form2
Private Sub lblCloseAboutMenu_Click()Unload MeEnd Sub
12. Buat 1 module bernama : ModInjector, dan massukan kode di bawah ini pada module tersebut
Option Explicit'Created Date: 15 September 2013'Form1 Counter Strike 1.6 Injector by M.Sammy Budiarjo'Email : samfx66@gmail and sfxpm.inc@gmailPublic FileTarget As StringPrivate sFlDLL As StringPrivate IdTargetOne As LongPrivate Const TH32CS_SNAPHEAPLIST As Long = &H1Private Const TH32CS_SNAPPROCESS As Long = &H2Private Const TH32CS_SNAPTHREAD As Long = &H4Private Const TH32CS_SNAPMODULE As Long = &H8Private Const TH32CS_SNAPALL As Double = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)Private Const MAX_PATH As Integer = 260Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFFPrivate Type PROCESSENTRY32dwSize As LongcntUsage As Longth32ProcessID As Longth32DefaultHeapID As Longth32ModuleID As LongcntThreads As Longth32ParentProcessID As LongpcPriClassBase As LongdwFlags As LongszExeFile As String * MAX_PATHEnd TypePrivate Type MODULEENTRY32dwSize As Longth32ModuleID As Longth32ProcessID As LongGlblcntUsage As LongProccntUsage As LongmodBaseAddr As LongmodBaseSize As LonghModule As LongszModule As String * 256szExePath As String * 260End TypePrivate Type THREADENTRY32dwSize As LongcntUsage As Longth32ThreadID As Longth32OwnerProcessID As LongtpBasePri As LongtpDeltaPri As LongdwFlags As LongEnd TypePublic Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _(ByVal hwnd As Long, _ByVal lpOperation As String, _ByVal lpFile As String, _ByVal lpParameters As String, _ByVal lpDirectory As String, _ByVal nShowCmd As Long) As LongPrivate Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, _ByVal lProcessID As Long) As LongPrivate Declare Function Module32First Lib "kernel32" (ByVal hSnapshot As Long, _uProcess As MODULEENTRY32) As LongPrivate Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As LongPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _ByVal bInheritHandle As Long, _ByVal dwProcessId As Long) As LongPrivate Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, _uProcess As PROCESSENTRY32) As LongPrivate Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, _uProcess As PROCESSENTRY32) As LongPrivate Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPrivate Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _ByVal lpProcName As String) As LongPrivate Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPrivate Declare Function VirtualAllocEx Lib "kernel32" (ByVal hProcess As Long, _lpAddress As Any, _ByVal dwSize As Long, _ByVal fAllocType As Long, _flProtect As Long) As LongPrivate Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, _ByVal lpBaseAddress As Any, _lpBuffer As Any, _ByVal nSize As Long, _lpNumberOfBytesWritten As Long) As LongPrivate Declare Function CreateRemoteThread Lib "kernel32" (ByVal ProcessHandle As Long, _lpThreadAttributes As Long, _ByVal dwStackSize As Long, _ByVal lpStartAddress As Any, _ByVal lpParameter As Any, _ByVal dwCreationFlags As Long, _lpThreadID As Long) As LongPublic Function GetFName(fn) As StringDim f As IntegerDim n As IntegerGetFName = fnf = InStr(fn, "\")Do While fn = ff = InStr(n + 1, fn, "\")LoopIf n > 0 ThenGetFName = Mid$(fn, n + 1)End IfEnd FunctionPublic Function GetProcessIdByName(ByVal szProcessName As String) As LongDim pe32 As PROCESSENTRY32Dim hSnapshot As LongDim bFoundProc As BooleanDim dwProcId As LongdwProcId = 0pe32.dwSize = Len(pe32)hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)bFoundProc = Process32First(hSnapshot, pe32)Do While bFoundProcIf Right$(LCase$(Left$(pe32.szExeFile, InStr(1, pe32.szExeFile, vbNullChar) - 1)), Len(szProcessName)) = LCase$(szProcessName) ThendwProcId = pe32.th32ProcessIDExit DoEnd IfbFoundProc = Process32Next(hSnapshot, pe32)LoopCloseHandle hSnapshotGetProcessIdByName = dwProcIdEnd FunctionPublic Function GetProcessWndByName(ByVal szProcessName As String) As LongDim dwProcId As LongDim dwProcWnd As LongdwProcId = GetProcessIdByName(szProcessName)If dwProcId = 0 ThenGetProcessWndByName = 0ElsedwProcWnd = OpenProcess(PROCESS_ALL_ACCESS, False, dwProcId)CloseHandle dwProcIdGetProcessWndByName = dwProcWndEnd IfEnd FunctionPublic Sub InjectDll(DllPath As String, _ProsH As Long)Dim DLLVirtLoc As LongDim DllLength As LongDim inject As LongDim LibAddress As LongDim CreateThread As LongDim ThreadID As LongDim Bla As VbMsgBoxResultg_loadlibary:LibAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA")If LibAddress = 0 ThenBla = MsgBox("Can't find LoadLibrary API from kernel32.dll", vbYesNo, "ERROR")If Bla = vbYes ThenGoTo g_loadlibaryElseExit SubEnd IfEnd Ifg_virutalallocex:DllLength = Len(DllPath)DLLVirtLoc = VirtualAllocEx(ProsH, 0, DllLength, &H1000, ByVal &H4)If DLLVirtLoc = 0 ThenBla = MsgBox("VirtualAllocEx API failed! - try again?", vbYesNo, "ERROR")If Bla = vbYes ThenGoTo g_virutalallocexElseExit SubEnd IfEnd Ifg_writepmemory:inject = WriteProcessMemory(ProsH, ByVal DLLVirtLoc, ByVal DllPath, DllLength, vbNull)If inject = 0 ThenBla = MsgBox("Failed to Write DLL to Process! - try again?", vbYesNo, "ERROR")If Bla = vbYes ThenGoTo g_writepmemoryElseExit SubEnd IfEnd Ifg_creatthread:CreateThread = CreateRemoteThread(ProsH, ByVal 0, 0, ByVal LibAddress, ByVal DLLVirtLoc, 0, ThreadID)If CreateThread = 0 ThenBla = MsgBox("Failed to Create Thead! - try again?", vbYesNo, "ERROR")If Bla = vbYes ThenGoTo g_creatthreadElseExit SubEnd IfEnd IfForm1.Label1.Caption = "Injected Successful!"MsgBox "Dll Injection Successful!", vbInformation, "Success"End SubPublic Sub InjectExecute(ByVal sFlDLL As String)Dim lProcInject As LonglProcInject = OpenProcess(PROCESS_ALL_ACCESS, 0, IdTargetOne)If lProcInject > "0" ThenInjectDll sFlDLL, lProcInjectEnd IfCloseHandle lProcInjectEnd SubPublic Function NTProcessList() As LongDim FileName As StringDim ExePath As StringDim hProcSnap As LongDim hModuleSnap As LongDim lProc As LongDim uProcess As PROCESSENTRY32Dim uModule As MODULEENTRY32On Error Resume NexthProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)uProcess.dwSize = Len(uProcess)lProc = Process32First(hProcSnap, uProcess)Do While lProcIf uProcess.th32ProcessID <> 0 ThenhModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, uProcess.th32ProcessID)uModule.dwSize = Len(uModule)Module32First hModuleSnap, uModuleIf hModuleSnap > 0 ThenExePath = StripNulls(uModule.szExePath)FileName = GetFName(ExePath)If FileTarget = FileName ThenIdTargetOne = uProcess.th32ProcessIDEnd IfEnd IfEnd IflProc = Process32Next(hProcSnap, uProcess)LoopCloseHandle hProcSnapCloseHandle lProcOn Error GoTo 0End FunctionPrivate Function StripNulls(ByVal sStr As String) As StringStripNulls = Left$(sStr, lstrlen(sStr))End FunctionPublic Sub OpenURL(situs As String, sourceHWND As Long)Call ShellExecute(sourceHWND, vbNullString, situs, vbNullString, vbNullString, 1)End Sub
Yang warna orange jangan di ganti
13. Jika sudah di coba dulu program-nya
14. Jika sudah benar, kita compile menjadi EXE, caranya :
14 : 1. Klik menu File
14 : 2. Klik sub menu Make Nama project anda.exe
15. Enjoy, Heppy programming :D
0 Komentar untuk "Cara membuat Injector DLL dengan Visual Basic 6.0 "
Don't forget leave some comment