{ if(!bFetched) return; //若产生的密码尚未使用,不再产生密码,直接返回退出 bFetched=false; CString lpszCharSet; char lpszCurrentPassword[30]="\0"; CString lpszTmpCurrentPassword; GetPrivateProfileString("设置","穷举方法","数字",lpszMethod,sizeof(lpszMethod),"Setup.ini"); //得到上一次密码产生的办法,不同的办法定义不同的密码字符集,并得到相应的密码 if(strstr(lpszMethod,"数字")!=NULL) {lpszCharSet.Format ("%s","0123456789"); GetPrivateProfileString("数字","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod,"小写字母")!=NULL) {lpszCharSet.Format("%s","abcdefghijklmnopqrstuvwxyz" ); GetPrivateProfileString("小写字母","当前密码","a",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod,"大写字母")!=NULL) {lpszCharSet.Format("%s","ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); GetPrivateProfileString("大写字母","当前密码","A",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod, "大小写字母组合")!=NULL) {lpszCharSet.Format("%s","abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ; GetPrivateProfileString("大小写字母组合","当前密码","a",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod, "数字字母组合")!=NULL) {lpszCharSet.Format("%s","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ; GetPrivateProfileString("数字字母组合","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod, "所有字符")!=NULL) { lpszCharSet.Format("%s","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+`-=,./';[]\\{}|:\"<>?" ); GetPrivateProfileString("所有字符","当前密码","0",(LPTSTR)lpszCurrentPassword,sizeof(lpszCurrentPassword),"Setup.ini"); } if(strstr(lpszMethod, "数据字典")!=NULL) {unsigned long nFilePos=GetPrivateProfileInt(lpszPath,"文件指针",0,"Setup.ini");//得到上次取密码的文件指针 CFile m_file; m_file.Open (lpszPath,0,NULL); if(nFilePos==m_file.GetLength()) { m_file.Close (); m_bEnum=false; ::EnableWindow(::GetDlgItem(m_hwnd,IDOK),TRUE); ::EnableWindow(::GetDlgItem(m_hwnd,IDCANCEL),TRUE); ::EnableWindow(::GetDlgItem(m_hwnd,IDPause),FALSE); ::SetFocus(::GetDlgItem(m_hwnd,IDOK)); return ; //密码字典已经遍历完毕,停止线程枚举 } m_file.Seek (nFilePos,0); int i=0; for(;;) {m_file.Read(lpszPassword+i,1);//依次读取密码字符,跳过回车换行符 if ((char)lpszPassword[i]!=0x0d) {nFilePos++; i++; m_file.Seek (nFilePos,0); continue; } else { m_file.Close (); TCHAR lpszFilePos[10]; lpszPassword[i]='\0'; nFilePos++; nFilePos++;//进度信息存盘 _stprintf(lpszFilePos,"%d",nFilePos); WritePrivateProfileString(lpszPath,"文件指针",lpszFilePos,"Setup.ini"); WritePrivateProfileString(lpszPath,"当前穷举密码",lpszPassword,"Setup.ini"); break; } }
return; } bool bSetOk=false; lpszTmpCurrentPassword.Format("%s",lpszCurrentPassword); int nStrLen=lpszTmpCurrentPassword.GetLength (); int i=nStrLen; while (i>0) { CString CharCode=lpszTmpCurrentPassword.Mid(i-1,1); if (CharCode!=lpszCharSet.Right(1)) {int nIndex=lpszCharSet.Find(CharCode,0); CharCode=lpszCharSet.Mid (nIndex+1,1); if(i!=nStrLen)lpszTmpCurrentPassword.Format("%s%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode,lpszTmpCurrentPassword.Right(nStrLen-i)); else lpszTmpCurrentPassword.Format("%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode); WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini"); lpszTmpCurrentPassword.Format ("%s",lpszCurrentPassword); lstrcpy(lpszPassword,lpszTmpCurrentPassword,lpszTmpCurrentPassword.GetLength ()+1);
bSetOk=true; break; } else {CharCode=lpszCharSet.Left(1); if(i!=nStrLen)lpszTmpCurrentPassword.Format("%s%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode,lpszTmpCurrentPassword.Right(nStrLen-i)); else lpszTmpCurrentPassword.Format("%s%s",lpszTmpCurrentPassword.Left(i-1),CharCode); WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini"); i--; } } if(bSetOk) {
return; } lpszTmpCurrentPassword.Insert(0,lpszCharSet.Left(1)); WritePrivateProfileString(lpszMethod,"当前密码",(LPCTSTR)lpszTmpCurrentPassword,"Setup.ini"); lpszTmpCurrentPassword.Format ("%s",lpszCurrentPassword);
lstrcpyn(lpszPassword,lpszTmpCurrentPassword,lpszTmpCurrentPassword.GetLength ()+1);
return;
}
void CGetCodeDlg::OnBrowse() {CFileDialog m_FileOpen(TRUE,"*.txt","*.txt",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,NULL,NULL); TCHAR lpBuffer[MAX_PATH]; LPTSTR *lpFilePart=NULL; GetFullPathName(lpszPath,sizeof(lpBuffer),lpBuffer,lpFilePart); m_FileOpen.m_ofn.lpstrInitialDir =lpBuffer; m_FileOpen.DoModal(); m_EditPath.SetWindowText(m_FileOpen.GetPathName());
}
void CGetCodeDlg::OnRadio7() { m_EditPath.EnableWindow(TRUE); m_BtnBrowser.EnableWindow(TRUE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO7); }
void CGetCodeDlg::OnRadio1() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO1); }
void CGetCodeDlg::OnRadio2() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO2); }
void CGetCodeDlg::OnRadio3() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO3); }
void CGetCodeDlg::OnRadio4() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO4); }
void CGetCodeDlg::OnRadio5() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO5); }
void CGetCodeDlg::OnRadio6() { m_EditPath.EnableWindow(FALSE); m_BtnBrowser.EnableWindow(FALSE); CheckRadioButton(IDC_RADIO1,IDC_RADIO7,IDC_RADIO6); } |
五、程序使用说明
1.本程序仅对具有多次重试密码机会的程序有效,比如access、电子图板eb等等有效, word 、excel无效,穷举这些文件密码最好采用VBA编程。
2.密码穷举将要占用大量的系统资源,使用时尽可能少地运行应用程序,最好启动安全模式,以便使用尽可能多的线程,加快穷举进程。
3.多台微机分工穷举可以加快穷举速度。
4.对没有标题的对话框,程序要少作些改动方能穷举。
5. 本方法适用于穷举安装文件序列号和注册码。
6.本程序对汉字密码失灵,有兴趣的读者可以定义密码字符集为80~FF实现汉字密码穷举,对大字符集UNICODE, 读者可以自行扩充。