新年新气象!好好研究一把自己关心的专项问题。感兴趣的兄弟们请务必踊跃发言。
首先,我抛砖引玉了。
“混淆”也好,“加密”也好,都是为了加强代码的安全性,防范被人任意查看,在一定程度上保护资源。
请大家注意,在本主题的标题上,我把“混淆”、“加密”这两个概念堆在一起了,为的是从实现目的的角度着眼,从实践的角度着手,不主观地排斥任何手段。所有“混淆”技巧都是为了降低代码的可读性;所有“加密”技巧都是要通过“解密”计算过程将代码还原以后才能执行。
但是,把“混淆|加密”和在一起讨论,并不意味着我们要把概念搞混,在这里为了预防接下来的讨论中发生因概念不清而导致偏离主题,在先说明我们这里所讨论的范畴不包含代码的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>  </script>

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor