麻烦帮我看一下这段加密锁代码,怎么破解?

yschat2012 2016-08-04 10:33:43
这是一段网络应用程序的服务端,要用到注册码

并把注册码文本框映射到DDX_Text(pDX, IDC_EDIT_License, m_sLicense);
点击确定按钮注册
void CDBProxyDlg::OnOK()
m_SrvInfo->port = m_port;
m_SrvInfo->dbsrv_path = m_sDbPath.GetBuffer(0);
m_SrvInfo->dbsrv_psw = m_sPsw.GetBuffer(0);
m_SrvInfo->dbsrv_user = m_sUser.GetBuffer(0);
m_SrvInfo->dbsrv_ip = m_sDbIp.GetBuffer(0);
m_SrvInfo->sLicense = m_sLicense.GetBuffer(0);
CDialog::OnOK();
}
其他相关代码:
BOOL CSrvManager::CheckLicenseOk(CString sLicenseIn)
{
m_bTryVersion = FALSE;
m_bTryFull = FALSE;
USES_CONVERSION;
CEncryption decode;
CString sLicense;

char in[500];
char out[500];
memset(in, 0, 500);
memset(out, 0, 500);
strcpy(in,sLicenseIn);
decode.Decrypt(in,out);
sLicense = out;

CString sLIp,sLSessionNumb,sLMaxSessionUsers,sFreeUsers;
CString sTryDays,sTryStart;
int pos;
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sLIp = sLicense.Left(pos);
}
if (pos >= 0)
{
sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sLSessionNumb = sLicense.Left(pos);
}
}

if (pos >= 0)
{
sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0 )
{
sLMaxSessionUsers = sLicense.Left(pos);
m_nLMaxSessionUsers = atoi(sLMaxSessionUsers);//最大用户数
}
}

if (pos >= 0)
{
sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sFreeUsers = sLicense.Left(pos);
sFreeUsers.TrimLeft();
sFreeUsers.TrimRight();
}
}
if (pos >= 0)
{
sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0 )
{
sTryDays = sLicense.Left(pos);
sTryDays.TrimLeft();
sTryDays.TrimRight();
m_nTryDay = atoi(sTryDays);
if ( m_nTryDay> 0)
m_bTryVersion = TRUE;
}
}
if (pos >= 0)
{
sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sTryStart = sLicense.Left(pos);
sTryStart.TrimLeft();
sTryStart.TrimRight();
m_sTryStart = sTryStart;

CString str = m_sTryStart.Left(4);
int years = atoi(str);
str = m_sTryStart.Mid(4);
int m = atoi(str.Mid(2));
str = m_sTryStart.Mid(6);
int d = atoi(str);
CTime t1(years,m,d,0,0,0);
CTime t2 = CTime::GetCurrentTime();
CTimeSpan ts = t2 - t1;
if (ts.GetDays() - m_nTryDay > 0)
m_bTryFull = TRUE;
}
}

sLIp.TrimLeft();
sLIp.TrimRight();
sLIp.MakeLower();

if (m_bTryFull)
{
m_nLMaxSessionUsers = 4;//最大用户数
}
BOOL bMatch = FALSE;
CStringArray macArr;
GetAllLocalAdapterMacAddr(macArr);
for (int i =0; i < macArr.GetSize(); i ++)
{
CString sMac = macArr.GetAt(i);
if (sMac == sLIp)
{
bMatch = TRUE;
break;
}
}
return bMatch;
}


BOOL CSrvManager::CheckLicense()
{
try
{
long nAppID = 0x410541; //应用程序ID, 4字节,通过设号工具设置
long Keys[8]= {0};
long nKeyNum = 0;

BOOL ret = 1;
if( 0 != NoxFind(nAppID,Keys, &nKeyNum))
{
ret = 0 ;
return FALSE;
}

//打开第一只加密锁
char * userPin = "F6822DC1D06944FC"; //用户密码,通过设号工具设置
if( 0 != NoxOpen(Keys[0],userPin))
{
ret = 0 ;
return FALSE;
}

//存储区读(16字节)
unsigned char readStorage[16] = {0};
if( 0 != NoxReadStorage(Keys[0],readStorage))
{
ret = 0 ;
return FALSE;
}

CString sLicense = readStorage;
sLicense.MakeLower();

//关闭加密锁
NoxClose(Keys[0]);

if (!ret)
{
return FALSE;
}

CString sLSessionNumb,sLMaxSessionUsers,sLFreeUsers;
int pos;
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sLSessionNumb = sLicense.Left(pos);
}

sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sLMaxSessionUsers = sLicense.Left(pos);
}

