Posted August 31, 201311 yr Hello! I want to get the sections of an executable (.text, .rdata, etc). With PEiD it's easy to dump them, but programming it's more difficult. Anybody knows how to do so in .NET? Thanks so much!
August 31, 201311 yr Check out my post here:http://forum.tuts4you.com/topic/26862-net-directory-flags/?p=127022
September 1, 201311 yr Author @xsp!d3r Is there any documentation for this library?@atom0s This gets the data only for .NET applications. I mean for all types of applications in any language.
September 1, 201311 yr This is code in C, but it could help... IMAGE_DOS_HEADER *pdh; IMAGE_NT_HEADERS *pnth; IMAGE_SECTION_HEADER *psh; pdh=(IMAGE_DOS_HEADER*)((DWORD)pFileInfo->lpFile); //start of file = DOS HEADER if(pdh->e_magic!=IMAGE_DOS_SIGNATURE) //check if it's a good MZ signature return false; pnth=(IMAGE_NT_HEADERS*)((DWORD)pFileInfo->lpFile+pdh->e_lfanew); //NT HEADER is file + e_lfanew if(IsBadReadPtr(pnth, 4)) //check if its a readable pointer return false; if(pnth->Signature!=IMAGE_NT_SIGNATURE) //check NT signature return false; if(pnth->FileHeader.Machine!=IMAGE_FILE_MACHINE_I386) //check x32 return false; psh=IMAGE_FIRST_SECTION(pnth); //little macro for section headerwhen you have IMAGE_SECTION_HEADER, you can dump the sections using the raw address (file+raw address) and the raw size.Another trick I saw (in Armadillo) to get the section header is:psh=(IMAGE_SECTION_HEADER*)pnth[1];
September 1, 201311 yr Author Oh I found NetPE app from Ki! which does exacly that. Thanks everyone for help!
September 2, 201311 yr @xsp!d3r Is there any documentation for this library? @atom0s This gets the data only for .NET applications. I mean for all types of applications in any language. You can just remove the managed check: // Is this managed? bool bIsManaged = (imgNtHeaders.OptionalHeader.DataDirectory[HeaderHelper.IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR].Size > 0); if (!bIsManaged) { // invalid file.. throw new Exception("Invalid PE file... file is not managed."); }
September 5, 201311 yr Oh I found NetPE app from Ki! which does exacly that. Thanks everyone for help! Did you mean this http://netpe.codeplex.com/
Create an account or sign in to comment