Skip to content

Commit c506777

Browse files
committed
Add obfuscation type checker + Alert
1 parent 6bc7843 commit c506777

File tree

3 files changed

+91
-5
lines changed

3 files changed

+91
-5
lines changed

src/Analizer.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
11
export default function () {
2+
const Analizer = {};
23

4+
Analizer.checkType = function(targetName, code) {
5+
let type;
6+
7+
if (typeof type != "string") return type;
8+
9+
switch (true) {
10+
case !!code.match(new RegExp(`${targetName}\\[[0-9]+\\]`)):
11+
type = 0;
12+
break;
13+
14+
case !!code.match(new RegExp(`${targetName}\\(.[a-zA-Z0-9]+.\\)`)):
15+
type = 1;
16+
break;
17+
18+
case !!code.match(new RegExp(`${targetName}\\(.[a-zA-Z0-9]+.,.[^']+.\\)`)):
19+
type = 2;
20+
break;
21+
}
22+
23+
console.log("[Analizer] Obfuscation type:", type);
24+
return type;
25+
}
26+
27+
return Analizer;
328
}

src/components/Alert.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div v-if="show" class="alert" v-bind:class="[type]" role="alert">
3+
<b>{{ title }}</b> {{ message }}
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
data() {
10+
return {
11+
title: "",
12+
message: "",
13+
type: "alert-success",
14+
show: false,
15+
};
16+
},
17+
18+
methods: {
19+
showAlert(type, title, message) {
20+
this.type = "alert-" + type;
21+
this.title = title;
22+
this.message = message;
23+
this.show = true;
24+
},
25+
hide() {
26+
this.show = false;
27+
},
28+
}
29+
};
30+
</script>

src/components/Main.vue

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<template>
22
<div class="container text-left">
33
<h1 class="my-4">JavaScript Deobfuscator</h1>
4+
5+
<Alert ref="alert"></Alert>
6+
47
<div class="form-group mb-4 text-left">
58
<label for="TargetFuncName">Target function name</label>
69
<input
710
type="text"
811
class="form-control"
912
id="TargetFuncName"
10-
placeholder="_0x"
13+
placeholder="_0x1234"
1114
v-model="targetName"
1215
/>
1316
</div>
@@ -17,6 +20,7 @@
1720
class="form-control"
1821
id="codeInputTextarea"
1922
rows="5"
23+
placeholder="var _0x14bb=['EMKjwoXCuTB1PsKIbSnDkMKY','RsKLwrHCpQ==','wpPCisOQI ..."
2024
v-model="mainCode"
2125
></textarea>
2226
</div>
@@ -52,12 +56,17 @@
5256
</template>
5357

5458
<script>
55-
// import Decoder from "@/Decoder.js";
59+
import Analizer from "@/Analizer.js";
60+
import Alert from "@/components/Alert.vue";
5661
5762
export default {
63+
components: {
64+
Alert,
65+
},
66+
5867
data() {
5968
return {
60-
decoder: null,
69+
analizer: null,
6170
targetName: null,
6271
mainCode: null,
6372
outputCode: null,
@@ -68,26 +77,48 @@ export default {
6877
methods: {
6978
decode() {
7079
this.running = true;
80+
this.$refs.alert.hide();
81+
82+
const type = this.analizer.checkType(this.targetName, this.mainCode);
83+
if (!type)
84+
return this.$refs.alert.showAlert(
85+
"danger",
86+
"[Error]",
87+
"Invalid obfuscation type! Please report to us or try again."
88+
);
89+
7190
this.changeProgress(100);
91+
7292
this.axios
7393
.post(
7494
"https://us-central1-deobfuscator.cloudfunctions.net/api/request",
7595
{
7696
targetName: this.targetName,
77-
code: this.mainCode
97+
code: this.mainCode,
98+
type,
7899
}
79100
)
80101
.then((res) => {
81102
this.running = false;
82103
// console.log(res);
83104
res.data = res.data.replace(/\n/g, "");
84105
this.changeProgress(0);
106+
this.$refs.alert.showAlert(
107+
"success",
108+
"[Success]",
109+
"Successfully decoded the code!!"
110+
);
85111
this.outputCode = window.js_beautify(res.data);
86112
})
87113
.catch((e) => {
88114
this.running = false;
89115
this.changeProgress(0);
90116
console.log(e);
117+
this.$refs.alert.showAlert(
118+
"danger",
119+
"[Error]",
120+
"Server error! Please check target code and name of target function."
121+
);
91122
});
92123
},
93124
changeProgress(rate) {
@@ -99,7 +130,7 @@ export default {
99130
},
100131
101132
mounted() {
102-
// this.decoder = Decoder();
133+
this.analizer = Analizer();
103134
},
104135
};
105136
</script>

0 commit comments

Comments
 (0)