sLicense = sLicense.Mid(pos+1);
pos = sLicense.Find(_T('|'));
if (pos >= 0)
{
sLFreeUsers = sLicense.Left(pos);
}
if (sLSessionNumb.IsEmpty() || sLMaxSessionUsers.IsEmpty())
return FALSE;

m_nLMaxSessionUsers = atoi(sLMaxSessionUsers);//最大用户数量
m_bTryVersion = FALSE;
}
catch (...)
{
return FALSE;
}
return TRUE;
}


void CServerManagerDlg::CheckLicenseStatus()
{
CSrvManager&s = CSrvManager::GetInstance();
BOOL ret = s.CheckLicense();
if (!ret)
ret = s.CheckLicenseOk(s.GetLicenseStr());
if (ret)
{
CString str;
if (s.m_nLMaxSessionUsers < 0)
{
str.Format("服务器管理器 - 注册版(无限制会议数和人数)");
}
else
{
if (!s.m_bTryVersion)
str.Format("服务器管理器 - 注册版(%d)",s.m_nLMaxSessionUsers);
else
{
if (s.m_bTryFull)
str.Format("服务器管理器 - 试用版已到期 试用了%d天",s.m_nTryDay);
else
str.Format("服务器管理器 - 试用版(%d) 试用%d天",s.m_nLMaxSessionUsers,s.m_nTryDay);
}
}
SetWindowText(str);
}
else
SetWindowText("服务器管理器 - 非注册版(会议允许最大4人)");

}

请教下面两个问题:
1、这是通过机器生成的注册码吗?怎么获取注册吗?
2、我把m_nLMaxSessionUsers = 4,改成其他数字,返回到客户端还是4,怎么回事?
...全文
166 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yschat2012 2016-08-09
  • 打赏
  • 举报
回复
谢谢!!!!
sevancheng 2016-08-04
  • 打赏
  • 举报
回复
把检查的代码去掉就ok了啊
yschat2012 2016-08-04
  • 打赏
  • 举报
回复
int GetAllLocalAdapterMacAddr(CStringArray& mac)

{
    NCB ncb;
    LANA_ENUM AdapterList;
	
    memset(&ncb, 0, sizeof(ncb));
	
    ncb.ncb_command = NCBENUM;
	
    ncb.ncb_buffer = (unsigned char *)&AdapterList;
	
    ncb.ncb_length = sizeof(AdapterList);
	
    Netbios(&ncb);
	
    mac.RemoveAll();
	
    for (int i = 0; i < AdapterList.length ; ++i )
    {
        struct ASTAT
        {
            ADAPTER_STATUS adapt;
			
            NAME_BUFFER    psz_name[30];
			
        } Adapter;
		
        // Reset the LAN adapter so that we can begin querying it
		
        NCB Ncb;
        memset( &Ncb, 0, sizeof (Ncb));
        Ncb.ncb_command  = NCBRESET;
        Ncb.ncb_lana_num = AdapterList.lana[i];
        if (Netbios(&Ncb) != NRC_GOODRET)
            continue;
		
        // Prepare to get the adapter status block
		
        memset(&Ncb, 0, sizeof(Ncb)) ;
		
        Ncb.ncb_command = NCBASTAT;
		
        Ncb.ncb_lana_num = AdapterList.lana[ i ];
		
        strcpy((char *)Ncb.ncb_callname, "*" );
		
        memset(&Adapter, 0, sizeof (Adapter));
		
        Ncb.ncb_buffer = (unsigned char *)&Adapter;
		
        Ncb.ncb_length = sizeof (Adapter);
		
        // Get the adapter's info and, if this works, return it in standard,
        // colon-delimited form. 
		CString sMac;
		CString str;
        if ( Netbios( &Ncb ) == 0 )
        {
			for (int i=0; i<6; i++)
			{
				Adapter.adapt.adapter_address[i];
				str.Format("%02x",(int)(Adapter.adapt.adapter_address[i]));
				sMac += str;
				sMac += "-";
			}
        }
        else
            break;
		sMac = sMac.Left(sMac.GetLength() - 1);
		sMac.MakeLower();
		mac.Add(sMac);
    }
	
    return 0;
	
}
yschat2012 2016-08-04
  • 打赏
  • 举报
回复
如果我想不用注册就变成正式版,怎么修改代码?谢谢!

18,357

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