网页设计版权保护的代码,拒绝修改版权链接

更新时间:2018-10-06 分类:设计主题 浏览量:4546

网页设计或者说网站建设都是很辛苦的一件事情。如果非商业需求,真的建议不要随便删除他人的版权链接。目前开源程序有很多,免费网站主题也很多,有许多开源程序或是网站主题都有要求保留版权链接,但是,大多数还是喜欢私下删除链接。其实如果不是影响很大,或者非其得不已的原因,真的还是保留版权链接比较好。

在很多程序和 WordPress 模板都会各种加密的设置来版权保护。包括一些免费的商业程序,个人使用,都是要求保留他的网站链接。

无意中,发现了一个JS的保护版权的代码。


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="./hsmw.js" type="text/javascript" charset="utf-8"></script>
</head>
<body id="home">
<div class="home">
<div class="copyright">Copyright © 混世魔王的技术博客 版权所有<!-- 为了能够正常使用,建议保留该链接 -->
<a title="黑帽SEO" href="http://26836659.blogcn.com" id="link" target="_blank">混世魔王</a></div>
</div>
</body></html>

这个作者写的代码很鸡贼,远程调用,加密以后,隐藏到了 jquery.js文件中。还是被混世魔王我给提取了出来。把下面JS代码保存成 hsmw.js 文件。

JS判断有很多,比如防止版权链接文字被篡改,URL被替换,被用display隐藏。你自己读代码了。 blogcn 不允许JS的代码,改成BASE64 的格式。自己解密一下。

ZnVuY3Rpb24gaW5uZXJIVE1MKGVsLCB3aGVyZSwgaHRtbCkgewppZiAoIWVsKSB7CnJldHVybiBmYWxzZTsKfQoKd2hlcmUgPSB3aGVyZS50b0xvd2VyQ2FzZSgpOwoKaWYgKGVsLmluc2VydEFkamFjZW50SFRNTCkgey8vSUUKZWwuaW5zZXJ0QWRqYWNlbnRIVE1MKHdoZXJlLCBodG1sKTsKfSBlbHNlIHsKdmFyIHJhbmdlID0gZWwub3duZXJEb2N1bWVudC5jcmVhdGVSYW5nZSgpLApmcmFnID0gbnVsbDsKCnN3aXRjaCAod2hlcmUpIHsKY2FzZSAiYmVmb3JlYmVnaW4iOgpyYW5nZS5zZXRTdGFyd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pmpDol4/kuobnvZHnq5nniYjmnYPkv6Hmga/vvIzlt7LlvIDlkK/kv53miqTmqKHlvI/vvIEiKTsKd2luZG93Lm9wZW4oImh0dHA6Ly8yNjgzNjY1OS5ibG9nY24uY29tIiwiX3RvcCIpOwp9CmlmKGdldFN0eWxlKHVyY29weS5wYXJlbnRFbGVtZW50LCJkaXNwbGF5IikgPT09ICJub25lIikgewphbGVydCgi56iL5bqP5qOA5rWL5Yiw5L2g6ZqQ6JeP5LqG572R56uZ54mI5p2D5L+h5oGv77yM5bey5byA5ZCv5L+d5oqk5qih5byP77yBIik7CndpbmRvdy5vcGVuKCJodHRwOi8vMjY4MzY2NTkuYmxvZ2NuLmNvbSIsIl90b3AiKTsKfQp9Cjs=

最终解密效果如下:


function innerHTML(el, where, html) {
if (!el) {
return false;
}

where = where.toLowerCase();

if (el.insertAdjacentHTML) {//IE
el.insertAdjacentHTML(where, html);
} else {
var range = el.ownerDocument.createRange(),
frag = null;

switch (where) {
case "beforebegin":
range.setStartBefore(el);
frag = range.createContextualFragment(html);
el.parentNode.insertBefore(frag, el);
return el.previousSibling;
case "afterbegin":
if (el.firstChild) {
range.setStartBefore(el.firstChild);
frag = range.createContextualFragment(html);
el.insertBefore(frag, el.firstChild);
} else {
el.innerHTML = html;
}
return el.firstChild;
case "beforeend":
if (el.lastChild) {
range.setStartAfter(el.lastChild);
frag = range.createContextualFragment(html);
el.appendChild(frag);
} else {
el.innerHTML = html;
}
return el.lastChild;
case "afterend":
range.setStartAfter(el);
frag = range.createContextualFragment(html);
el.parentNode.insertBefore(frag, el.nextSibling);
return el.nextSibling;
}
}
}

function getStyle(obj,attr){
if(obj.currentStyle){
return obj.currentStyle[attr];
}else{
return getComputedStyle(obj,false)[attr];
};
};

window.onload=function(){
var urcopy = document.getElementById("link");
var urfromurl = window.location.hostname;
if(urcopy) {
if(urcopy.innerHTML.length < 3) {
alert("程序检测到版权链接文字被恶意篡改,已启动保护模式!");
window.open("http://26836659.blogcn.com","_top");
}
else {
insertHTML(urcopy, 'afterEnd', '');
}
}
else {
alert("网页必须元素丢失,请检查网站代码是否被篡改或粘贴了来自其他网站的不安全内容!");
window.open("http://26836659.blogcn.com","_top");
}
if(urcopy.getAttribute("href").substring(0,26) != "http://26836659.blogcn.com") {
alert("请不要修改网站底部版权链接!");
window.open("http://26836659.blogcn.com","_top");
}
if(getStyle(urcopy,"display") === "none") {
alert("程序检测到你隐藏了网站版权信息,已开启保护模式!");
window.open("http://26836659.blogcn.com","_top");
}
if(getStyle(urcopy.parentElement,"display") === "none") {
alert("程序检测到你隐藏了网站版权信息,已开启保护模式!");
window.open("http://26836659.blogcn.com","_top");
}
}
;

Via:混世魔王的技术博客