前往Shuct.Net首页

Shudepb PB反编译专家长时间以来,为业内同类软件事实上的唯一选择.细节,彰显专业.态度,决定品质.

关于PBKILLER的搜索

如何用PBNI实现软件注册授权控制2 - 笑傲江湖博客-揭秘互联网,关注互联网络的IT博客 - 笑傲江湖传 - 和讯博客 个人门户 搜索用户 和讯首页 写博客 消息 通知 账号 设置 退出 快速注册 登录 http://hexun.com/lovebeijingforever > 复制 > 收藏 | 手机看个人门户 笑傲江湖博客-揭秘互联网,关注互联网络的IT博客 弃我去者,昨日之日不可留。乱我心者,今日之日多烦忧。 个人门户 博客 微博 相册 音乐 转帖 邮箱 朋友圈 关注 留言 理财--> 进入我的家 载入中 自定义HTML载入中... 快速链接 [和讯博客] [发表文章] [博客设置] [文章管理] 搜索 精华推荐 红二代在干啥 字画改变曾国藩 年轻的王夫人 陪酒女维权事件 毛为何非搞文革 日本如何扫黄 特招入伍的女星 朝鲜集中营内幕 >更多美图 政协为何成藏污纳诟的场所 历数乌克兰政坛中的各种逆袭 经适房何以成了官适房 王石这个大土豪为什么成不了贵族 美女委员一天换几套衣服给谁看 中国人热衷奢侈品消费为哪般 >更多文章 如何用PBNI实现软件注册授权控制2 [原创 2011-12-24 19:32:59] 字号:大 中 小 接着上一篇如何用PBNI实现软件注册授权控制,即然PB程序采用调用DLL文件的方式来进行软件注册授权控制,很容易被绕开,那么该如何解决这一问题呢? 从PB9 开始,增加了PBNI功能,可以直接采用VC来编写可视和不可视的组件给PB的应用程序调用,以实现PB应用功能的扩展.采用这种技术架构,可以非常方便 的把原来的VC中的功能,封装为PB的可视对象或不可视对象,给PB的应用程序使用,而不需要在程序中定义各种API函数.而且由于PBNI编译后的 PBD文件,并不是使用PB的代码指令,用PBKILLER和Shudepb都无法对期进行反编译,可以有效的保护软件系统核心部分代码的安全. 下面,我们采用VC6来开发一个PBNI组件,用于封装上一篇文件中所实现的CheckKey和Add函数功能.(如果是PB9,则建议采用VC6作为开发环境,如果是PB10以上版本,则建议采用VS2003作为开发环境.) 配置开发环境 首先,按照帮助文件的说明,配置VC6的开发环境,以便使用PBNI的应用向导,以及向开发环境增加PBNI的头文件和库文件的目录. 1. 把C:\Program Files\Sybase\PowerBuilder 9.0\SDK\PBNI\wizards\pbext.awx文件拷到C:\Program Files\Microsoft Visual Studio\COMMON\MSDev98\Bin\IDE目录,以便在VC6中可以使用PBNI应用程序向导. 2.打开VC6,选择工具---选择---目录,增加以下选项. C:\Program Files\Sybase\PowerBuilder 9.0\SDK\PBNI\include C:\Program Files\Sybase\PowerBuilder 9.0\SDK\PBNI\Lib 新建一个PBNI工程 1.文件---新建---工程,选择PBNI Extension App Wizard,输入工程名称,选择工程的保存路径,按确定. 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="width: 598px; height: 392px;" src="http://photo20.hexun.com/p/2011/1224/463009/b_2DDDCBE30A53BDD76CC0589A5F8664D5.jpg" alt="如何用PBNI实现软件注册授权控制2" border="0"> 2.输入对象名称,n_cst_service,由于VC6的向导只能增加不可视对象,所以该对象最好生成的是不可视对象组件. 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="width: 598px; height: 463px;" src="http://photo20.hexun.com/p/2011/1224/463009/b_E35ACF6B17309AB7D3BE0C74EB4B11A3.jpg" alt="如何用PBNI实现软件注册授权控制2" border="0"> 3.按完成,向导出自动生成PBNI所需要的各种全局函数,并增加了n_cst_Service这个不可视对象的定义,以及相对应的VC类对 象.向导会为n_cst_Service增加SampleMethod1和SampleMethod2两个函数,这两个函数没什么意义,需要把它改成需要 的CheckKey的Add函数. 实现对象功能 1.打开PBX_GetDescription函数,定义生成PB对象的描述定义.向导生成的n_cst_service对象的代码如下: 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" id="Code_Closed_Image_104019" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11">0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="display: none;" id="Code_Open_Image_104019" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11">CodePBXEXPORT LPCTSTR PBXCALL PBX_GetDescription(){ static const TCHAR class_descs[] = { "class n_cst_service from nonvisualobject\n" // TODO : Add in your PBNI class functions here. "function long SampleMethod1()\n" "function long SampleMethod2()\n" "end class\n" }; return class_descs;} 把SmpleMethod1和SampleMethod2删除掉,并增加CheckKey和Add函数的定义,n_cst_service的描述定义最后为: 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" id="Code_Closed_Image_103946" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11">0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="display: none;" id="Code_Open_Image_103946" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11"> CodePBXEXPORT LPCTSTR PBXCALL PBX_GetDescription(){ static const TCHAR class_descs[] = { "class n_cst_service from nonvisualobject\n" // TODO : Add in your PBNI class functions here. "function boolean CheckKey(string key)\n" "function int Add(int a , int b )\n" "end class\n" }; return class_descs;} 2.打开n_cst_service.h文件,修改n_cst_service对应的vc类的定义,删除SampleMethod1和SampleMethod2函数的定义,并增加ChcekKey和Add函数的定义,最后代码如下 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" id="Code_Closed_Image_103854" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11">0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="display: none;" id="Code_Open_Image_103854" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11">Codeclass Cn_cst_service : public IPBX_NonVisualObject{ enum MethodIDs { mid_CheckKey = 0, mid_Add = 1 }; virtual void Destroy();public: Cn_cst_service(); Cn_cst_service(IPB_Session* pIPB_Session, pbobject pbobj); ~Cn_cst_service(); // IPBX_UserObject methods. PBXRESULT Invoke ( IPB_Session *session, pbobject obj, pbmethodID mid, PBCallInfo *ci ); protected: PBXRESULT CheckKey ( IPB_Session *session, pbobject obj, PBCallInfo *ci ); PBXRESULT Add ( IPB_Session *session, pbobject obj, PBCallInfo *ci ); 3.打开n_cst_service.cpp文件,同样删除向导生成的函数,并增加CheckKey和Add函数的功能,最后生成的代码如下: 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" id="Code_Closed_Image_113255" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11">0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="display: none;" id="Code_Open_Image_113255" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11">Code// IPBX_UserObject method.PBXRESULT Cn_cst_service::Invoke( IPB_Session *session, pbobject obj, pbmethodID mid, PBCallInfo *ci){ PBXRESULT pbrRet = PBX_E_INVOKE_FAILURE; // First assume function associated with "mid" is not found. if (mid == mid_CheckKey) { pbrRet = (PBXRESULT)CheckKey ( (IPB_Session*)session, (pbobject)obj, (PBCallInfo*)ci ); } if (mid == mid_Add) { pbrRet = (PBXRESULT)Add ( (IPB_Session*)session, (pbobject)obj, (PBCallInfo*)ci ); } return pbrRet;}// PB callable Cn_cst_service method.PBXRESULT Cn_cst_service::CheckKey( IPB_Session *session, pbobject obj, PBCallInfo *ci){ PBXRESULT pbrRet = PBX_OK; LPCSTR key =session->GetString( ci->pArgs->GetAt(0)->GetString() ); //取传入的参数 if(strcmp(key,"12345678")==0) { ci -> returnValue -> SetBool(true); //设置返回值 } else { ci -> returnValue -> SetBool(false); } return pbrRet;}// PB callable Cn_cst_service method.PBXRESULT Cn_cst_service::Add( IPB_Session *session, pbobject obj, PBCallInfo *ci){ PBXRESULT pbrRet = PBX_OK; int a, b, result; a =(int)ci->pArgs->GetAt(0)->GetInt(); b =(int)ci->pArgs->GetAt(1)->GetInt(); result = a+b; ci -> returnValue -> SetInt(result); return pbrRet;} 4.编译程序,生成pbx文件. 5.用pbx2pbd90程序,生成pb应用程序使用的pbd文件. pbx2pbd90 {dir}\PBNI_Test.pbd {dir}\PBNI_Test.PBX 引用程序 1.把PBNI_Test.PBX和PBNI_Test.PBD拷贝到pb程序应用的目录下,用pb9打开应用程序,,在程序的库文件列表中增中上面生成的PBD文件. 2.打开w_main窗口,CheckKey按钮的代码更改为: 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" id="Code_Closed_Image_113445" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11">0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" style="display: none;" id="Code_Open_Image_113445" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11">CodeCoden_cst_service n_servicen_service = Create n_cst_service IF n_service.CheckKey("12345678") Then MessageBox("提示1","注册码12345678正确!")ELSE MessageBox("提示1","注册码12345678错误!")END IFIF n_service.CheckKey("abcdefg") Then MessageBox("提示2","注册码abcdefg正确!")ELSE MessageBox("提示2","注册码abcdefg错误!")END IFDestroy n_service Add按钮的代码更改为: n_cst_service n_servicen_service = Create n_cst_service MessageBox('Add计算',"100+30="+string(n_service.Add(100,30)))Destroy n_service 3.运行程序,点击CheckKey按钮,弹出下面两个窗口< 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" src="http://photo20.hexun.com/p/2011/1224/463009/b_79C4FB257FF26AC2F69D3AD576C61F92.jpg" alt="如何用PBNI实现软件注册授权控制2" border="0"> 0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" src="http://photo20.hexun.com/p/2011/1224/463009/b_B6835FCEACCBEFBB39947357AFFD28D3.jpg" alt="如何用PBNI实现软件注册授权控制2" border="0"> 点击Add按钮,弹出下面窗口.0 && image.height>0){if(image.width>=700){this.width=700;this.height=image.height*700/image.width;}}" src="http://photo20.hexun.com/p/2011/1224/463009/b_D59A17CFEED3A3F291B7E43967255943.jpg" alt="如何用PBNI实现软件注册授权控制2" border="0"> 4.使用PBKILLER打开上面生成的pbd文件,显示错误信息,不能被反编译. 后注 使用PBNI可以防止代码被PBKILLER和shudepb反编译,也可以防止直接采用dll的方式,被直接绕开的情况,相对要安全 一点.但这种安全也是相对的,所以一般还需要在程序增加对这个pbd文件进行验证,如根据文件的MD5值,确定该文件没有被修改或被替换. 标签: 收藏 分类: 知道问问 将本文分享至: 阅读() | 评论() | 转帖 | 推荐 | 举报 我 顶 !觉得精彩就顶一下,顶的多了,文章将出现在更重要的位置上。 下一篇: PB与.net结合,开发三层架构的应用. 上一篇: 如何用PBNI实现软件注册授权控制 评论 评论正在加载中... 发表评论 大 名: [登录] [注册成为和讯用户] (不填写则显示为匿名者) 网 址: (您的网址,可以不填) 标 题: 内 容: 字数上限为2000字 请根据下图中的字符输入验证码: 0 点这里显示验证码。 (您的评论将有可能审核后才能发表) 和讯个人门户 v1.0 | 和讯博客 | 意见反馈 黑名单 求关注 设置分组 设置分组 已成功添加“叶檀”到 6 个分组 创建新分组 保存 取消 请不要超过6个字 取消 保存 --> 推荐好的资源