⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anti_crackdlg.cpp

📁 防盗版的原理
💻 CPP
字号:
// anti_crackDlg.cpp : implementation file
//

#include "stdafx.h"
#include "anti_crack.h"
#include "anti_crackDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
  DWORD dwIDESerial;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAnti_crackDlg dialog

CAnti_crackDlg::CAnti_crackDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAnti_crackDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAnti_crackDlg)
	m_reg = _T("");
	m_info = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CAnti_crackDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAnti_crackDlg)
	DDX_Text(pDX, IDC_EDIT2, m_reg);
	DDX_Text(pDX, IDC_EDIT1, m_info);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAnti_crackDlg, CDialog)
	//{{AFX_MSG_MAP(CAnti_crackDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAnti_crackDlg message handlers

BOOL CAnti_crackDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

GetVolumeInformation("c:\\",NULL,NULL,&dwIDESerial,NULL,NULL,NULL,NULL); 
m_info=dwIDESerial;
UpdateData(FALSE);




	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 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
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CAnti_crackDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// 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 CAnti_crackDlg::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 CAnti_crackDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CAnti_crackDlg::OnOK() 
{
	// TODO: Add extra validation here
UpdateData(TRUE);

	int I;
	int A=0x01234567,B=0x89abcdef,C=0xfedcba98,D=0x76543210;
	int a,b,c,d;
	a=A;b=B;c=C;d=D;
	int input[16],order[16];
	char result[17]="";
	char words[37]="QW9ER7T0YUI8OP4ASD5FG3HJKL1Z6XCVB2NM";
	int Mask[16]={1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
 
  for(I=0;I<16;I++) //第一步,生成12个整数
  {
  input[I]=m_info/Mask[I];
  //input[I]=input[I]%37; 
  }
 
  for(I=0;I<4;I++) //第二步,经过简化的MD5加密算法
  {
    a =b+((a+((b&c)|((~b)&d)+input[I*4+0]+0xd76aa478))<<7);//第一轮
    d =a+((d+((a&b)|((~a)&c)+input[I*4+1]+0xe8c7b756))<<12);	
	c =d+((c+((d&a)|((~d)&b)+input[I*4+2]+0x242070db))<<17);
    b =c+((b+((c&d)|((~c)&a)+input[I*4+3]+0xc1bdceee))<<22);	
//FF(a,b,c,d,M0,7,0xd76aa478)
//FF(d,a,b,c,M1,12,0xe8c7b756)
//FF(c,d,a,b,M2,17,0x242070db)
//FF(b,c,d,a,M3,22,0xc1bdceee)

	a=b+((a+((b&d)|(c&(~d))+input[I*4+0]+0xf61e2562))<<5);//第二轮
	d=a+((d+((a&c)|(b&(~c))+input[I*4+1]+0xc040b340))<<9);
	c=d+((c+((d&b)|(a&(~b))+input[I*4+2]+0x265e5a51))<<14);
	b=c+((b+((c&a)|(d&(~a))+input[I*4+3]+0xe9b6c7aa))<<20);
//GG(a,b,c,d,M1,5,0xf61e2562)
//GG(d,a,b,c,M6,9,0xc040b340)
//GG(c,d,a,b,M11,14,0x265e5a51)
//GG(b,c,d,a,M0,20,0xe9b6c7aa)

    a=b+((a+(b^c^d+input[I*4+0]+0xfffa3942))<<4);//第三轮
    d=a+((d+(a^b^c+input[I*4+1]+0x8771f681))<<11);
	c=d+((c+(d^a^b+input[I*4+2]+0x6d9d6122))<<16);
	b=c+((b+(c^d^a+input[I*4+3]+0xfde5380c))<<23);
//HH(a,b,c,d,M5,4,0xfffa3942)
//HH(d,a,b,c,M8,11,0x8771f681)
//HH(c,d,a,b,M11,16,0x6d9d6122)
//HH(b,c,d,a,M14,23,0xfde5380c)

    a=b+((a+(c^(b|(~d))+input[I*4+0]+0xf4292244))<<6);//第四轮
    d=a+((d+(b^(a|(~c))+input[I*4+1]+0x432aff97))<<10);
	c=d+((c+(a^(d|(~b))+input[I*4+2]+0xab9423a7))<<15);
	b=c+((b+(d^(c|(~a))+input[I*4+3]+0xfc93a039))<<21);
//II(a,b,c,d,M0,6,0xf4292244)
//II(d,a,b,c,M7,10,0x432aff97)
//II(c,d,a,b,M14,15,0xab9423a7)
//II(b,c,d,a,M5,21,0xfc93a039)

input[I*4+0]=a;
input[I*4+1]=b;
input[I*4+2]=c;
input[I*4+3]=d;
  }

  for(I=0;I<16;I++) //第三步,转化为0-35的整数
  {
  input[I]=input[I]%36; 
  if(input[I]<0)
  input[I]=-input[I];
  }
  
  int Index[16]={7,15,5,10,3,13,1,6,12,11,8,4,2,9,14,0};
  int in=0;

  for(I=0;I<16;I++)//第四步,错序操作 
  { 
	//  if((I+1)%5==0&&I>=4)
	//  {
		 // result[I]='-';
//	  }else
//	  {
		order[I]=input[Index[I]]; 
//	  in++;
//	  }
  }

   for(I=0;I<16;I++)//第五步,根据字符表生成注册码 
  { 
   result[I]=words[order[I]];
   }

  result[16]='\0';
  m_reg=result;
   UpdateData(FALSE);

//}else MessageBox("请输入用户名!",NULL,MB_ICONERROR);
}

/*
char words[37]="QW9ER7T0YUI8OP4ASD5FG3HJKL1Z6XCVB2NM";  
char user[17];
int Index[16]={15,7,13,5,12,3,8,1,11,14,4,10,9,6,15,2,0};
int com[16];
 int n; 
 int uinput[16];

	for(n=0;n<16;n++)
 {
	  for(I=0;I<36;I++)
  {
    if(words[I]==user[n])
         uinput[16]=words[I]
  }
 }
 
 for(I=0;I<16;I++)//第四步,反错序操作 
  { 

		com[I]=uinput[Index[I]]; 

  }
*/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -