Print the name of all dll output tables in the folder

Source: Internet
Author: User

Today, we reverse crack the account and password saved in the firefox browser, because firefox constantly improves the security of account information, therefore, an export function used in the previous cracking is not encapsulated into that dll, but there are many dll files in the firefox installation directory, it is too troublesome to use the loadPe tool one by one, so I wrote a small program to traverse all the dll export tables in the folder and print them out.

Header file:

#include 
 
  #include 
  
   #include 
   
    #pragma comment(lib, "imagehlp.lib ")
   
  
 
Implementation functions:

void ShowExportFuncsInfo( char* szName ){HANDLE hFile;HANDLE hMapping;LPVOID ImageBase;DWORD dwDataStartRVA;PIMAGE_DOS_HEADER  pDH;PIMAGE_NT_HEADERS pNtH= NULL;PIMAGE_OPTIONAL_HEADER pOH= NULL;PIMAGE_EXPORT_DIRECTORY pExportDir= NULL;PDWORD                  pdwRvas, pdwNames;PWORD                   pwOrds;UINT                    iNumOfName=0;char*szFuncName; BOOL                    bIsByName=FALSE;;hFile=CreateFile(szName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0);if (!hFile)   return ;hMapping=CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL);if(!hMapping){CloseHandle(hFile);return ;}ImageBase=MapViewOfFile(hMapping,FILE_MAP_READ,0,0,0);    if(!ImageBase){CloseHandle(hMapping);CloseHandle(hFile);return ;}pDH=(PIMAGE_DOS_HEADER)ImageBase;if(pDH->e_magic!=IMAGE_DOS_SIGNATURE)return ;    pNtH=(PIMAGE_NT_HEADERS32)((DWORD)pDH+pDH->e_lfanew);    if (pNtH->Signature != IMAGE_NT_SIGNATURE )        return ;pOH=&pNtH->OptionalHeader;if(!pOH)return ;    dwDataStartRVA=pOH->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;if(!dwDataStartRVA)        return ;pExportDir=(PIMAGE_EXPORT_DIRECTORY)ImageRvaToVa(pNtH,ImageBase,dwDataStartRVA, NULL);if(!pExportDir)return ;pwOrds    = (PWORD)ImageRvaToVa(pNtH,  ImageBase,pExportDir->AddressOfNameOrdinals, NULL);pdwRvas   = (PDWORD)ImageRvaToVa(pNtH, ImageBase,pExportDir->AddressOfFunctions, NULL);pdwNames  = (PDWORD)ImageRvaToVa(pNtH, ImageBase,pExportDir->AddressOfNames, NULL);iNumOfName=pExportDir->NumberOfNames;for(int i=0;i
 
  NumberOfFunctions;i++){if(*pdwRvas){    for(int j=0;j
  
   Base+i), (*pdwRvas), szFuncName);}++pdwRvas;}if(ImageBase)UnmapViewOfFile(ImageBase);if(hMapping)CloseHandle(hMapping);if(hFile)CloseHandle(hFile);}
  
 
Call the function:

int main(){WIN32_FIND_DATA FindData;HANDLE hFind;char FilePathName[MAX_PATH];char FullPathName[MAX_PATH];if (__argc !=2){return 0;}strcpy(FilePathName, __argv[1]);strcat(FilePathName, "\\*.dll");hFind = FindFirstFile(FilePathName, &FindData);if (hFind == INVALID_HANDLE_VALUE){return 0;}while(::FindNextFile(hFind, &FindData)){if (strcmp(FindData.cFileName, ".") == 0 || strcmp(FindData.cFileName, "..") == 0 ){continue;}if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){continue;}sprintf(FullPathName, "%s\\%s", __argv[1],FindData.cFileName);printf("\n%s\n", FullPathName);ShowExportFuncsInfo(FullPathName);}getchar();return 0;}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.