Skip to content

Commit c86ee58

Browse files
authored
Add files via upload
0 parents  commit c86ee58

File tree

8 files changed

+1927
-0
lines changed

8 files changed

+1927
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Discord Javascript obfuscator
2+
3+
**Simple discord javascript obfuscator bot**
4+
- Notice this source code is not the best, especially command handlers
5+
has been done so fast that I will definitely find bugs from it later.
6+
7+
**Requirements:**
8+
- Node.js v12+(Recommended)
9+
- Discord.js 12.0.0 (Recommended) or newer
10+
- download 8.0.0 (Recommended)
11+
- javascript-obfuscator 2.6.2 (Recommended)
12+
13+
## Credits
14+
[https://github.com/rutkuli]
15+
[https://github.com/javascript-obfuscator]
16+
17+

commands/Obfuscator.js

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
const { Discord, MessageAttachment } = require('discord.js'); /*npm install discord.js*/
2+
const Config = require('../config.json');
3+
const download = require('download'); /*npm install download*/
4+
const fs = require('fs'); /*npm install fs*/
5+
const JavaScriptObfuscator = require('javascript-obfuscator'); /*npm install javascript-obfuscator*/
6+
7+
exports.run = async(client, message, args) => {
8+
9+
const status = args[0]; /*Gets status from first argument*/
10+
11+
if(!status){ /*If there is no status, this will send message.author a editable message*/
12+
message.delete();
13+
return message.channel.send(`$@{message.author.tag} Please specify status.`).then(s => { s.delete({ timeout: 7000 })})
14+
}
15+
16+
if(status === "encode"){
17+
let method = args[1]; /*Gets method from second argument*/
18+
19+
if(!method){ /*If there is no method, this will send message.author a editable message*/
20+
message.delete();
21+
return message.channel.send(`${message.author.tag} Please specify encryption level, *-low*, *medium*, *-high*`).then(s => { s.delete({ timeout: 7000 })})
22+
}
23+
24+
if(method === "-high"){
25+
try {
26+
Download(); /*Call function download*/
27+
function Download(){
28+
const attachments = (message.attachments).array(); // Get list of attachments
29+
const attachment = attachments[0]; // Take the first attachment
30+
if (attachments.length !== 0) {
31+
download(message.attachments.first().url, `./encoding/`, {
32+
'filename': `${message.author.tag}.txt` /*Forces the file to be saved as txt file*/
33+
});
34+
setTimeout(function() { Run(); }, 5000); /*Timeout 5000 = 5s*/ /*Call function Run after timeout*/
35+
message.delete({ timeout: 10000 }); /*Deletes original attachment message*/ /*NOTICE: If your connection speed is slow, this might be a broplem. Higher number = slower deletion time which is great for bad internet connections*/
36+
}else{
37+
message.author.send('You should send the command with an file!');
38+
message.delete();
39+
}
40+
}
41+
42+
function Run(){
43+
fs.readFile(`./encoding/${message.author.tag}.txt`, 'utf8', function(err,data) {
44+
if (err) {
45+
return console.log(err);
46+
}
47+
var obfuscationResult = JavaScriptObfuscator.obfuscate(data, {
48+
compact: true,
49+
controlFlowFlattening: true,
50+
controlFlowFlatteningThreshold: 1,
51+
deadCodeInjection: true, /*These options are editable, you can find the options from https://github.com/javascript-obfuscator/javascript-obfuscator*/
52+
deadCodeInjectionThreshold: 25,
53+
disableConsoleOutput: true,
54+
renameGlobals: true,
55+
selfDefending: true
56+
});
57+
fs.writeFile(`./encoding/finished/${message.author.tag}.txt`, obfuscationResult.getObfuscatedCode() , function(err) {
58+
if(err) {
59+
return console.log(err);
60+
}
61+
});
62+
});
63+
setTimeout(function() { Send(); }, 7000); /*Timeout 7000 = 7s*/ /*Call function Send after timeout*/
64+
}
65+
66+
function Send() {
67+
fs.readFile(`./encoding/finished/${message.author.tag}.txt`, 'utf8', function(err,data) {
68+
if (err) {
69+
return console.log(err);
70+
}
71+
const Message = 'Your encrypted file.'; /*This is just an example text.*/
72+
const attachment = new MessageAttachment(`./encoding/finished/${message.author.tag}.txt`);
73+
message.author.send(Message, attachment);
74+
});
75+
setTimeout(function() { Delete(); }, 10000);/*Timeout 10000 = 10s*/ /*Call function Delete after timeout*/
76+
}
77+
78+
function Delete() {
79+
fs.unlinkSync(`./encoding/${message.author.tag}.txt`); /*Deletes message.author original file*/
80+
fs.unlinkSync(`./encoding/finished/${message.author.tag}.txt`);/*Deletes message.author encrypted file*/
81+
}
82+
83+
} catch (err) {
84+
console.log(err);
85+
}
86+
}
87+
88+
if(method === "-medium"){
89+
try {
90+
Download();
91+
function Download(){
92+
const attachments = (message.attachments).array(); // Get list of attachments
93+
const attachment = attachments[0]; // Take the first attachment
94+
if (attachments.length !== 0) {
95+
download(message.attachments.first().url, `./encoding/`, {
96+
'filename': `${message.author.tag}.txt` /*Forces the file to be saved as txt file*/
97+
});
98+
setTimeout(function() { Run(); }, 5000); /*Timeout 5000 = 5s*/ /*Call function Run after timeout*/
99+
message.delete({ timeout: 10000 }); /*Deletes original attachment message*/ /*NOTICE: If your connection speed is slow, this might be a broplem. Higher number = slower deletion time which is great for bad internet connections*/
100+
}else{
101+
message.author.send('You should send the command with an file!');
102+
message.delete();
103+
}
104+
}
105+
106+
function Run(){
107+
fs.readFile(`./encoding/${message.author.tag}.txt`, 'utf8', function(err,data) {
108+
if (err) {
109+
return console.log(err);
110+
}
111+
var obfuscationResult = JavaScriptObfuscator.obfuscate(data, {
112+
compact: true,
113+
controlFlowFlattening: true,
114+
controlFlowFlatteningThreshold: 0.75,
115+
deadCodeInjection: true,
116+
deadCodeInjectionThreshold: 0.4, /*These options are editable, you can find the options from https://github.com/javascript-obfuscator/javascript-obfuscator*/
117+
debugProtectionInterval: false,
118+
disableConsoleOutput: true,
119+
renameGlobals: false,
120+
selfDefending: true,
121+
});
122+
fs.writeFile(`./encoding/finished/${message.author.tag}.txt`, obfuscationResult.getObfuscatedCode() , function(err) {
123+
if(err) {
124+
return console.log(err);
125+
}
126+
});
127+
});
128+
setTimeout(function() { Send(); }, 7000); /*Timeout 7000 = 7s*/ /*Call function Send after timeout*/
129+
}
130+
131+
function Send() {
132+
fs.readFile(`./encoding/finished/${message.author.tag}.txt`, 'utf8', function(err,data) {
133+
if (err) {
134+
return console.log(err);
135+
}
136+
const Message = 'Your encrypted file.'; /*This is just an example text.*/
137+
const attachment = new MessageAttachment(`./encoding/finished/${message.author.tag}.txt`);
138+
message.author.send(Message, attachment);
139+
});
140+
setTimeout(function() { Delete(); }, 10000); /*Timeout 10000 = 10s*/ /*Call function Delete after timeout*/
141+
}
142+
143+
function Delete() {
144+
fs.unlinkSync(`./encoding/${message.author.tag}.txt`); /*Deletes message.author original file*/
145+
fs.unlinkSync(`./encoding/finished/${message.author.tag}.txt`);/*Deletes message.author encrypted file*/
146+
}
147+
148+
} catch (err) {
149+
console.log(err);
150+
}
151+
}
152+
153+
154+
155+
156+
157+
if(method === "-low"){
158+
try {
159+
Download();
160+
function Download(){
161+
const attachments = (message.attachments).array(); // Get list of attachments
162+
const attachment = attachments[0]; // Take the first attachment
163+
if (attachments.length !== 0) {
164+
download(message.attachments.first().url, `./encoding/`, {
165+
'filename': `${message.author.tag}.txt` /*Forces the file to be saved as txt file*/
166+
});
167+
setTimeout(function() { Run(); }, 5000); /*Timeout 5000 = 5s*/ /*Call function Run after timeout*/
168+
message.delete({ timeout: 10000 }); /*Deletes original attachment message*/ /*NOTICE: If your connection speed is slow, this might be a broplem. Higher number = slower deletion time which is great for bad internet connections*/
169+
}else{
170+
message.author.send('You should send the command with an file!');
171+
message.delete();
172+
}
173+
}
174+
175+
function Run(){
176+
fs.readFile(`./encoding/${message.author.tag}.txt`, 'utf8', function(err,data) {
177+
if (err) {
178+
return console.log(err);
179+
}
180+
var obfuscationResult = JavaScriptObfuscator.obfuscate(data, {
181+
compact: true,
182+
mangle: true,
183+
rotateStringArray: true,
184+
selfDefending: true, /*These options are editable, you can find the options from https://github.com/javascript-obfuscator/javascript-obfuscator*/
185+
stringArray: true,
186+
});
187+
fs.writeFile(`./encoding/finished/${message.author.tag}.txt`, obfuscationResult.getObfuscatedCode() , function(err) {
188+
if(err) {
189+
return console.log(err);
190+
}
191+
});
192+
});
193+
setTimeout(function() { Send(); }, 7000); /*Timeout 7000 = 7s*/ /*Call function Send after timeout*/
194+
}
195+
196+
function Send() {
197+
fs.readFile(`./encoding/finished/${message.author.tag}.txt`, 'utf8', function(err,data) {
198+
if (err) {
199+
return console.log(err);
200+
}
201+
const Message = 'Your encrypted file.'; /*This is just an example text.*/
202+
const attachment = new MessageAttachment(`./encoding/finished/${message.author.tag}.txt`);
203+
message.author.send(Message, attachment);
204+
});
205+
setTimeout(function() { Delete(); }, 10000); /*Timeout 10000 = 10s*/ /*Call function Delete after timeout*/
206+
}
207+
208+
function Delete() {
209+
fs.unlinkSync(`./encoding/${message.author.tag}.txt`); /*Deletes message.author original file*/
210+
fs.unlinkSync(`./encoding/finished/${message.author.tag}.txt`); /*Deletes message.author encrypted file*/
211+
}
212+
213+
} catch (err) {
214+
console.log(err);
215+
}
216+
}
217+
}
218+
}
219+
220+
exports.help = {
221+
name: 'obfuscator'
222+
}

config.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"prefix": "Your prefix",
3+
"author": "Your discord account id",
4+
"token": "Your bot token, you can find token from Discord developer portal."
5+
}

events/message.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const Config = require('../config.json');
2+
3+
module.exports = (client, message) => {
4+
5+
let prefix = Config.prefix;
6+
let msg = message.content.split(/\s+/g);
7+
let args = msg.slice(1);
8+
let command = msg[0];
9+
let cmd = client.commands.get(command.slice(prefix.length)) || client.commands.get(client.aliases.get(command.slice(prefix.length)));
10+
if (message.author.bot) return;
11+
if (!command.startsWith(prefix)) return;
12+
if (message.channel.type == "dm") return;
13+
if (cmd) {
14+
cmd.run(client, message, args);
15+
}
16+
}

index.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const Discord = require('discord.js'); /*npm install discord.js*/
2+
const Client = new Discord.Client();
3+
const Config = require('./config.json');
4+
const fs = require('fs'); /*npm install fs*/
5+
6+
let prefix = Config.prefix;
7+
/*Very simple base, but it does it job :D*/
8+
fs.readdir("./events/", (err, files) => {
9+
if (err) return console.error(err);
10+
files.forEach((file) => {
11+
const event = require(`./events/${file}`);
12+
let eventName = file.split(".")[0];
13+
Client.on(eventName, event.bind(null, Client));
14+
});
15+
});
16+
17+
Client.commands = new Discord.Collection();
18+
Client.aliases = new Discord.Collection();
19+
20+
fs.readdir("./commands/", (err, files) => {
21+
if (err) return console.error(err);
22+
files.forEach((file) => {
23+
if (!file.endsWith(".js")) return;
24+
let cmd = require(`./commands/${file}`);
25+
let cmdFileName = file.split(".")[0];
26+
Client.commands.set(cmd.help.name, cmd);
27+
if (cmd.help.aliases) {
28+
cmd.help.aliases.forEach(alias => {
29+
Client.aliases.set(alias, cmd.help.name);
30+
});
31+
};
32+
});
33+
});
34+
35+
Client.on("ready", () => {
36+
console.log(`Bot is ready to use!`);
37+
});
38+
39+
Client.login(Config.token)

obfuscator.rar

21.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)