You last visited: Today at 17:06
Advertisement
[Help] Code Autoit Close Auto Injector
Discussion on [Help] Code Autoit Close Auto Injector within the AutoIt forum part of the Coders Den category.
05/16/2012, 19:04
#1
elite*gold: 0
Join Date: Jun 2011
Posts: 228
Received Thanks: 1,011
[Help] Code Autoit Close Auto Injector
Is there anybody who can help me with a box to auto close after the dll is injected?
Please help.
PHP Code:
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#RequireAdmin
#include <GUIConstants.au3>
GUICreate ( "Injector By Alexgogole" , 351 , 143 , 186 , 125 )
GUISetBkColor ( 0xFFFFFF )
GUICtrlCreateLabel ( "Process:" , 10 , 10 , 50 , 17 )
$I_ProcessName = GUICtrlCreateInput ( "" , 65 , 10 , 200 , 21 )
GUICtrlCreateLabel ( "DLL:" , 10 , 40 , 50 , 17 )
$I_DllPath = GUICtrlCreateInput ( "" , 65 , 40 , 150 , 21 )
$B_SearchDll = GUICtrlCreateButton ( "..." , 225 , 40 , 40 , 25 )
$R_Auto = GUICtrlCreateRadio ( "Automatic" , 10 , 75 , 75 , 17 )
GUICtrlSetState (- 1 , $GUI_CHECKED )
$R_Man = GUICtrlCreateRadio ( "Manual" , 130 , 75 , 55 , 17 )
$B_Inject = GUICtrlCreateButton ( "Injectar" , 190 , 70 , 75 , 25 )
$Label1 = GUICtrlCreateLabel ( "Made by Alexgoogle" , 8 , 184 , 100 , 17 )
$MadeByAlexgoogle = GUICtrlCreateLabel ( "MadeByAlexgoogle" , 248 , 120 , 95 , 17 )
$Checkbox1 = GUICtrlCreateCheckbox ( "Close After Injecting..." , 8 , 120 , 129 , 17 )
GUICtrlSetState (- 1 , $GUI_DISABLE )
GUISetState ()
$Injected = False
Do
$Msg = GUIGetMsg ()
Switch $Msg
Case $B_SearchDll
GUICtrlSetData ( $I_DllPath , FileOpenDialog ( "Dll" , @ HomeDrive , "Dynamic Link Library (*.dll)" , 3 ))
Case $R_Auto
GUICtrlSetState ( $B_Inject , $GUI_DISABLE )
Case $R_Man
GUICtrlSetState ( $B_Inject , $GUI_ENABLE )
Case $B_Inject
_InjectDll ( ProcessExists ( GUICtrlRead ( $I_ProcessName )), GUICtrlRead ( $I_DllPath ))
_Message (@ error )
EndSwitch
If BitAND ( GUICtrlRead ( $R_Auto ), $GUI_CHECKED ) And Not $Injected Then
$ProcessId = ProcessExists ( GUICtrlRead ( $I_ProcessName ))
If $ProcessId > 0 Then
_InjectDll ( $ProcessId , GUICtrlRead ( $I_DllPath ))
_Message (@ error )
$Injected = True
;Exit
EndIf
EndIf
Sleep ( 10 )
Until $Msg == $GUI_EVENT_CLOSE
Func _Message ( $ErrorCode )
If $ErrorCode <> 0 Then
MsgBox ( 48 , "Fehler" , "There is an error!" & @ CRLF & "Fehlercode: " & @ error )
Else
MsgBox ( 64 , "Info" , "successful injection!" )
EndIf
EndFunc
;=================================================================================================
; Function: _InjectDll ( $ProcessId , $DllPath )
; Description : Injects a . dll into a running program .
; Return Value ( s ): On Success - Returns true
; On Failure - Returns false
; @ Error - 0 = No error .
; 1 = Invalid ProcessId .
; 2 = File does not exist .
; 3 = File is not a . dll ( invalid file ).
; 4 = Failed to open 'Advapi32.dll' .
; 5 = Failed to get the full path .
; 6 = Failed to open the process .
; 7 = Failed to call 'GetModuleHandle' .
; 8 = Failed to call 'GetProcAddress' .
; 9 = Failed to call 'VirtualAllocEx' .
; 10 = Failed to write the memory .
; 11 = Failed to create the 'RemoteThread' .
; Author ( s ): KillerDeluxe
;=================================================================================================
Func _InjectDll ( $ProcessId , $DllPath )
If $ProcessId == 0 Then Return SetError ( 1 , "" , False )
If Not ( FileExists ( $DllPath )) Then Return SetError ( 2 , "" , False )
If Not ( StringRight ( $DllPath , 4 ) == ".dll" ) Then Return SetError ( 3 , "" , False )
$Kernel32 = DllOpen ( "kernel32.dll" )
If @ error Then Return SetError ( 4 , "" , False )
$DLL_Path = DllStructCreate ( "char[255]" )
DllCall ( $Kernel32 , "DWORD" , "GetFullPathNameA" , "str" , $DllPath , "DWORD" , 255 , "ptr" , DllStructGetPtr ( $DLL_Path ), "int" , 0 )
If @ error Then Return SetError ( 5 , "" , False )
$hProcess = DllCall ( $Kernel32 , "DWORD" , "OpenProcess" , "DWORD" , 0x1F0FFF , "int" , 0 , "DWORD" , $ProcessId )
If @ error Then Return SetError ( 6 , "" , False )
$hModule = DllCall ( $Kernel32 , "DWORD" , "GetModuleHandleA" , "str" , "kernel32.dll" )
If @ error Then Return SetError ( 7 , "" , False )
$lpStartAddress = DllCall ( $Kernel32 , "DWORD" , "GetProcAddress" , "DWORD" , $hModule [ 0 ], "str" , "LoadLibraryA" )
If @ error Then Return SetError ( 8 , "" , False )
$lpParameter = DllCall ( $Kernel32 , "DWORD" , "VirtualAllocEx" , "int" , $hProcess [ 0 ], "int" , 0 , "ULONG_PTR" , DllStructGetSize ( $DLL_Path ), "DWORD" , 0x3000 , "int" , 4 )
If @ error Then Return SetError ( 9 , "" , False )
DllCall ( "kernel32.dll" , "BOOL" , "WriteProcessMemory" , "int" , $hProcess [ 0 ], "DWORD" , $lpParameter [ 0 ], "str" , DllStructGetData ( $DLL_Path , 1 ), "ULONG_PTR" , DllStructGetSize ( $DLL_Path ), "int" , 0 )
If @ error Then Return SetError ( 10 , "" , False )
$hThread = DllCall ( $Kernel32 , "int" , "CreateRemoteThread" , "DWORD" , $hProcess [ 0 ], "int" , 0 , "int" , 0 , "DWORD" , $lpStartAddress [ 0 ], "DWORD" , $lpParameter [ 0 ], "int" , 0 , "int" , 0 )
If @ error Then Return SetError ( 11 , "" , False )
DllCall ( $Kernel32 , "BOOL" , "CloseHandle" , "DWORD" , $hProcess [ 0 ])
DllClose ( $Kernel32 )
Return SetError ( 0 , "" , True )
EndFunc
05/16/2012, 19:25
#2
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
Code:
Func _Message($ErrorCode)
If $ErrorCode <> 0 Then
MsgBox(48, "Fehler", "There is an error!" & @CRLF & "Fehlercode: " & @error)
Exit
Else
MsgBox(64, "Info", "successful injection!")
EndIf
Exit
EndFunc
05/16/2012, 19:38
#3
elite*gold: 0
Join Date: Jun 2011
Posts: 228
Received Thanks: 1,011
Quote:
Originally Posted by
Lawliet!
Code:
Func _Message($ErrorCode)
If $ErrorCode <> 0 Then
MsgBox(48, "Fehler", "There is an error!" & @CRLF & "Fehlercode: " & @error)
Exit
Else
MsgBox(64, "Info", "successful injection!")
EndIf
Exit
EndFunc
That he has...You send me the full code included with auto close?
05/16/2012, 19:42
#4
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
Replace this part with the part in the script
05/16/2012, 19:48
#5
elite*gold: 0
Join Date: Jun 2011
Posts: 228
Received Thanks: 1,011
Quote:
Originally Posted by
Lawliet!
Replace this part with the part in the script
Now if I replace her by my ... it will close automatically?
05/16/2012, 20:46
#6
elite*gold: 0
Join Date: Mar 2009
Posts: 7,260
Received Thanks: 33,149
You just failed to copy my example.
Code:
#RequireAdmin
#include <GUIConstants.au3>
$Injected = False
GUICreate("KDInjector", 250, 85)
GUICtrlCreateLabel("Process:", 5, 7, 50, 17)
$I_ProcessName = GUICtrlCreateInput("", 60, 5, 185, 21)
GUICtrlCreateLabel("DLL:", 5, 32, 50, 17)
$I_DllPath = GUICtrlCreateInput("", 60, 30, 155, 21)
$B_SearchDll = GUICtrlCreateButton("...", 220, 30, 25, 21)
$R_Automatic = GUICtrlCreateRadio("Automatic", 10, 60, 80, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$R_Manual = GUICtrlCreateRadio("Manual", 100, 60, 60, 17)
$B_Inject = GUICtrlCreateButton("Inject", 170, 55, 75, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Do
$Msg = GUIGetMsg()
Switch $Msg
Case $B_SearchDll
$DllPath = FileOpenDialog("Dynamic Link Library", @HomeDrive, "Dynamic Link Library (*.dll)", 3)
If Not @error Then GUICtrlSetData($I_DllPath, $DllPath)
Case $R_Automatic
GUICtrlSetState($B_Inject, $GUI_DISABLE)
Case $R_Manual
GUICtrlSetState($B_Inject, $GUI_ENABLE)
Case $B_Inject
$ProcessName = GUICtrlRead($I_ProcessName)
$ProcessId = ProcessExists($ProcessName)
If $ProcessId > 0 Then
$DllPath = GUICtrlRead($I_DllPath)
If Not FileExists($DllPath) Then
MsgBox(48, "Error", '"' & $DllPath & '" does not exist!')
Else
_InjectDll($ProcessId, $DllPath)
If @error Then
MsgBox(48, "Error", "Injection failed!" & @CRLF & "Error: " & @error)
Else
MsgBox(64, "Info", "Successful injected!")
EndIf
EndIf
Else
MsgBox(48, "Error", '"' & $ProcessName & '" is not running!')
EndIf
EndSwitch
If BitAND(GUICtrlRead($R_Automatic), $GUI_CHECKED) And Not $Injected Then
$ProcessId = ProcessExists(GUICtrlRead($I_ProcessName))
If $ProcessId > 0 Then
$Injected = True
_InjectDll($ProcessId, GUICtrlRead($I_DllPath))
If @error Then
GUICtrlSetState($R_Automatic, $GUI_DISABLE)
GUICtrlSetState($R_Manual, $GUI_CHECKED)
MsgBox(48, "Error", "Injection failed!" & @CRLF & "Error: " & @error)
Else
MsgBox(64, "Info", "Successful injected!")
Exit
EndIf
EndIf
EndIf
Sleep(10)
Until $Msg == $GUI_EVENT_CLOSE
;=================================================================================================
; Function: _InjectDll($ProcessId, $DllPath)
; Description: Injects a .dll into a running program.
; Return Value(s): On Success - Returns true
; On Failure - Returns false
; @Error - 0 = No error.
; 1 = Invalid ProcessId.
; 2 = File does not exist.
; 3 = File is not a .dll (invalid file).
; 4 = Failed to open 'Advapi32.dll'.
; 5 = Failed to get the full path.
; 6 = Failed to open the process.
; 7 = Failed to call 'GetModuleHandle'.
; 8 = Failed to call 'GetProcAddress'.
; 9 = Failed to call 'VirtualAllocEx'.
; 10 = Failed to write the memory.
; 11 = Failed to create the 'RemoteThread'.
; Author(s): KillerDeluxe
;=================================================================================================
Func _InjectDll($ProcessId, $DllPath)
If $ProcessId == 0 Then Return SetError(1, "", False)
If Not(FileExists($DllPath)) Then Return SetError(2, "", False)
If Not(StringRight($DllPath, 4) == ".dll") Then Return SetError(3, "", False)
$Kernel32 = DllOpen("kernel32.dll")
If @error Then Return SetError(4, "", False)
$DLL_Path = DllStructCreate("char[255]")
DllCall($Kernel32, "DWORD", "GetFullPathNameA", "str", $DllPath, "DWORD", 255, "ptr", DllStructGetPtr($DLL_Path), "int", 0)
If @error Then Return SetError(5, "", False)
$hProcess = DllCall($Kernel32, "DWORD", "OpenProcess", "DWORD", 0x1F0FFF, "int", 0, "DWORD", $ProcessId)
If @error Then Return SetError(6, "", False)
$hModule = DllCall($Kernel32, "DWORD", "GetModuleHandleA", "str", "kernel32.dll")
If @error Then Return SetError(7, "", False)
$lpStartAddress = DllCall($Kernel32, "DWORD", "GetProcAddress", "DWORD", $hModule[0], "str", "LoadLibraryA")
If @error Then Return SetError(8, "", False)
$lpParameter = DllCall($Kernel32, "DWORD", "VirtualAllocEx", "int", $hProcess[0], "int", 0, "ULONG_PTR", DllStructGetSize($DLL_Path), "DWORD", 0x3000, "int", 4)
If @error Then Return SetError(9, "", False)
DllCall("kernel32.dll", "BOOL", "WriteProcessMemory", "int", $hProcess[0], "DWORD", $lpParameter[0], "str", DllStructGetData($DLL_Path, 1), "ULONG_PTR", DllStructGetSize($DLL_Path), "int", 0)
If @error Then Return SetError(10, "", False)
$hThread = DllCall($Kernel32, "int", "CreateRemoteThread", "DWORD", $hProcess[0], "int", 0, "int", 0, "DWORD", $lpStartAddress[0], "DWORD", $lpParameter[0], "int", 0, "int", 0)
If @error Then Return SetError(11, "", False)
DllCall($Kernel32, "BOOL", "CloseHandle", "DWORD", $hProcess[0])
DllClose($Kernel32)
Return SetError(0, "", True)
EndFunc
Adding a label doesn't make you the creator of something.
Similar Threads
auto alchemy (autoit) code .. Copy
05/01/2012 - SRO Private Server - 4 Replies
#RequireAdmin
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiListView.au3>
Auto Close Injector Source Code [VB 8]
02/17/2012 - C/C++ - 1 Replies
Auto Close Injector Source Code TuT
5 Buttons
2 RadioButtons
1 ListBox
1 TextBox
1 CheckBox
Changing Name :
Listbox1 = "DLLs"
All times are GMT +2. The time now is 17:07 .