cs_jibus
Messages postés17Date d'inscriptionsamedi 24 janvier 2004StatutMembreDernière intervention31 mars 2008
-
9 avril 2006 à 02:24
cs_jibus
Messages postés17Date d'inscriptionsamedi 24 janvier 2004StatutMembreDernière intervention31 mars 2008
-
9 avril 2006 à 17:17
Salut à tous,
Je suis en train de faire un débuggeur en MFC et j'aimerai savoir comment il est possible d'obtenir et d'afficher le code assembleur d'un exe. En gros comment je peux desassembler un exe quoi
Merci d'avance ;)
@++
platon179
Messages postés237Date d'inscriptionlundi 20 mai 2002StatutMembreDernière intervention22 juillet 20112 9 avril 2006 à 08:57
Salut :)
Tu dois étudier le format des instructions de la machine sur laquelle tu travailles (Intel/AMD je suppose)... Sache que c'est pas simple du tout, mais une fois qu'on a compris le fonctionnement de base, ca va tout seul... Va aussi falloir étudier le format des exécutables Win32, il y a quelques codes sur ce sujet sur cppfrance... Il existe toute une floppée de sites aussi, en voici l'un ou l'autre :
Format des instructions Intel :
www.sandpile.org
www.x86.org (pour les manuels Intel techniques officiels, en 3 volumes, le dernier est le plus intéressant pour toi ;) )
Format PE (.exe de windows) :
www.wotsit.org
www.xbdev.net
Taron31
Messages postés199Date d'inscriptionvendredi 16 avril 2004StatutMembreDernière intervention28 février 2008 9 avril 2006 à 13:17
En addition à ce que Platon a dit, voici un petit code pour te donner une idée de démarrage (j'espère que ça peut aider). il s'agit d'une comparaison d'opcodes dans une DLL, je pense 'donc pas sûr) que ça doit être a peu de choses près le même esprit lorsque tu désassemble un .exe :
#include <Windows.h>
#include <stdio.h>
void usage();
DWORD GetRegNum(char *reg);
void findjmp(char *dll,char *reg);
/*
This finds useful jump points in a dll. Once you overflow a buffer, by
looking in the various registers, it is likely that you will find a
reference to your code. This program will find addresses of suitible
addresses of eip that will return to your code.
*/
int main(int argc, char **argv)
{
char dll[512], //holder for the dll to look in
reg[512]; // holder for the register
/*base pointer for the loaded DLL*/
HMODULE loadedDLL;
/*current position within the DLL */
BYTE *curpos;
/* decimal representation of passed register */
DWORD regnum=GetRegNum(reg);
/*accumulator for addresses*/
DWORD numaddr=0;
/*check if register is useable*/
if(regnum == -1)
{
/*it didn't load, time to bail*/
printf("There was a problem understanding the register.\n"\
"Please check that it isa correct IA32 register name\n"\
"Currently supported are:\n "\
"EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBP\n"\
);
exit(-1);
}
loadedDLL=LoadLibraryA(dll);
/* check if DLL loaded correctly*/
if(loadedDLL == NULL)
{
/*it didn't load, time to bail*/
printf("There was a problem Loading the requested DLL.\n"\
"Please check that it is in your path and readable\n" );
exit(-1);
}
else
{
/*we loaded the dll correctly, time to scan it*/
printf("Scanning %s for code useable with the %s register\n",
dll,reg);
/*set curpos at start of DLL*/
curpos=(BYTE*)loadedDLL;
__try
{
while(1)
{
/*check for jmp match*/
if(!memcmp(curpos,jmppat[regnum],2))
{
/* we have a jmp match */
printf("0x%X\tjmp %s\n",curpos,reg);
numaddr++;
}
/*check for call match*/
else if(!memcmp(curpos,callpat[regnum],2))
{
/* we have a call match */
printf("0x%X\tcall %s\n",curpos,reg);
numaddr++;
}
/*check for push/ret match*/
else if(!memcmp(curpos,pushretpat[regnum],2))
{
/* we have a pushret match */
printf("0x%X\tpush %s - ret\n",curpos,reg);
numaddr++;
}
curpos++;
}
}
__except(1)
{
printf("Finished Scanning %s for code useable with the %s register\n",
dll,reg);
printf("Found %d usable addresses\n",numaddr);
}
}
Avec ce code tu peux reconnaître des instructions ASM dans une DLL, donc si ça peut t'être utile...
Source : la source n'est pas de moi, elle est tirée du livre Stratégies Anti-Hackers (Eyerolles) ___________________
MVS - Most Valuable Student ( Microsoft)
cs_jibus
Messages postés17Date d'inscriptionsamedi 24 janvier 2004StatutMembreDernière intervention31 mars 2008 9 avril 2006 à 17:17
Merci pour vos réponses ;)
Le format PE j'avais déjà regardé et implémenter dans mon application une vue qui me décrivait tout le header.
Sinon pour le reste de vos infos et bien je vais me pencher dessus et voir ce que je peux en tirer
A bientot ++