La structure RTL_USER_PROCESS_PARAMETERS
Par Samuel Dralet, dans Forensics -# 12 - Fil RSS
Pour connaitre la ligne de commande d'un processus, son environnement, le nom du binaire exécuté et son path, et tout un tas d'autres informations, il existe la structure RTL_USER_PROCESS_PARAMETERS.
Chaque processus sous Windows est doté d'un PEB (Process Environnement Block). Ce n'est pas nouveau :) C'est une structure spécifique au processus courant, gérée par le système d'exploitation, et contenant des variables nécessaires à son exécution. La structure est déclarée de cette manière:
0:002> dt nt!_PEB +0x000 InheritedAddressSpace : UChar +0x001 ReadImageFileExecOptions : UChar +0x002 BeingDebugged : UChar +0x003 SpareBool : UChar +0x004 Mutant : Ptr32 Void +0x008 ImageBaseAddress : Ptr32 Void +0x00c Ldr : Ptr32 _PEB_LDR_DATA +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS +0x014 SubSystemData : Ptr32 Void +0x018 ProcessHeap : Ptr32 Void [...]
Le champ ProcessParameters est celui qui nous intéresse. Il pointe vers une structure _RTL_USER_PROCESS_PARAMETERS qui a cette forme:
0:002> dt nt!_RTL_USER_PROCESS_PARAMETERS +0x000 MaximumLength : Uint4B +0x004 Length : Uint4B +0x008 Flags : Uint4B +0x00c DebugFlags : Uint4B +0x010 ConsoleHandle : Ptr32 Void +0x014 ConsoleFlags : Uint4B +0x018 StandardInput : Ptr32 Void +0x01c StandardOutput : Ptr32 Void +0x020 StandardError : Ptr32 Void +0x024 CurrentDirectory : _CURDIR +0x030 DllPath : _UNICODE_STRING +0x038 ImagePathName : _UNICODE_STRING +0x040 CommandLine : _UNICODE_STRING +0x048 Environment : Ptr32 Void +0x04c StartingX : Uint4B +0x050 StartingY : Uint4B +0x054 CountX : Uint4B +0x058 CountY : Uint4B +0x05c CountCharsX : Uint4B +0x060 CountCharsY : Uint4B +0x064 FillAttribute : Uint4B +0x068 WindowFlags : Uint4B +0x06c ShowWindowFlags : Uint4B +0x070 WindowTitle : _UNICODE_STRING +0x078 DesktopInfo : _UNICODE_STRING +0x080 ShellInfo : _UNICODE_STRING +0x088 RuntimeData : _UNICODE_STRING +0x090 CurrentDirectores : [32] _RTL_DRIVE_LETTER_CURDIR
Et vous avez tout ce que vous voulez. Un détail, si vous lancer votre debugger favori, vous vous apercevez que le champ ProcessParameters a toujours pour adresse 0x20000, quelque soit le processus (en tout cas sur un XPSP2).
L'idéal maintenant est d'obtenir ces informations en lisant la mémoire physique...
Commentaires
Aucun commentaire pour le moment.
Ajouter un commentaire