You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# JS Analyzer
2
2
3
-
This is a project to analyze obfuscated JS code using abstract interpretation.
3
+
This is a project to analyze obfuscated JS code using abstract interpretation and optimizations similar to compiler optimizations
4
4
5
5
It requires `python3` or `pypy3` with module `esprima`. The usage of `pypy3` is
6
6
recommended for performance reasons.
@@ -11,6 +11,7 @@ essential things are missing, including but not limited to:
11
11
* OOP stuff (classes, etc)
12
12
* async functions
13
13
* a lot of operators and built-in functions are not handled correctly, or not handled at all...
14
+
* Analysis speed could be a lot better
14
15
15
16
## Setup
16
17
@@ -24,7 +25,16 @@ Before use, you must type `make` in the project directory in order to compile js
24
25
25
26
It will produce a `yourfile-out.js`
26
27
27
-
## How it works
28
+
## How it works ?
29
+
30
+
The obfuscated JS is processed in 4 steps
31
+
32
+
* Parsing the JS into an Abstract Syntax Tree (AST) (this is done by the esprima module)
33
+
* Abstract Interpretation on the AST to find out constant expressions (done by analyze.py)
34
+
* Code Transformations on the AST, this is similar to compiler optimizations (done by transform.py)
35
+
* Transformed JS output (done by prettyprint.js using the escodegen module)
36
+
37
+
## Abstract interpretation
28
38
29
39
### The general idea
30
40
@@ -114,3 +124,6 @@ The project is organized in several files:
114
124
*`output.py`: defines the pretty-printer / output generator. It is executed after the interpreter, and outputs the result JS, where each constant expression is replaced with its value.
115
125
116
126
127
+
## Code Transforms
128
+
129
+
The used optimizations are common, and found in any good compilation book (dead code/variable elimination, unrolling, etc)
0 commit comments