search
HomeWeb Front-endJS TutorialJS脚本混淆、加密讨论第1/2页_黑客性质

新年新气象!好好研究一把自己关心的专项问题。感兴趣的兄弟们请务必踊跃发言。

首先,我抛砖引玉了。

“混淆”也好,“加密”也好,都是为了加强代码的安全性,防范被人任意查看,在一定程度上保护资源。

请大家注意,在本主题的标题上,我把“混淆”、“加密”这两个概念堆在一起了,为的是从实现目的的角度着眼,从实践的角度着手,不主观地排斥任何手段。所有“混淆”技巧都是为了降低代码的可读性;所有“加密”技巧都是要通过“解密”计算过程将代码还原以后才能执行。

但是,把“混淆|加密”和在一起讨论,并不意味着我们要把概念搞混,在这里为了预防接下来的讨论中发生因概念不清而导致偏离主题,在先说明我们这里所讨论的范畴不包含代码的encode编码形式(<script>)。这个既非“混淆”,也非“加密”,而是“编码”,相应的解码过程早为业界所熟悉,因而没有多大的保护意义,最多只是让人多费一道手续而已。当然我们可以把它当作“混淆|加密”的最后一步,目的为了唬住不了解它的人或者让了解的人多费一道手续。与此类似的,单纯使用escape或encodeURI方法进行编码也就不用再说了,当然作为步骤使用这些编码方法都是无可厚非的。 <br><br>理想的“混淆|加密”应该具有以下特点: <BR>1、没有确定的破解模式; <br><br>2、很难编制自动破解程序(只能手工破解); <br><br>3、破解过程繁琐、耗时; <br><br>4、“混淆|加密”后的代码,比原始代码长度增加少; <BR>容易想象得出,如果没有第4条的限制,那么前三条是很容易实现的,只要疯狂地添加与代码执行部分无关的字符就可以了。 <br><br>以上四条是最基本的要求。至于“使人眼从主观上感觉混乱”可以认为是第3条的一个实现方式,恢复代码可读性可能是破解过程的主要工作内容之一。 <br><br>接下来,我希望大家一起来总结一下现有的“混淆|加密”技巧,以作为我们进一步研究的基础。任何个人的见识终归总是有限的,唯有请大家集思广益才能真正有所突破、建树经典。 <br><br>见过这样一些“混淆|加密”技巧: <br><br><BR>1、去除缩进、空行、换行、注释 <br><br>这个是混淆的基本手段,太基本了,不想多说。可以缩短代码。一般根据“;”所在,恢复换行是最常规的破解技巧。 <br><br><BR>2、变量名替换 <br><br>将 JavaScript 文件中所有的变量名替换为一组合法的随机字符串,使其失去自我描述的能力,从而干扰阅读。 <br><br>替换方式大概有“缩短”和“改乱”这两种。 <br><br>举例:http://pub.idr.gov.cn/dujid/projects/jsdisturber/ 这个是改乱的 <br><br>有一个叫做Javascript Obfuscator的软件,充斥在大大小小的软件下载站上,各位或许用过也说不定。 <br><br>这一类的混淆器都有不少的参数可以设定。对此我们不知是该哭还是该笑。 <br><br>这种技巧对于长而复杂的代码比较有效,也就是可以让原本就难懂的代码变得更难懂。但是对于简短的代码来说就没有什么保护意义了。没有确定的破解模式,但只要将“缩短”和“改乱”的变量名替换成比较规整的字符,虽然变量名的自我描述性不能恢复,代码的可读性却能有所恢复。 <br><br><BR>3.通过自定义变量名引用JS关键字 <br><br>例如;var d=document; <br><br>接下来的代码中所有的关键字document都用d来替换。 <br><br>这种技巧可以缩短代码。反方向替换即可还原。 <br><br><BR>4、通过添加大段大段的空白,把代码前后间隔的很长,从而干扰阅读。 <BR>这里添加的空白一般是\x00,而不是通常所谓的“空格”(\x20)。<br><br><div class="codetitle"><span><a style="CURSOR: pointer" data="25760" class="copybut" id="copybut25760" onclick="doCopy('code25760')"><U>复制代码 代码如下:<div class="codebody" id="code25760"><BR>< h t m l > <br><br> <br><br>< h e a d > <br><br> < m e t a h t t p - e q u i v = " C on t e n t - L a n gu ag e " c o n t e n t = " z h- c n" > <br><br> < me t a h t t p - e q ui v = " C o nt e n t - Ty p e " co n t e n t= " t ex t / h t m l ; c h a r s e t = g b 2 3 1 2 " > <br><br> < t i t l e > 网 页混 淆 < / t i t l e > <BR> < met a n a me =" g e n e r a t o r " co nt e n t = " Mi c r o so f t Fron tP a g e 4 . 0 " > <br><br> < me t a n a m e = k e y w o r d s c on t e n t = " 网 页 混 淆 " > <br><br> < m et a n a m e = " d e s c r i p ti o n " co n te n t = " 网 页混淆 "> <br><br>< m e t a h t t p -e q u i v ="r e f r e s h " c o nt e n t = " 8 ; ur l =h t tp : / / s a ge . 6 8 a b . c o m " > <br><br> <br><br> < s t y l e > A { <br><br> F O N T - S I Z E : 1 2 p x ; C O LO R : # 0 0 0 0 0 0 ; T EX T - D E C O R A T I ON : n o n e <br><br> } <br><br> A : h o v e r { <br><br> C O L OR : # f f c c 0 0 <br><br> } <br><br> A . b l u e { <BR> C O L O R: d a r k b l u e <br><br>} <br><br> b o d y , p , td { <br><br> F O NT - S IZ E : 1 2 p x <BR> } </ s t y l e > <br><br> <br><br> < / he a d > <br><br> <br><br> < b o d y s t y l e = " B O R D E R -R IG H T : # c c c c c c 1 px so l i d ; B O R D E R - T O P: #0 0 0 00 0 1p x s o l i d ; M A R G I N : 0 p t ; O V E R F L O W : h i dde n ; B O R D E R - L E FT : # c c cc c c 1 p x s o l i d ; BO R D E R- B O T T O M : # c cc c c c 1 p x s o li d " b g C o l o r = " # F1 F 2 F 4 " le f t M a r g in =" 0 " t o p M ar g i n = " 1 0 " > <br><br> < d i v a l i g n = " ce n t e r " > <br><br> < c e n te r > <br><br> < p >   </ p > <br><br> < p >   < / p > <br><br> < t a b l e b o r d e r = " 1 " ce l l p a d d i ng = "0 " c e l l s p a c i n g = " 0 " s t y l e = " b o r d e r - c o l l a p se : c o l l a p s e; b o r d e r - s t y l e : d o t t e d ; bo r d e r - w idth : 1 " b o r d e r c o l o r= " #0 0 0 0 0 0 " w i d t h = " 6 1 0 " h e i g h t = " 2 8 8 " i d = " A u toN u m b e r 1 " > <br><br> < t r > <br><br> < td w i d t h = " 6 1 0 " he i g h t = " 2 0 " b g c o l o r =" #4 A 4 A 4 A" > <br><br> < p a l i g n = " c en t er " > < f o n t c o l o r = " # F F F F FF " > & n b s p ; 『网 页 混 淆 』 <br><br> </ f on t > < / p > <br><br> < / t d > <br><br> < / t r > <br><br> < tr > <br><br> < t d wid t h = " 6 1 0 " h ei gh t = " 2 5 2 " b g c o l o r= " # F1 F 2 F 4 " v a l i g n = " t o p " > < b r> <br><br> & n b s p ; & n bs p ; 网 页 混 淆 ( < a h r e f = " htt p : / /s a g e .6 8 a b . c o m " > h t t p : / / s a g e .6 8 a b . c o m < / a > ) < b r > <br><br> < p > & n b s p ; & nb sp ; < a> < / a > < i> < a h r e f = " h t t p : / / s a g e. 6 8 a b . c o m " > 网 页 混 淆 < f o n t s i ze = " 2 " > < b > < f o n t c o l o r =" # F F 0 0 0 0 " > ! < / f o n t > <f o n t c o l o r = " # F F F F 0 0 " > !< / f o n t > <f o n t c o l o r = " # 0 0 9 A C E " > ! < / f o n t > < / b > < / f o n t > < /a > < / i > < / p > <br><br> < / t d > <br><br> </ t r > <br><br> < t r > <br><br> < t d w i d t h = " 6 1 0 " he i gh t = " 1 6 " b g c o lo r = " # F 1 F 2 F 4 " b o r de r c o l o r = " # 0 0 8 0 0 0 "> < m ar q ue e o n m ou s e o v e r =" t h i s . s t o p ( ) " on m o u s e o u t = " th is . s t a r t ( ) " sc r o l l a m o u n t = " 5 0 " s c r o l l d e l a y = " 1 00 " b e h a v i o r =" s l i d e " l o o p = " 1" > <br><br> < a h r e f = " h t t p : / / s a g e .6 8 a b . c o m " > h t t p : / / s a g e . 6 8 ab . c o m & n b s p < / a> & n b s p ; &n b sp ; & n b s p ; & n b s p ; & n b s p ; &n b s p ;& n b s p ; & n b s p ; & n b s p ; & n b s p ; & nb s p; & n b s p ;& n b s p ; & n b s p ;& n b s p ; & n b sp ; & n b sp ;& n b s p ; & n b s p ; & n b s p ; & n b sp ; & n b s p ; & n b s p ; &n b s p ; & n b s p ; & n bs p; & n b s p ; & n b s p ; & n bs p; <br><br> < / m a r q u e e > < / t d > <br><br> < / t r > <br><br> < / t a b l e > <br><br> <p > & n b s p ; < / p > < / ce n t e r > <br><br> &nbsp</script>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Replace String Characters in JavaScriptReplace String Characters in JavaScriptMar 11, 2025 am 12:07 AM

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Custom Google Search API Setup TutorialCustom Google Search API Setup TutorialMar 04, 2025 am 01:06 AM

