Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Command("Obfuscate")]
- public async Task Obfuscate(string Strength)
- {
- Strength = Strength.ToLower();
- int StrengthNum = 0;
- if (Strength == "veryweak" || Strength == "vw") StrengthNum = 1;
- else if (Strength == "weak" || Strength == "w") StrengthNum = 2;
- else if (Strength == "medium" || Strength == "m") StrengthNum = 3;
- else if (Strength == "hard" || Strength == "h") StrengthNum = 4;
- else if (Strength == "veryhard" || Strength == "vh") StrengthNum = 5;
- if (StrengthNum == 0)
- {
- EmbedBuilder EmbedBuilder = new EmbedBuilder();
- EmbedBuilder.WithTitle("Error While Obfuscation")
- .WithDescription("Please Select A Protection Strength!")
- .WithColor(Color.Red);
- await ReplyAsync("", false, EmbedBuilder.Build());
- return;
- }
- try
- {
- EmbedBuilder EmbedBuilder = new EmbedBuilder();
- var Attachments = Context.Message.Attachments;
- WebClient WebClient = new WebClient();
- string FileName = Attachments.ElementAt(0).Filename;
- string FileExtension = FileName.Split('.').Last();
- if (FileExtension != "lua")
- {
- EmbedBuilder.WithTitle("Error While Obfuscation")
- .WithDescription("File's Extension is not .lua!")
- .WithColor(Color.Red);
- await ReplyAsync("", false, EmbedBuilder.Build());
- return;
- }
- string FileUrl = Attachments.ElementAt(0).Url;
- byte[] FileBuffer = WebClient.DownloadData(FileUrl);
- string Script = Encoding.UTF8.GetString(FileBuffer);
- EmbedBuilder.WithTitle("Obfuscating Script...")
- .WithDescription("Script is Currently Obfucating!")
- .WithColor(Color.Blue);
- var ObfuscatingMessage = await ReplyAsync("", false, EmbedBuilder.Build());
- string ObfuscatedScript = Obfuscator.ObfuscateScript(Script, StrengthNum);
- if (ObfuscatedScript == null)
- {
- EmbedBuilder.WithTitle("Error While Obfuscation")
- .WithDescription("Null Returned After Obfuscation!")
- .WithColor(Color.Red);
- await ReplyAsync("", false, EmbedBuilder.Build());
- return;
- }
- string FilePath = Directory.GetCurrentDirectory() + "\\" + FileName.Split('.')[0] + "-obf.lua";
- File.WriteAllText(FilePath, ObfuscatedScript);
- EmbedBuilder.WithTitle("Script Obfuscated!")
- .WithDescription("Script Obfuscated!\nTimestamp: " + DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss"))
- .WithColor(Color.Blue);
- await Context.User.SendFileAsync(FilePath, "", false, EmbedBuilder.Build());
- EmbedBuilder.WithTitle("Script Obfuscated!")
- .WithDescription("Script Obfuscated, Sent To DM!\nTimestamp: " + DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss"))
- .WithColor(Color.Blue);
- await ObfuscatingMessage.ModifyAsync(MessageProperties => { MessageProperties.Embed = EmbedBuilder.Build(); });
- }
- catch (Exception Exception)
- {
- EmbedBuilder EmbedBuilder = new EmbedBuilder();
- EmbedBuilder.WithTitle("Error While Obfuscation")
- .WithDescription(Exception.Message.ToString())
- .WithColor(Color.Red);
- await ReplyAsync("", false, EmbedBuilder.Build());
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement