My name is Anderson,
Today I will give you my source code of my injector
I hope that helps you.
Code:
;---------------------------------------------;---------------------------------------------
;-Includes
;---------------------------------------------;---------------------------------------------
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <misc.au3>
#include <File.au3>
#Include <WinAPI.au3>
#include "_UskinLibrary.au3"
#include "Ezlo.au3"
_Uskin_LoadDLL()
_USkin_Init(_Ezlo(True))
;--------------------------------------------
;--------------------------------------------
;-Validando para Apenas Executar uma vez
;--------------------------------------------
$nScript = "DarkSide TEAM"
If WinExists($nScript) Then
Msgbox(0,"DarkSide Injector","O programa já está em execução")
Exit
EndIf
AutoItWinSetTitle($nScript)
;--------------------------------------------
$Logo_jpg = @TempDir & "bg-Dark.jpg"
FileInstall("C:Dark sideInjetorResourcesbg-Dark.jpg", $Logo_jpg)
SplashImageOn("", $Logo_jpg, 421, 111, -1, -1, 1)
Sleep(3000)
SplashOff()
;--------------------------------------------
;-Definições Globais
;--------------------------------------------
#AutoIt3Wrapper_UseUpx=n ;Nao usar upx
#AutoIt3Wrapper_UseX64=n ;Nao usar console x64
#NotrayIcon ;Sem icone no rodape
#RequireAdmin ;Executar Como admin
#AutoIt3Wrapper_Res_Comment=DarkSide TEAM - Hacking our Duty. ;Comentario
#AutoIt3Wrapper_Res_Description=Injete dlls em programas em execução. ;Descricao
#AutoIt3Wrapper_Res_Fileversion=4.0.0.1 ;Versao
#AutoIt3Wrapper_Res_ProductVersion=4.0.0.1 ; Versao
#AutoIt3Wrapper_Res_LegalCopyright=(C)DarkSide TEAM 2012 ;Copyright
#AutoIt3Wrapper_Res_Language=1046 ;Definiçao de linguagem 1046 = PT-BR
#AutoIt3Wrapper_Res_Field=CompanyName|DarkSide TEAM. ;Nome da Empresa produtora
#AutoIt3Wrapper_Res_Field=InternalName|DarkSideInjector.exe ;Nome do arquivo
#AutoIt3Wrapper_Res_Field=LegalTrademarks|Esse Software é para uso domestico apenas-Todos os direitos reservados.
#AutoIt3Wrapper_Res_Field=OriginalFilename|
#AutoIt3Wrapper_Res_Field=DigitalProductID|0x4E657453656E642E657865
#AutoIt3Wrapper_Res_Field=DateBuild|%longdate%
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #INDEX# =======================================================================================================================
; Title .........: CreateFilesEmbedded
; Module ........: Main
;Opt('MustDeclareVars', 1); Garante que todas as variáveis sejam obrigadas a serem declaradas!
;--------------------------------------------
;--------------------------------------------
;-Variaveis
;--------------------------------------------
Local $Form1, $iButton1
Local $Window, $iButton2
Local $aGuiEvt, $sFileOpen
;--------------------------------------------
;--------------------------------------------
;-Criando Formulario 1
;--------------------------------------------
$Form1 = GUICreate("DarkSide TEAM", 275, 100)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateLabel("Processo:", 10, 10, 50, 17)
$I_ProcessName = GUICtrlCreateInput(IniRead("Config.ini", "Configuracoes", "Processo", "default"), 65, 10, 150, 21)
$B_SearchProcess = GUICtrlCreateButton("Procurar", 220, 10, 50, 22)
GUICtrlCreateLabel("Local Dll:", 10, 40, 50, 17)
$I_DllPath = GUICtrlCreateInput(IniRead("Config.ini", "Configuracoes", "Dll", "default"), 65, 40, 150, 21)
$B_SearchDll = GUICtrlCreateButton("Procurar", 220, 39, 50, 22)
$R_Auto = GUICtrlCreateRadio("Automático", 50, 75, 75, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$R_Man = GUICtrlCreateRadio("Manual", 130, 75, 55, 17)
$B_Inject = GUICtrlCreateButton("Injetar", 190, 70, 75, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
;--------------------------------------------
;--------------------------------------------
;-Declamaramos que a Injeção ainda não foi feita
;--------------------------------------------
$Injected = False
;--------------------------------------------
;--------------------------------------------
;-Criando Formulario 2
;--------------------------------------------
Dim $string[1]
$Window = GUICreate("Lista de Processos", 300, 270) ;Janela Principal
$menu1 = GUICtrlCreateMenu("Processos:")
$List = GUICtrlCreateList("",2,2, 295,230) ;Cria a Lista Ja preenchida
$Processes = ProcessList()
ReDim $string[$Processes[0][0] + 1] ;+1 porque a variavel $processes comeca com 1,0
For $i = 1 To $Processes[0][0]
If $string[$i] = "" Then $string[$i] = $Processes[$i][0]
GUICtrlSetData($List,$string[$i])
Next
$ButtonRefresh = GUICtrlCreateButton("Atualizar", 30,230,170,20)
GUICtrlSetState(-1, $GUI_FOCUS)
$n2 = GUICtrlCreateButton("Selecionar", 230, 230,70, 20)
GUISetState(@SW_HIDE) ;Esconde a janela no inicio
;--------------------------------------------
;--------------------------------------------
;-Começo do Programa e separação dos Forms
;--------------------------------------------
While 1
;#Sobre o GUIGetMsg()--------------------------------------------------------------------
; Quando usado o parâmetro "Advanced", é retornado um array com as seguintes informações:
; $array[0] = 0 ou Event ID ou Control ID
; $array[1] = A identificação da GUI (Window Handle)
;----------------------------------------------------------------------------------------
$aGuiEvt = GUIGetMsg(1) ; (1) = Avançado
Switch $aGuiEvt[1] ; Verifica a identificação da GUI
; Se for o Form1, então;
Case $Window
Switch $aGuiEvt[0] ; Verifica o identificador do controle (Control ID)
Case $n2
;MsgBox(0, "Selecionado:", GUICtrlRead($List)) ; mostra o selicionado
GUICtrlSetData($I_ProcessName, GUICtrlRead($List))
Sleep(4)
GUISetState(@SW_HIDE,$Window)
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $Window)
Case $ButtonRefresh
GUICtrlDelete($List) ;Recria a Lista
$List = GUICtrlCreateList("",2,2, 295,230) ;Para Atualiza-la
$Processes = ProcessList()
ReDim $string[$Processes[0][0] + 1] ;+1 porque a variavel $processes comeca com 1,0
For $i = 1 To $Processes[0][0]
If $string[$i] = "" Then $string[$i] = $Processes[$i][0]
GUICtrlSetData($List,$string[$i])
Next
EndSwitch
; Se for o Form2, então;
Case $Form1
Switch $aGuiEvt[0] ; Verifica o identificador do controle (Control ID)
Case $GUI_EVENT_CLOSE
GUISetState(@SW_HIDE, $Form1)
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_SearchProcess
_processos()
Case $B_Inject
$ProcessId = ProcessExists(GUICtrlRead($I_ProcessName))
If $ProcessId > 0 Then
$theStrp = StringSplit(GUICtrlRead($I_DllPath), ".") ; Criamos uma Matriz
For $x = 1 to $theStrp[0] Step 1
if $theStrp[$x] = "dll" then
$dll = True
Else
$dll = False
EndIf
Next
if $dll == True then
_InjectDll($ProcessId, GUICtrlRead($I_DllPath))
_Message(@error)
$Injected = True
Else
MsgBox(48, "Erro", "Por favor Informe um arquivo .dll valido.")
endif
;Exit
EndIf
; _InjectDll(ProcessExists(GUICtrlRead($I_ProcessName)), GUICtrlRead($I_DllPath))
;_Message(@error)
EndSwitch
EndSwitch
;--------------------------------------------
;-Validando o Fechamento dos Forms
;--------------------------------------------
If _IsClosedGuis($Form1, $Window) Then Exit
_mostraprocesso()
autoinject()
WEnd
;--------------------------------------------
;-Funcao validando checkbox automatico
;--------------------------------------------
Func autoinject()
If BitAND(GUICtrlRead($R_Auto), $GUI_CHECKED) And Not $Injected Then
$ProcessId = ProcessExists(GUICtrlRead($I_ProcessName))
$DllPath = GUICtrlRead($I_DllPath)
If $ProcessId > 0 and $DllPath <> "" Then
$theStrp1 = StringSplit(GUICtrlRead($I_DllPath), ".") ; Criamos uma Matriz
For $w = 1 to $theStrp1[0] Step 1
if $theStrp1[$w] = "dll" then
$dll2 = True
Else
$dll2 = False
EndIf
Next
if $dll2 == True then
_InjectDll($ProcessId, GUICtrlRead($I_DllPath))
_Message(@error)
$Injected = True
Else
;MsgBox(48, "Erro", "Por favor Informe um arquivo .dll valido.")
endif
;Exit
EndIf
EndIf
endfunc
;--------------------------------------------
;-Mostra Tooltip se o processo for valido
;--------------------------------------------
Func _mostraprocesso()
$theStr = StringSplit(GUICtrlRead($I_ProcessName), ".") ; Criamos uma Matriz
For $i = 1 to $theStr[0] Step 1
if $theStr[$i] = "exe" then
$executavel = True
Else
$executavel = False
EndIf
Next
if GUICtrlRead($I_ProcessName) <> "" then
if $executavel==True Then
ToolTip("Esperando "&GUICtrlRead($I_ProcessName), 0, 0)
Else
ToolTip("", 0, 0)
endif
endif
EndFunc
;--------------------------------------------
;-Abre Form de Processos
;--------------------------------------------
Func _processos()
GUISetState(@SW_SHOW,$Window) ;Mostra a Janela
EndFunc
;--------------------------------------------
;-Funcao Mensagem de Erro
;--------------------------------------------
Func _Message($ErrorCode)
If @error == 0 Then
MsgBox(64, "Sucesso", "Dll Injetada com exito!")
if FileExists(@ScriptDir&"Config.ini") Then
FileDelete(@ScriptDir&"Config.ini")
salvar()
Else
salvar()
EndIf
exit
endif
If $ErrorCode <> 0 Then
MsgBox(48, "Erro", "Houve um erro!" & @CRLF & "O código de erro: " & @error)
if FileExists(@ScriptDir&"Config.ini") Then
FileDelete(@ScriptDir&"Config.ini")
salvar()
Else
salvar()
EndIf
Else
MsgBox(64, "Sucesso", "Dll Injetada com exito!")
if FileExists(@ScriptDir&"Config.ini") Then
FileDelete(@ScriptDir&"Config.ini")
salvar()
Else
salvar()
EndIf
exit
EndIf
EndFunc
;--------------------------------------------
;-Salvando Configuracoes
;--------------------------------------------
Func salvar()
IniWrite(@ScriptDir&"Config.ini","Configuracoes","Processo",GUICtrlRead($I_ProcessName))
IniWrite(@ScriptDir&"Config.ini","Configuracoes","Dll", GUICtrlRead($I_DllPath))
EndFunc
;=================================================================================================
; Funcao...............: _InjectDll($ProcessId, $DllPath)
; Descricao............: Injeta arquivos .dll em programas em execução.
; Valores Retornado(s).: Sucesso - Retorna true
; On Failure - Returns false
; @Error - 0 = Sem erros.
; 1 = ProcessId Invalido.
; 2 = Arquivo nao existe.
; 3 = Arquivo invalido .dll (invalid file).
; 4 = Falha ao abrir 'Advapi32.dll'.
; 5 = Falha ao recuperar o caminho.
; 6 = Falha ao abrir o processo.
; 7 = Falha ao chamar 'GetModuleHandle'.
; 8 = Falha ao chamar 'GetProcAddress'.
; 9 = Falha ao chamar 'VirtualAllocEx'.
; 10 = Falha ao escrever na memoria.
; 11 = Falha ao criar o 'RemoteThread'.
; Author(s): Anderson Oliveira
;=================================================================================================
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
;--------------------------------------------
;-Validando o fechamento dos Forms
;--------------------------------------------
Func _IsClosedGuis($hWnd1, $hWnd2)
Local $iState1, $iState2
$iState1 = WinGetState($hWnd1, "")
$iState2 = WinGetState($hWnd2, "")
If Not BitAnd($iState1, 2) And Not BitAnd($iState2, 2) Then Return 1
Return 0
EndFunc







