Skip to content

Commit e800dc2

Browse files
committed
Basic prototype
1 parent c99f2b3 commit e800dc2

File tree

49 files changed

+1429
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1429
-1
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
root = true
3+
4+
[*]
5+
insert_final_newline = true
6+
end_of_line = lf
7+
8+
[*.{ts,js,md}]
9+
indent_style = space
10+
indent_size = 4
11+
charset = utf-8

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
/mod.ts

Examples/App.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
import { initialize , deobfuscate } from 'Deobfuscate'
3+
import * as Paths from './Paths.js'
4+
5+
6+
const { writeTextFile , readTextFile } = Deno;
7+
const { clear , log } = console;
8+
9+
10+
clear();
11+
12+
log('Deobfuscating /Data/Obfuscated.js -> /Data/Deobfuscated.js')
13+
14+
await initialize();
15+
16+
17+
const obfuscated = await
18+
readTextFile(Paths.Obfuscated);
19+
20+
const deobfuscated =
21+
deobfuscate(obfuscated,{ debug : true });
22+
23+
24+
await writeTextFile(Paths.Deobfuscated,deobfuscated);

Examples/Data/Deobfuscated.js

Whitespace-only changes.

Examples/Data/Obfuscated.js

Whitespace-only changes.

Examples/Paths.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
import { fromFileUrl , dirname , join } from 'Path'
3+
4+
5+
const repository = join(dirname(fromFileUrl(import.meta.url)),'..');
6+
7+
8+
const examples =
9+
join(repository,'Examples');
10+
11+
const data =
12+
join(examples,'Data');
13+
14+
15+
export const Deobfuscated =
16+
join(data,'Deobfuscated.js')
17+
18+
19+
export const Obfuscated =
20+
join(data,'Obfuscated.js')
21+
22+

Imports.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"imports" : {
3+
4+
"Path" : "https://deno.land/std@0.167.0/path/mod.ts" ,
5+
6+
"Deobfuscate" : "./Source/mod.ts"
7+
}
8+
}

README.md

Lines changed: 233 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,233 @@
1-
# Deobfuscate
1+
2+
<div align = center>
3+
4+
# Deobfuscate
5+
6+
*Make obfuscated JavaScript code more readable.*
7+
8+
</div>
9+
10+
<br>
11+
<br>
12+
13+
## Status
14+
15+
Currently the deobfuscation doesn't prioritize one step
16+
over another, however this will change in the future.
17+
18+
<br>
19+
<br>
20+
21+
## Steps
22+
23+
*Implemented deobfuscation steps.*
24+
25+
<br>
26+
27+
- **Combined Expressions**
28+
29+
```js
30+
expression && expression
31+
```
32+
33+
```js
34+
if(expression)
35+
expression
36+
```
37+
38+
<br>
39+
40+
- **Double Knot**
41+
42+
```js
43+
!! expression
44+
```
45+
46+
```js
47+
Boolean(expression)
48+
```
49+
50+
<br>
51+
52+
- **Interjoined Assignments**
53+
54+
```js
55+
(a = {}).b = 1
56+
```
57+
58+
```js
59+
a = {} ;
60+
b = 1 ;
61+
```
62+
63+
<br>
64+
65+
- **Joined Variables**
66+
67+
```js
68+
let a = 1 ,
69+
b = 2 ;
70+
```
71+
72+
```js
73+
let a = 1 ;
74+
let b = 2 ;
75+
```
76+
77+
<br>
78+
79+
- **Literal Garbage**
80+
81+
```js
82+
0;
83+
```
84+
85+
<br>
86+
87+
- **Non-constant**
88+
89+
```js
90+
var a = 1;
91+
```
92+
93+
```js
94+
const a = 1;
95+
```
96+
97+
<br>
98+
99+
- **Noop**
100+
101+
```js
102+
;
103+
```
104+
105+
<br>
106+
107+
- **Number Logic**
108+
109+
```js
110+
!0 !1
111+
```
112+
113+
```js
114+
true false
115+
```
116+
117+
<br>
118+
119+
- **Property Twins**
120+
121+
```js
122+
const object = {
123+
property : property
124+
}
125+
```
126+
127+
```js
128+
const object = {
129+
property
130+
}
131+
```
132+
133+
<br>
134+
135+
- **Readable Variables**
136+
137+
```js
138+
const a;
139+
```
140+
141+
```js
142+
const __thing_234
143+
```
144+
145+
<br>
146+
147+
- **Secondhand Call**
148+
149+
```js
150+
(method)(a,b,c)
151+
```
152+
153+
```js
154+
method(a,b,c)
155+
```
156+
157+
<br>
158+
159+
- **Sequenced Expressions**
160+
161+
```js
162+
( expression , expression )
163+
```
164+
165+
```js
166+
expression;
167+
expression;
168+
```
169+
170+
<br>
171+
172+
- **Sequence Literals**
173+
174+
```js
175+
(0,a,0,b,0)
176+
```
177+
178+
```js
179+
(a,b,0)
180+
```
181+
182+
<br>
183+
184+
- **Stringed Indexing**
185+
186+
```js
187+
object['key']
188+
```
189+
190+
```js
191+
object.key
192+
```
193+
194+
<br>
195+
196+
- **Twin Declaration**
197+
198+
```js
199+
const w = window;
200+
```
201+
202+
<br>
203+
204+
- **Unreachable Conditions**
205+
206+
```js
207+
if(false)
208+
;
209+
```
210+
211+
<br>
212+
213+
- **Useless Constants**
214+
215+
```js
216+
const a;
217+
```
218+
219+
<br>
220+
221+
- **Void Literal**
222+
223+
```js
224+
void 0
225+
```
226+
227+
```js
228+
undefined
229+
```
230+
231+
232+
233+
<br>

Source/Imports.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
export * as Variable from './Variable.js'
3+
export * as Types from 'npm:@babel/types'
4+
5+
export { parse } from 'npm:@babel/parser'
6+
7+
8+
import Traverse from 'npm:@babel/traverse'
9+
export const traverse = Traverse.default;
10+
11+
12+
import Generator from 'npm:@babel/generator'
13+
export const generate = Generator.default;
14+
15+
16+
export * as FileSystem from 'https://deno.land/std@0.167.0/fs/mod.ts'
17+
export * as Path from 'https://deno.land/std@0.167.0/path/mod.ts'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
# Combined Expression
3+
4+
*Normalizes combined expressions.*
5+
6+
<br>
7+
<br>
8+
9+
## Conversion
10+
11+
```js
12+
expression && expression
13+
```
14+
15+
```js
16+
if(expression)
17+
expression
18+
```
19+
20+
<br>

0 commit comments

Comments
 (0)