DLL auf inject prüfen

05/14/2011 14:00 Whoknowsit#1
Hi,

ist es irgendwie möglich, ob eine spezielle DLL in einen spezifischen Prozess injected wurde?

Speziell geht es mir um den Hack [Only registered and activated users can see links. Click Here To Register...] und die dazugehörige WExt.dll.
05/14/2011 14:03 yihaaa#2
Kannst du die Frage noch mal so stellen, dass man diese auch versteht?

MfG

Edit: Meinst du ob eine DLL-injection möglich ist oder nicht?
05/14/2011 14:11 Whoknowsit#3
Hm... Wie soll ich die Frage denn stellen? Ich meine genau das, was ich schrieb :D

WoWExt injected WExt.dll in den gewählten WoW-Prozess, richtig? Ich möchte mit AutoIT herausfinden, ob die o.g. DLL in den WoW-Prozess injected wurde, oder nicht.

Ich sende Zeichenfolgen an WoW, die aber nur dann funktionieren, wenn WoWExt in den Prozess geladen wurde.

EDIT:

Code:
$offset = ......
$wow= _MEMORYOPEN($ProcessID)
$base = _MEMORYMODULEGETBASEADDRESS($ProcessID, "Wow.exe")
If _MEMORYREAD($base + $offset, $wow, "byte") == XXX Then
so?!
05/15/2011 19:17 derpo#4
Quote:
Originally Posted by Whoknowsit View Post
Hm... Wie soll ich die Frage denn stellen? Ich meine genau das, was ich schrieb :D

WoWExt injected WExt.dll in den gewählten WoW-Prozess, richtig? Ich möchte mit AutoIT herausfinden, ob die o.g. DLL in den WoW-Prozess injected wurde, oder nicht.

Ich sende Zeichenfolgen an WoW, die aber nur dann funktionieren, wenn WoWExt in den Prozess geladen wurde.

EDIT:

Code:
$offset = ......
$wow= _MEMORYOPEN($ProcessID)
$base = _MEMORYMODULEGETBASEADDRESS($ProcessID, "Wow.exe")
If _MEMORYREAD($base + $offset, $wow, "byte") == XXX Then
so?!