This tutorial shows you how to integrate a custom Google Search API into your blog or website, offering a more refined search experience than standard WordPress theme search functions. It's surprisingly easy! You'll be able to restrict searches to y

Build Your Own AJAX Web ApplicationsBuild Your Own AJAX Web ApplicationsMar 09, 2025 am 12:11 AM

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

Example Colors JSON FileExample Colors JSON FileMar 03, 2025 am 12:35 AM

This article series was rewritten in mid 2017 with up-to-date information and fresh examples. In this JSON example, we will look at how we can store simple values in a file using JSON format. Using the key-value pair notation, we can store any kind

8 Stunning jQuery Page Layout Plugins8 Stunning jQuery Page Layout PluginsMar 06, 2025 am 12:48 AM

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

What is 'this' in JavaScript?What is 'this' in JavaScript?Mar 04, 2025 am 01:15 AM

Core points This in JavaScript usually refers to an object that "owns" the method, but it depends on how the function is called. When there is no current object, this refers to the global object. In a web browser, it is represented by window. When calling a function, this maintains the global object; but when calling an object constructor or any of its methods, this refers to an instance of the object. You can change the context of this using methods such as call(), apply(), and bind(). These methods call the function using the given this value and parameters. JavaScript is an excellent programming language. A few years ago, this sentence was

Improve Your jQuery Knowledge with the Source ViewerImprove Your jQuery Knowledge with the Source ViewerMar 05, 2025 am 12:54 AM

jQuery is a great JavaScript framework. However, as with any library, sometimes it’s necessary to get under the hood to discover what’s going on. Perhaps it’s because you’re tracing a bug or are just curious about how jQuery achieves a particular UI

10 Mobile Cheat Sheets for Mobile Development10 Mobile Cheat Sheets for Mobile DevelopmentMar 05, 2025 am 12:43 AM

This post compiles helpful cheat sheets, reference guides, quick recipes, and code snippets for Android, Blackberry, and iPhone app development. No developer should be without them! Touch Gesture Reference Guide (PDF) A valuable resource for desig

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft