|
You last visited: Today at 03:41
Advertisement
MemoryDump
Discussion on MemoryDump within the C/C++ forum part of the Coders Den category.
12/27/2015, 02:58
|
#1
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,548
Received Thanks: 333
|
MemoryDump
Hallo leider kenne ich mich mit c++ und c# noch nicht gut aus und finde nichts groß zu dem thema memorydump. Ist es möglich ein Dll Modul eines Prozess aus dem Arbeitsspeicher heraus zu dumpen ? (Normal verschlüsselt aber zur laufzeit entschlüsselt im speicher) Wie es halt Prozess Hacker 2 und andere Programme machen. - die können nur dmp, wie bekomme ich die dll so dass ich sie mir im ollydbg angucken kann ?  also direkt .dll wäre natürlich das beste
ich habe mehrere wege zwar gefunden aber geklappt hat bei mir keiner 
ich hoffe ihr könnt mir da weiter helfen  mfg waller66
Code mit dem genau das gehen soll :
Da tut sich gar nichts , habs getestet.
Code:
#include <stdio.h>
#include <Windows.h>
#include <tlhelp32.h>
HANDLE hSnapshot = NULL;
HANDLE hProcess = NULL;
PROCESSENTRY32 pe32;
MODULEENTRY32 me32;
int iProcessCount = NULL;
int iModuleCount = NULL;
char szProcessName[256];
char szModuleName[256];
char szDumpPath[256];
BOOL bNoProcessName = NULL;
BOOL bNoModuleName = NULL;
DWORD dwBuffer;
HANDLE hToken;
TOKEN_PRIVILEGES tpToken;
LUID luid;
int main( int argc, char * argv[] )
{
printf( "*******************************************************************************\n" );
printf( "*\n* Module Dumper by blub.txt \n" );
printf( "* This Tool dumps a module of the specified process memory to a file on Hardrive*\n*\n" );
printf( "* Usage: DumpModule.exe ProcessName ModuleName DumpPath \n" );
printf( "* Example: DumpModule.exe steam.exe Steam.dll C:\\test.dump \n*\n" );
printf( "* If you don`t refer a process name you get a list of the current process, * the same with modules\n*\n" );
printf( "*******************************************************************************\n\n" );
if( argv[1] == NULL )
bNoProcessName = 1;
else
{
strcpy( szProcessName, argv[1] );
if( argv[2] == NULL )
bNoModuleName = 1;
else
{
strcpy( szModuleName, argv[2] );
strcpy( szDumpPath, argv[3] );
}
}
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hSnapshot == INVALID_HANDLE_VALUE )
{
CloseHandle( hSnapshot );
return 0;
}
pe32.dwSize = sizeof( PROCESSENTRY32 );
if( !Process32First( hSnapshot, &pe32 ) )
{
CloseHandle( hSnapshot );
return 0;
}
while( Process32Next( hSnapshot, &pe32 ) )
{
if( bNoProcessName == 1)
printf( "%s \n", pe32.szExeFile );
else if( !lstrcmp( pe32.szExeFile, szProcessName ) )
{
printf( "Process found! %s \n", szProcessName );
hProcess = OpenProcess( PROCESS_ALL_ACCESS, false, pe32.th32ProcessID );
if( OpenProcessToken( hProcess, TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken) == 0 )
{
CloseHandle( hProcess);
return 0;
}
if( ( LookupPrivilegeValue( 0, SE_SECURITY_NAME, &luid ) == 0) || ( LookupPrivilegeValue( 0, SE_DEBUG_NAME, &luid ) == 0 ) )
{
CloseHandle( hProcess );
return 0;
}
tpToken.PrivilegeCount = 1;
tpToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
tpToken.Privileges[0].Luid = luid;
AdjustTokenPrivileges( hToken, false, &tpToken, sizeof( tpToken ), NULL, 0 );
hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, pe32.th32ProcessID );
me32.dwSize = sizeof( MODULEENTRY32 );
if ( !Module32First( hSnapshot, &me32 ) )
{
CloseHandle( hSnapshot );
return 0;
}
while( Module32Next( hSnapshot, &me32) )
{
if( bNoModuleName == 1 )
printf( "%s \n", me32.szModule );
else if( !lstrcmp( me32.szModule, szModuleName ) )
{
LPVOID lpBuffer;
LPDWORD dwBytesWritten;
HANDLE hDrop;
printf( "Module found! %s \n", szModuleName );
printf( "- Base Address: 0x%x \n", me32.modBaseAddr );
printf( "- Base Size: %d \n", me32.modBaseSize );
lpBuffer = VirtualAlloc( NULL, me32.modBaseSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE );
ReadProcessMemory( hProcess, me32.modBaseAddr, lpBuffer, me32.modBaseSize, NULL );
hDrop = CreateFile( szDumpPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
if( hDrop != INVALID_HANDLE_VALUE )
{
WriteFile( hDrop, lpBuffer, me32.modBaseSize, dwBytesWritten, NULL );
}
VirtualFree( lpBuffer, NULL, MEM_RELEASE );
CloseHandle( hDrop );
CloseHandle( hSnapshot );
CloseHandle( hProcess );
return 1;
}
}
}
}
CloseHandle( hSnapshot );
Sleep( 5 );
return 1;
}
|
|
|
12/29/2015, 16:53
|
#2
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,548
Received Thanks: 333
|
alter ist in der sektion hier tote hose.... epvp geht schlafen ... wo sind die helden wie früher ^^ xD
|
|
|
12/29/2015, 17:34
|
#3
|
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
|
|
|
|
01/10/2016, 22:45
|
#4
|
elite*gold: 100
Join Date: Aug 2005
Posts: 595
Received Thanks: 208
|
Prozess öffnen
MemoryRegions abfragen
Jede Region durchgehen und den Start auf einen PE Header Checken
wenn gefunden -> Region start -> Ende Dumpen
Sollte alles Dumpen das den PE Header nicht vorsätzlich zerstört inklusive unlinked Dlls
Sollte das nich reichen musst die Regions mit Heuristik auf StandartCodeFragmente und allgemeinen PE merkmalen checken und sie nach wahrscheinlichkeit Dumpen, dürft aber für 99% der Sachen overkill sein.
|
|
|
All times are GMT +1. The time now is 03:41.
|
|