Hier habe ich mal ein Beispiel erstellt, das die kernel32.dll im eigenen Prozess sucht. _InjectModulInfo ist nicht von mir.
PHP Code:
#include <Memory.au3>
#include <WinAPI.au3>
#include <NomadMemory.au3>
$modulinfo _InjectModulInfo(@AutoItPID)
For 
$i 0 To UBound($modulinfo,1Step 1
    
If $modulinfo[$i][8] = "Kernel32.dll" Then
        MsgBox
(0,"Fund","Ich habe die kernel32.dll gefunden!")
        
ExitLoop
    
EndIf
Next

#FUNCTION# ====================================================================================================================
Name...........: _InjectModulInfo
Description ...: Returns information about every modul in the specified process
Syntax.........: _InjectModulInfo($PID)
Parameters ....: $PID A process identifier
; Return values .: Success        Returns an 2d array with the modules and there information
;                  Failure        Returns -and sets @Error:
;                  |@
error Wrong PID
;                  |@error DllOpen failed -> kernel32.dll might not have been found
Author ........: Deathly Assassin (http://www.*************)
Modified.......:
Remarks .......:
Related .......:
Link ..........:
Example .......: Yes
; ===============================================================================================================================


Func _InjectModulInfo($PID)
    
Local $hModule$hSnapshot$hOpen$iCount 0$aArray[1][10], $i$vMODULEENTRY32$vNext

    
If Not ProcessExists($PIDThen
        SetError
(1)
        Return -
1
    
EndIf

    
SetPrivilege("SeDebugPrivilege"1)
    
$hOpen DllOpen("Kernel32.dll")

    If @
error Then
        SetError
(2)
        Return -
1
    
EndIf

    
$vMODULEENTRY32 DllStructCreate("DWORD dwSize; DWORD th32ModuleID; DWORD th32ProcessID; DWORD GlblcntUsage; DWORD ProccntUsage; ptr modBaseAddr; DWORD modBaseSize; HANDLE hModule; CHAR szModule[256]; CHAR szExePath[260];")
    
DllStructSetData($vMODULEENTRY321DllStructGetSize($vMODULEENTRY32))
    
$hSnapshot DllCall($hOpen"HANDLE""CreateToolhelp32Snapshot""DWORD"8"DWORD"$PID)
    
DllCall($hOpen"BOOL""Module32First""HANDLE"$hSnapshot[0], "ptr"DllStructGetPtr($vMODULEENTRY32))

    Do
        
ReDim $aArray[$iCount 1][10]
        For 
$i 1 To 10
            $aArray
[$iCount][$i 1] = DllStructGetData($vMODULEENTRY32$i)
        
Next
        $iCount 
+= 1
        $vNext 
DllCall($hOpen"BOOL""Module32Next""HANDLE"$hSnapshot[0], "ptr"DllStructGetPtr($vMODULEENTRY32))
    
Until Not $vNext[0]

    
DllClose($hOpen)

    Return 
$aArray
EndFunc   
;==>_InjectModulInfo 
Falls du Memory.au3 und/oder NomadMemory.au3 noch nicht hast, dann kannst du die hier runterladen :
NomadMemory : [Only registered and activated users can see links. Click Here To Register...]
Memory : [Only registered and activated users can see links. Click Here To Register...]
05/15/2011 23:23 Whoknowsit#5
Danke dafür, aber das funktioniert leider nicht. Ich finde die WExt.dll ums Verderben nicht im WoW-Prozess, obwohl diese injected wurde :(
05/16/2011 11:20 freehuntx#6
Naja, ich würde in der dll einfach eine Messagebox öffnen lassen.

Ich kenne keinen weg es zu überprüfen, aber kannst es ja mal per memory probiere, aber weiß nicht ob das klappt und ob man pointer kriegt.

Z.B. einen text der dll suchen etc.
05/16/2011 13:05 lolkop#7
die idee mit dem snapshot ist schon nicht schlecht...

allerdings wirst du bei x64 programmen auf probleme treffen.

ich hatte mir damals eine ähnliche funktion geschrieben:
Code:
ConsoleWrite(CheckForModule(WinGetProcess('vlc'), 'Kernel32.dll')&@CRLF)

Func CheckForModule($pid, $module_name)
	$struct = DllStructCreate('int; int; int; int; int; ptr; int; hwnd; char[256]; char[260];')
	DllStructSetData($struct, 1, DllStructGetSize($struct))
	$snapshot = DllCall('kernel32.dll', 'hwnd', 'CreateToolhelp32Snapshot', 'dword', 8, 'dword', $pid)
	DllCall('kernel32.dll', 'int', 'Module32First', 'hwnd', $snapshot[0], 'ptr', DllStructGetPtr($struct))
	Do
		If DllStructGetData($struct, 9) = $module_name Then Return True
		$module = DllCall('kernel32.dll', 'int', 'Module32Next', 'hwnd', $snapshot[0], 'ptr', DllStructGetPtr($struct))
	Until Not $module[0]
	Return False
EndFunc
weis allerdings nicht genau wie man das am besten auf x64 systemen regelt :s
05/16/2011 13:18 Whoknowsit#8
Moin,

danke soweit. Also...

Wenn ich beispielsweise prüfe, ob wow64.dll in den WoW-Prozess geladen wurde, funktionieren alle Lösungen d.h. auch die letzte o.g. Lösung zeigt mir true an.

Wenn ich aber schaue, ob WExt.dll geladen wurde, wird mir überall false angezeigt. Mir wird also tatsächlich nichts anderes übrig bleiben, als einen Text in der DLL zu suchen, oder sonstwas... Oder ich muss nach irgendeinem Offset suchen, welches von der o.g. DLL produziert/verändert wird. Scheinbar :(
05/16/2011 16:50 derpo#9
Führ mal eine der Auflistungsfunktionen von Modulen auf nach der Injektion auf und lass alles mit _ArrayDisplay aus der Array.au3 anzeigen
05/16/2011 18:56 Whoknowsit#10
Schon getan. Die o.g. DLL wird nicht aufgeführt, obwohl sie injected ist.

Code:
#Include <WinAPI.au3>
#include <Array.au3>

; #FUNCTION#;===============================================================================
;
; Name...........: _ProcessGetLoadedModules
; Description ...: Returns an array containing the full path of the loaded modules
; Syntax.........: _ProcessGetLoadedModules($iPID)
; Parameters ....:
; Return values .: Success - An array with all the paths
;               : Failure - -1 and @error=1 if the specified process couldn't be opened.
; Author ........: Andreas Karlsson (monoceres)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........;
; Example .......; No
;
;;==========================================================================================
Func _ProcessGetLoadedModules($iPID)
    Local Const $PROCESS_QUERY_INFORMATION=0x0400
    Local Const $PROCESS_VM_READ=0x0010
    Local $aCall, $hPsapi=DllOpen("Psapi.dll")
    Local $hProcess, $tModulesStruct
    $tModulesStruct=DllStructCreate("int [1000]")
    $hProcess=_WinAPI_OpenProcess(BitOR($PROCESS_QUERY_INFORMATION,$PROCESS_VM_READ),False,$iPID)
    If Not $hProcess Then Return SetError(1,0,-1)
    $aCall=DllCall($hPsapi,"int","EnumProcessModules","ptr",$hProcess,"ptr",DllStructGetPtr($tModulesStruct),"dword",1000,"dword*","")
    If $aCall[4]>1000 Then
        $tModulesStruct=DllStructCreate("int ["&$aCall[4]&"]")
        $aCall=DllCall($hPsapi,"int","EnumProcessModules","ptr",$hProcess,"ptr",DllStructGetPtr($tModulesStruct),"dword",$aCall[4],"dword*","")
    EndIf
    Local $aReturn[$aCall[4]]
    For $i=0 To Ubound($aReturn)-1
        $aCall=DllCall($hPsapi,"dword","GetModuleFileNameExW","ptr",$hProcess,"int",DllStructGetData($tModulesStruct,1,$i+1),"wstr","","dword",65536)
        $aReturn[$i]=$aCall[3]
    Next
    _WinAPI_CloseHandle($hProcess)
    DllClose($hPsapi)
    Return $aReturn
EndFunc

$MODULES = _ProcessGetLoadedModules(4920)
_ArrayDisplay($MODULES)
Ergebnis:

Quote:
[0]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[1]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[2]|C:\Windows\SYSTEM32\ntdll.dll
[3]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[4]|C:\Windows\SYSTEM32\wow64.dll
[5]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[6]|C:\Windows\SYSTEM32\wow64win.dll
[7]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[8]|C:\Windows\SYSTEM32\wow64cpu.dll
[9]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[10]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[11]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[12]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[13]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[14]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[15]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[16]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[17]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[18]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[19]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[20]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[21]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[22]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[23]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[24]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[25]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[26]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[27]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[28]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[29]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[30]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[31]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[32]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[33]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[34]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[35]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[36]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[37]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[38]|C:\Program Files (x86)\World of Warcraft\WoW.exe
[39]|C:\Program Files (x86)\World of Warcraft\WoW.exe
4920 ist natürlich die PID des entsprechenden WoW-Prozesses.
05/16/2011 21:24 lolkop#11
das ganze funktioniert nicht weil du ein 64bit system hast auf dem du 32bit funktionen aufrufen willst...

das hatte ich aber bereits von anfang an gesagt.

du kannst ja mal nach den apis in verbindung mit 64bit systemen googlen und wirst das selbe was ich anfangs sagte mti ewas anderem wortlaut auch in vielen anderen foren finden