在当今的互联网时代,JavaScript是web开发的核心技术之一。但是,为了保护JavaScript代码的安全性,很多开发者会使用JS加密技术。其中一个常用的JS加密工具是jsjiami.v6。
JS加密通过对JavaScript代码进行混淆、压缩、编码等多种操作,使得代码难以被理解和修改。这不仅可以防止恶意攻击,还可以保护商业秘密。
然而,如果你需要对一个使用jsjiami.v6加密的JavaScript代码进行修改或解析,就需要进行解密操作。接下来,我将为您介绍一些JS解密技巧。
首先,让我们来看一段使用jsjiami.v6加密的代码:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n9" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\b'+e(c)+'\b','g'),k[c]);return p;}('0 1(){2.3("4 5!");}',6,6,'function|foo|console|log|Hello|World'.split('|'),0,{}))</pre>
这是一个简单的函数,输出了"Hello World!"。但是,由于被加密,代码难以理解。现在,让我们来解密它。
第一步,我们需要将代码放到一个JS美化工具中,以便更好地理解代码结构。可以使用在线工具如JS Beautifier或JS Nice进行美化。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n15" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">function foo() {
console.log("Hello World!");
}</pre>
现在我们可以看到这个函数输出了"Hello World!"。但是,代码仍然无法执行,因为它是经过压缩和编码的。
第二步,我们需要手动解码代码。这段代码使用了一个自定义的解码函数,它会将字符串解密为可执行的代码。下面是解密函数:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n21" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">function decode(code) {
var a = 62,
b = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
c = RegExp("[^" + b.substr(0, a) + "]","g"),
code = code.replace(c, ""),
d = code.length,
e = 0,
f = "";
for (; e < d;) {
var g = b.indexOf(code.charAt(e++)),
h = b.indexOf(code.charAt(e++)),
i = b.indexOf(code.charAt(e++)),
j = b.indexOf(code.charAt(e++)),
k = g << 2 | h >> 4,
l = (15 & h) << 4 | i >> 2,
m = (3 & i) << 6 | j;
f += String.fromCharCode(k),
64 != i && (f += String.fromCharCode(l)), 64 != j && (f += String.fromCharCode(m))
}
return f
}
</pre>
可以看到,这个解密函数使用了一个字符串和数字的映射表,将加密后的字符串解密成原始代码。 现在我们将解密函数应用到原始代码上:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="js" cid="n25" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">function foo() {
console.log("Hello World!");
}
eval(decode('0%20%66%75%6e%63%74%69%6f%6e%20%66%6f%6f%28%29%20%7b%0a%20%20%63%6f%6e%73%6f%6c%65%2e%6c%6f%67%28%22%48%65%6c%6c%6f%20%57%6f%72%6c%64%21%22%29%3b%0a%7d'))</pre>
我们可以看到,这个代码现在已经可以执行,输出了"Hello World!"。
这就是一个简单的JS解密过程。虽然这个例子比较简单,但是如果您需要解密更复杂的JS代码,您可能需要使用更高级的解密技术,例如AST解析和反混淆等。
总之,JS加密是保护JavaScript代码安全性的一种有效手段。但是,如果您需要对加密代码进行修改或解析,您也可以使用一些解密技巧来实现。希望本文能对您有所帮助。
如果您对文章内容有不同看法,或者疑问,欢迎到评论区留言,或者私信我都可以。
如遇自己源码加密后没备份,可以找我们解决解出恢复源码,任何加密都可以
1.png
2.png









网友评论