如何做网站授权?加密授权解密分享授权函数
自己辛辛苦苦写的代码,总不希望被传的满天飞(除了自己愿意公开的除外),那些有点特殊功能的程序总是要加密并做好授权,这样才能将自己的技术换个饭钱以便养活自己,那么程序猿们改如何做网站授权呢?大神可以忽略。今天分享的是别人的加密授权源码,被我解密;解密的多了,发现现在网站授权方式就那么几样,并且都是大同小异的,今天直接上代码,我们一起来研究下网站是如何进行授权加密的。
这个是个什么系统我并不清楚,没有详细跟踪,如果侵犯了您的隐私,留言我尽快删除。此系统是THINKPHP开发的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
private function showLoginAuthorize( ) { $hasChanged = $this->loginFileHasChanged( ); if ( $hasChanged ) { $AuthorizeScript = "<script>\r\n\t\t\t\$(document).ready(function(){\r\n\t\t\t\t\$('#username').attr('disabled',true);\r\n\t\t\t \t\$('#password').attr('disabled',true);\r\n\t\t\t \t\$('.buttonface').attr('disabled',true);\r\n\t\t\t \talert('非法篡改版权文件!');\r\n\t\t\t});\r\n\t\t\t</script>"; echo $AuthorizeScript; } $para = "?version=".c( "CMSVersion" )."&host=".$_SERVER['HTTP_HOST']."&os=".PHP_OS; $para .= "&cen=".c( "CMSEnName" )."&v=3"; foreach ( glob( "./Data/*.id" ) as $filename ) { $mid = basename( $filename, ".id" ); if ( !is_numeric( $mid ) ) { continue; } $para .= "&mid=".$mid; break; } $para .= "&time=".time( ); $authUrl = "http://auth.yunmb.cn/authorize.php".$para; $AuthorizeScript = "<script>\r\n\t\t\$(document).ready(function(){\r\n\t\t\tsetTimeout(function(){\r\n\t\t\t\t\$.get('".$authUrl."',null, function(data){\r\n\t\t\t\t\t\$('#AuthorizeImage').html(data['AuthorizeImage']);\r\n\t\t\t\t},'json');\r\n\t\t\t}, 300);\r\n\t\t});\r\n\t\t</script>"; echo $AuthorizeScript; } private function loginFileHasChanged( ) { $filelist[] = array( "FileName" => "./App/Tpl/Admin/Default/Public/login.html", "Md5" => array( "f8a1e021936458e1e6e46f05fc2833ce", "ee889a558b1a33a8c284413487b75a3b", "3adc8bb23ba2e896750ee2fd52d078ec", "ddab77d1a2cfbe29c305e6f070c6bc64" ) ); $filelist[] = array( "FileName" => "./Public/jquery/jquery-1.7.2.min.js", "Md5" => array( "b8d64d0bc142b3f670cc0611b0aebcae" ) ); foreach ( $filelist as $v ) { if ( !file_exists( $v['FileName'] ) ) { return FALSE; } $md5 = md5_file( $v['FileName'] ); if ( in_array( $md5, $v['Md5'] ) ) { continue; } return TRUE; } return FALSE; } private function showAuthorize( ) { $para = "?version=".c( "CMSVersion" )."&host=".$_SERVER['HTTP_HOST']."&os=".PHP_OS; $para .= "&cen=".c( "CMSEnName" )."&v=2"; foreach ( glob( "./Data/*.id" ) as $filename ) { $mid = basename( $filename, ".id" ); if ( !is_numeric( $mid ) ) { continue; } $para .= "&mid=".$mid; break; } $para .= "&time=".time( ); $authUrl = "http://auth.yunmb.cn/authorize.php".$para; $AuthorizeScript = "<script>\r\n\t\t\$(document).ready(function(){\r\n\t\t\tgetAuthorize();\r\n\t\t\tfunction getAuthorize(){\r\n\t\t\t\tjQuery.ajax({url: '".$authUrl."', type: 'GET',timeout: 15*1000,dataType:'jsonp', jsonp: 'callback',\r\n\t\t\t\tjsonpCallback:'success_jsonpcallback',success: setAuthorize});\r\n\t\t\t}\r\n\t\t\tfunction setAuthorize(data){\r\n\t\t\t\tif( jQuery('#AuthorizeText').length <= 0 ){\r\n\t\t\t\t\talert('软件未授权');return;\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif(data.data) { eval(data.data); }\r\n\t\t\t\t\tjQuery('#AuthorizeText').html(data.info);\r\n\t\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\t\tif( data.info.indexOf( jQuery('#AuthorizeText').text() ) == -1 ){ alert(data.info); }\r\n\t\t\t\t\t\tsetAuthorize(data); \r\n\t\t\t\t\t}, 1000);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t\t</script>"; echo $AuthorizeScript; } public function upgrade( ) { import( "@.Common.YdUpgrade" ); ( $this->YouDianCMSVersion ); $u = new YdUpgrade( ); $b = $u->needUpgrade( ); if ( !$b ) { $this->ajaxReturn( NULL, "已经是最新版本!", 2 ); } $b = $u->start( ); $u->deleteAll( ); if ( $b ) { $this->ajaxReturn( NULL, "升级成功!", 1 ); } else { $this->ajaxReturn( NULL, "升级失败!", 0 ); } } |
直接访问授权URL http://auth.yunmb.cn/authorize.php 返回:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$(document).ready(function(){ checkAuthorize(); function checkAuthorize(){ try{ if( $('#AuthorizeText').length <= 0 ){ alert("软件未授权"); return; }else{ $('#AuthorizeText').html("<b style='color:red;font-size:12px'>未授权,为了保障您的权益和获得更好的售后服务,请购买正式授权</b>"); } $('#AuthorizeText').parents().css({'height':'auto', 'max-height':'' }); $('#AuthorizeText').parents().show(); $('#AuthorizeText').parents().css('visibility','visible'); $('#AuthorizeText').removeAttr('style'); $('#AuthorizeText').removeAttr('class'); $('#AuthorizeText').show(); $('#AuthorizeText').css('visibility','visible'); }catch(e){ } setTimeout(function(){ checkAuthorize(); }, 100); } }); |
作者不仅对该文件进行了简单的加密,并且对文件进行了MD5加密判断,只要修改了文件内容,就无法通过授权;这个软件你也就无法使用。
尊重劳动成果,请购买正版!