?? smbcrackdlg.cpp
字號:
// SMBCrackDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SMBCrack.h"
#include "SMBCrackDlg.h"
#include "CrackPwd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////
//Global viriable
extern "C"
{
UINT uCrackMode;FILE * fDictionary;
char * szCharSet,sz_CharSet[256];
int * iCurPwd,i_CurPwd[MAX_PWD_LEN+1];
int nCharSetLen;
int nMaxPwdLen,nCurPwdLen;
char szCrackedPwd[MAX_PWD_LEN+1];
char szPwdShot[MAX_PWD_LEN+1];
int nResources,nCracked;
int iCurResource,nNewPwd;
int iStartYear,iEndYear;
int iCurYear,iCurMonth,iCurDay;
int iYearFmt,iMonthFmt,iDayFmt;
CrackResource * Resources;
}
/////////////////////////////////////////////////////////////////////////////
// CSMBCrackDlg dialog
CSMBCrackDlg::CSMBCrackDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSMBCrackDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSMBCrackDlg)
m_vEndYear = 1980;
m_vStartYear = 1970;
m_vPwdLength = 4;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CSMBCrackDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSMBCrackDlg)
DDX_Control(pDX, IDC_ENDYEAR, m_cEndYear);
DDX_Control(pDX, IDC_USERNAME, m_cUserName);
DDX_Control(pDX, IDC_USEDICTIONARY, m_cUseDictionary);
DDX_Control(pDX, IDC_UPPERLETTER, m_cLetter);
DDX_Control(pDX, IDC_THREADS, m_cThreads);
DDX_Control(pDX, IDC_SYMBOL, m_cSymbol);
DDX_Control(pDX, IDC_STATUS, m_cStatus);
DDX_Control(pDX, IDC_STARTYEAR, m_cStartYear);
DDX_Control(pDX, IDC_STARTSPIN, m_cStartSpin);
DDX_Control(pDX, IDC_RESOUCE, m_cResource);
DDX_Control(pDX, IDC_REMOVE, m_cRemove);
DDX_Control(pDX, IDC_NUMBER, m_cNumber);
DDX_Control(pDX, IDC_MAXTHREADS, m_cMaxThreads);
DDX_Control(pDX, IDC_ENDSPIN, m_cEndSpin);
DDX_Control(pDX, IDC_DICTIONARYFILE, m_cDictionaryFile);
DDX_Control(pDX, IDC_DATE, m_cDate);
DDX_Control(pDX, IDC_CRACK, m_cCrack);
DDX_Control(pDX, IDC_CLEAR, m_cClear);
DDX_Control(pDX, IDC_BROWSE, m_cBrowse);
DDX_Control(pDX, IDC_ADD, m_cAdd);
DDX_Text(pDX, IDC_ENDYEAR, m_vEndYear);
DDV_MinMaxInt(pDX, m_vEndYear, STARTYEAR, ENDYEAR);
DDX_Text(pDX, IDC_STARTYEAR, m_vStartYear);
DDV_MinMaxInt(pDX, m_vStartYear, STARTYEAR, ENDYEAR);
DDX_Text(pDX, IDC_PWDLENGTH, m_vPwdLength);
DDV_MinMaxInt(pDX,m_vPwdLength,1,MAX_PWD_LEN);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSMBCrackDlg, CDialog)
//{{AFX_MSG_MAP(CSMBCrackDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CRACK, OnCrack)
ON_WM_TIMER()
ON_WM_CLOSE()
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_USEDICTIONARY, OnUsedictionary)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_RESOUCE, OnEndlabeleditResouce)
ON_BN_CLICKED(IDC_CLEAR, OnClear)
ON_BN_CLICKED(IDC_DATE, OnDate)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_RESOUCE, OnItemchangedResouce)
ON_WM_CTLCOLOR()
ON_MESSAGE(UM_CRACKDONE,CrackDone)
ON_MESSAGE(UM_CRACKOUT,CrackOut)
ON_MESSAGE(UM_ENUMOUT,EnumOut)
ON_MESSAGE(WM_HOTKEY,OnHotkey)
ON_EN_CHANGE(IDC_ENDYEAR, OnChangeEndyear)
ON_EN_CHANGE(IDC_STARTYEAR, OnChangeStartyear)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSMBCrackDlg message handlers
BOOL CSMBCrackDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
::RegisterHotKey(m_hWnd,0x4321,MOD_SHIFT|MOD_ALT,'K');
m_vThreads=0;
m_vEnums=0;
szCharSet=sz_CharSet+1;
iCurPwd=i_CurPwd+1;
m_cUserName.SetWindowText("Guest");
m_cMaxThreads.SetRange(MINTHREADS,MAXTHREADS,TRUE);
m_cMaxThreads.SetPos(10);
m_vMaxThreads=10;
LV_COLUMN ResourceColumn;
ResourceColumn.mask=LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH;
ResourceColumn.fmt=LVCFMT_LEFT;
ResourceColumn.cx=110;
ResourceColumn.pszText="Resource";
ResourceColumn.iSubItem=0;
m_cResource.InsertColumn(0,&ResourceColumn);
ResourceColumn.cx=60;
ResourceColumn.pszText="Password";
ResourceColumn.iSubItem=1;
m_cResource.InsertColumn(1,&ResourceColumn);
m_cStartSpin.SetRange(STARTYEAR,ENDYEAR);
m_cEndSpin.SetRange(STARTYEAR,ENDYEAR);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSMBCrackDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSMBCrackDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CSMBCrackDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if(m_vThreads|m_vEnums)
return;
::UnregisterHotKey(m_hWnd,0x4321);
CDialog::OnClose();
}
void CSMBCrackDlg::OnHotkey(UINT wParam, LONG lParam)
{
if(wParam!=0x4321)
return;
if(IsWindowVisible( ))
ShowWindow(SW_HIDE);
else
{
ShowWindow(SW_MINIMIZE);
ShowWindow(SW_SHOW);
ShowWindow(SW_RESTORE);
}
}
void CSMBCrackDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
char szThreads[20];
if(pScrollBar)
{
if((pScrollBar->GetDlgCtrlID())==IDC_MAXTHREADS)
{
m_vMaxThreads=((CSliderCtrl*)pScrollBar)->GetPos();
sprintf(szThreads,"%d threads",m_vMaxThreads);
m_cThreads.SetWindowText(szThreads);
}
}
}
void CSMBCrackDlg::OnUsedictionary()
{
// TODO: Add your control notification handler code here
m_cBrowse.EnableWindow(m_cUseDictionary.GetCheck());
m_cDictionaryFile.EnableWindow(m_cUseDictionary.GetCheck());
}
void CSMBCrackDlg::OnBrowse()
{
// TODO: Add your control notification handler code
OPENFILENAME ofn;
char szFilter[]="Dictionary file(*.DIC)%*.DIC%Text file(*.TXT)%*.TXT%All file%*.*%";
char szTitle[]="Choose dictionary file";
char szFullFileName[256]="",*Strh,*Strt;
int iResult;
Strh=szFilter;
while(Strt=strchr(Strh,'%'))
{
Strh=Strt+1;
*Strt=0;
}
ofn.lStructSize=sizeof(OPENFILENAME);
ofn.hwndOwner=m_hWnd;
ofn.hInstance=NULL;
ofn.lpstrFilter=szFilter;
ofn.lpstrCustomFilter=NULL;
ofn.nFilterIndex=1;
ofn.lpstrFile=szFullFileName;
ofn.nMaxFile=sizeof(szFullFileName);
ofn.lpstrFileTitle=NULL;
ofn.lpstrInitialDir=NULL;
ofn.lpstrTitle=szTitle;
ofn.Flags=OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;
ofn.lpstrDefExt=NULL;
ofn.lpfnHook=NULL;
if(iResult=GetOpenFileName(&ofn))
{
m_cDictionaryFile.SetWindowText(szFullFileName);
}
}
void CSMBCrackDlg::OnAdd()
{
// TODO: Add your control notification handler code here
LV_ITEM ResourveItem;
char szNewResource[20]="New resource";
int idxItem;
idxItem=m_cResource.GetItemCount();
ResourveItem.mask=LVIF_TEXT;
ResourveItem.iItem=idxItem;
ResourveItem.iSubItem=0;
ResourveItem.pszText=szNewResource;
ResourveItem.state=LVIS_FOCUSED;
m_cResource.InsertItem(&ResourveItem);
m_cRemove.EnableWindow(TRUE);
m_cClear.EnableWindow(TRUE);
m_cResource.SetFocus();
m_cResource.EditLabel(idxItem);
}
void CSMBCrackDlg::OnRemove()
{
// TODO: Add your control notification handler code here
int iCurItem=-1,nDeleted=0;
m_cResource.SetRedraw(0);
while((iCurItem=m_cResource.GetNextItem(iCurItem,
LVNI_SELECTED))!=-1)
{
nDeleted++;
m_cResource.DeleteItem(iCurItem);
iCurItem--;
}
if(!nDeleted)
m_cResource.DeleteItem(m_cResource.GetNextItem(-1,LVNI_FOCUSED));
iCurItem=m_cResource.GetItemCount()>0;
m_cClear.EnableWindow(iCurItem);
m_cRemove.EnableWindow(iCurItem);
m_cResource.SetFocus();
m_cResource.SetRedraw(1);
}
void CSMBCrackDlg::OnClear()
{
// TODO: Add your control notification handler code here
int iCurItem=-1,nCleared=0;
m_cResource.SetRedraw(0);
while((iCurItem=m_cResource.GetNextItem(iCurItem,LVNI_SELECTED))!=-1)
{
nCleared++;
m_cResource.SetItemText(iCurItem,1,"");
}
if(!nCleared)
m_cResource.DeleteItem(m_cResource.GetNextItem(-1,LVNI_FOCUSED));
m_cResource.SetFocus();
m_cResource.SetRedraw(1);
}
void CSMBCrackDlg::OnDate()
{
// TODO: Add your control notification handler code here
m_cStartYear.EnableWindow(m_cDate.GetCheck());
m_cEndYear.EnableWindow(m_cDate.GetCheck());
}
void CSMBCrackDlg::OnCrack()
{
HANDLE hThread;
DWORD CrackThread;
int i;
char szDictionaryFile[256];
if(m_vThreads)
{
SetEvent(m_vCrackStruct.hStopCrack);
m_cCrack.EnableWindow(FALSE);
return;
}
if(i=PrepareResource())
{
if(i==1)
{
m_cStatus.SetWindowText("No remote resource. Ready...");
return;
}
if(i==2)
{
m_cStatus.SetWindowText("Too many resource to crack. Ready...");
return;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -