public static bool Obfuscate(string path, string input, ObfuscationSettings settings, out string error) { try { error = ""; string OS = Environment.OSVersion.Platform == PlatformID.Unix ? "/usr/bin/" : ""; string l = Path.Combine(path, "luac.out"); if (!File.Exists(input)) { throw new Exception("Invalid input file."); } Console.WriteLine("Checking file..."); Process proc = new Process { StartInfo = { FileName = $"{OS}luac", Arguments = "-o \"" + l + "\" \"" + input + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; string err = ""; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(l)) { return(false); } File.Delete(l); string t0 = Path.Combine(path, "t0.lua"); Console.WriteLine("Stripping comments..."); proc = new Process { StartInfo = { FileName = $"{OS}luajit", Arguments = "../Lua/Minifier/luasrcdiet.lua --noopt-whitespace --noopt-emptylines --noopt-numbers --noopt-locals --noopt-strings --opt-comments \"" + input + "\" -o \"" + t0 + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(t0)) { return(false); } string t1 = Path.Combine(path, "t1.lua"); Console.WriteLine("Compiling..."); File.WriteAllText(t1, new ConstantEncryption(settings, File.ReadAllText(t0, _fuckingLua)).EncryptStrings()); proc = new Process { StartInfo = { FileName = $"{OS}luac", Arguments = "-o \"" + l + "\" \"" + t1 + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(l)) { return(false); } Console.WriteLine("Obfuscating..."); Deserializer des = new Deserializer(File.ReadAllBytes(l)); Chunk lChunk = des.DecodeFile(); if (settings.ControlFlow) { CFContext cf = new CFContext(lChunk); cf.DoChunks(); } Console.WriteLine("Serializing..."); //shuffle stuff //lChunk.Constants.Shuffle(); //lChunk.Functions.Shuffle(); ObfuscationContext context = new ObfuscationContext(lChunk); string t2 = Path.Combine(path, "t2.lua"); string c = new Generator(context).GenerateVM(settings); //string byteLocal = c.Substring(null, "\n"); //string rest = c.Substring("\n"); File.WriteAllText(t2, c, _fuckingLua); string t3 = Path.Combine(path, "t3.lua"); Console.WriteLine("Minifying..."); proc = new Process { StartInfo = { FileName = $"{OS}luajit", Arguments = "../Lua/Minifier/luasrcdiet.lua --maximum --opt-entropy --opt-emptylines --opt-eols --opt-numbers --opt-whitespace --opt-locals --noopt-strings \"" + t2 + "\" -o \"" + t3 + "\"" , } }; proc.Start(); proc.WaitForExit(); if (!File.Exists(t3)) { return(false); } Console.WriteLine("Watermark..."); File.WriteAllText(Path.Combine(path, "out.lua"), @"-- Obfuscated with Snoopbrew Obfuscator; Version 4.7.2 " + File.ReadAllText(t3, _fuckingLua).Replace("\n", " "), _fuckingLua); return(true); } catch (Exception e) { Console.WriteLine("ERROR"); Console.WriteLine(e); error = e.ToString(); return(false); } }
public static bool Obfuscate(string path, string input, ObfuscationSettings settings, out string error) { try { error = ""; string OS = Environment.OSVersion.Platform == PlatformID.Unix ? "/usr/bin/" : ""; string l = Path.Combine(path, "luac.out"); if (!File.Exists(input)) { throw new Exception("Invalid input file."); } Console.WriteLine("Checking file..."); Process proc = new Process { StartInfo = { FileName = $"{OS}luac", Arguments = "-o \"" + l + "\" \"" + input + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; string err = ""; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(l)) { return(false); } File.Delete(l); string t0 = Path.Combine(path, "t0.lua"); Console.WriteLine("Stripping comments..."); proc = new Process { StartInfo = { FileName = $"{OS}luajit", Arguments = "../Lua/Minifier/luasrcdiet.lua --noopt-whitespace --noopt-emptylines --noopt-numbers --noopt-locals --noopt-strings --opt-comments \"" + input + "\" -o \"" + t0 + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(t0)) { return(false); } string t1 = Path.Combine(path, "t1.lua"); Console.WriteLine("Compiling..."); File.WriteAllText(t1, new ConstantEncryption(settings, File.ReadAllText(t0, _fuckingLua)).EncryptStrings()); proc = new Process { StartInfo = { FileName = $"{OS}luac", Arguments = "-o \"" + l + "\" \"" + t1 + "\"", UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true } }; proc.OutputDataReceived += (sender, args) => { err += args.Data; }; proc.ErrorDataReceived += (sender, args) => { err += args.Data; }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); proc.WaitForExit(); error = err; if (!File.Exists(l)) { return(false); } Console.WriteLine("Obfuscating..."); Deserializer des = new Deserializer(File.ReadAllBytes(l)); Chunk lChunk = des.DecodeFile(); if (settings.ControlFlow) { CFContext cf = new CFContext(lChunk); cf.DoChunks(); } Console.WriteLine("Serializing..."); //shuffle stuff //lChunk.Constants.Shuffle(); //lChunk.Functions.Shuffle(); ObfuscationContext context = new ObfuscationContext(lChunk); string t2 = Path.Combine(path, "t2.lua"); string c = new Generator(context).GenerateVM(settings); //string byteLocal = c.Substring(null, "\n"); //string rest = c.Substring("\n"); File.WriteAllText(t2, c, _fuckingLua); string t3 = Path.Combine(path, "t3.lua"); Console.WriteLine("Minifying..."); proc = new Process { StartInfo = { FileName = $"{OS}luajit", Arguments = "../Lua/Minifier/luasrcdiet.lua --maximum --opt-entropy --opt-emptylines --opt-eols --opt-numbers --opt-whitespace --opt-locals --noopt-strings \"" + t2 + "\" -o \"" + t3 + "\"" , } }; proc.Start(); proc.WaitForExit(); if (!File.Exists(t3)) { return(false); } Console.WriteLine("Watermark..."); File.WriteAllText(Path.Combine(path, "out.lua"), @"--[[ IronBrew:tm: obfuscation; Version 2.7.0 ........................................................................................................................................................................................................ ........................................................................................................................................................................................................ .....,,...,............................................................................................................................................................................................. .... MMMMM,............................................................................................................................................................................................. ....MMMMMMM,............................................................................................................................................................................................ ....MMMMMMM,............................................................................................................................................................................................ ....,MMMMMO............................................................................................................................................................................................. ......,................................................................................................................................................................................................. ..................................................,,,,,,............................................Z$$................................................................................................. ...................................................:::::............................................MMMO................................................................................................ .....:???? ,.......:????....,.8MMMMM,.......,,,MMMMI???INMMM.,................,.?ZMMMMDI:,,.........MMM$................................................................................................ .....MMMMM?,.......MMMMM,,.OMMMMMMMM......, 7MM+?+++++++++?+DM$ .............MMMMMMMMMMMMMM ,,......MMM$................................................................................................ .....MMMMM?,.......MMMMM..NMMMMMMMMM.,...,$M7++++++++++++++++++M$ .........MMMMMMMMMMMMMMMMMN .,....MMM$................................................................................................ .....MMMMM?,.......MMMMMMMMMMM8..,,,.,..,MM?++++++++++++++++++++MM,,......MMMMMMMM~,.+MMMMMMMM......MMM$................................................................................................ .....MMMMM?,.......MMMMMMMMZ ,,.......MMMMMMMMMMMMMDZZZZMMMMMMMMMMMMM ...MMMMMM,,,....., MMMMMM.....MMM$................................,.,,............................................................ .....MMMMM?,.......MMMMMMM:............MMMMMMMMMMMMMMMMMMMMMMMMMMMMM....MMMMMD,...........MMMMMM.,..MMM$...:MMMMMMMM:,........8MMM:.,DMMMMM,......?MMMMMMMMI.........MMMM......... MMM,.........MMMI.... .....MMMMM?,.......MMMMMM+............,M?+MMMMMMMMMM++?DMMMMMMMMM?+M,...MMMMM,.............MMMMM,,..MMM$,NMMMMMMMMMMMM8,.,....MMMM,NMMMMMMM,..,,MMMMMMMMMMMMMM.,.....MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMMM,............,M?++MMMMMMMM7++++MMMMMMMM$??MM,,+MMMMM,.............MMMMM=...MMM$,MMMZ...,?MMMMMM,.....MMMMMMMMM,......DMMMMM:,....MMMMMN,....MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMMM.............MM+??+MMMMMMM?++++MMMMMMMD??+$M,.MMMMM?.............,MMMMM?...MMM$,M,.,...,,,,MMMMM,....MMMMMM,,,,....,MMMMM,..,....,.MDNN$....MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMM?,............MM??++???????++++++?????+++++7M..$MMMM,.............,?MMMM.,..MMM$.............OMMMM....MMMMM.........$MMMM,....... MMMMMM.,...MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMM=,............NM?+++++++++++++++++++++++++?$M..MMMMM+,............,+MMMM+,..NMN$..............MMMM+,..MMMMM.........MMMM......,?MMMMM?.,.....MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMM,,............,M+?+++++++?++++++++?+?++++++M7,,DMMMM:...............MMMM:,..MMMN.,............$MMM7...MMMM=.........MMMM....,DMMMMM..........MMMM.........7MMM7.........MMM$.... .....MMMMM?,.......MMMMM,,............:M$?++++?MM+++++++++DM?+++++?M,,,DMMMM+,..............MMMM+,..MMMM.,............?NMM?,..ZMMM,,........MMMM.,.MMMMMM,,..........MMMM,........7MMM7.........MMM$.... .....MMMMM?,.......MMMMM,,.............,M=++++++DMD++?++DMM+++++++M:...$MMMM.,..............MMMM ,..MMMM..............OMMM,,..OMMM,,........MMMM.,MMMM?,,......MNZ,,,MMMM.........IMMM?,........MMM?.... .....MMMMM?,.......MMMMM,,...............M+?+++++?+ZMMMN+++?+++++M7,...$MMMM................MMMM.,..=MMMN,..........,,MNMM.,..OMMM,.........?MMMI.,M..........,MMM,.,NMMM,........IMMMI.........MMM?.... .....MMMMM?,.......MMMMM,,................M7+?+++++++++++++++++IM,,....$MMMM,...............MMMM,....MMMMN.,......,,.MMMM,....OMMM,,........,MMMMN..........,+MMM,...,MMMN,.....,,MMMMM,,,.....MMMM..... .....MMMMM?,.......MMMMM,,................,MM++++?++++++++????MM.......$MMMM,...............MMMM,.....MNMMM$,......MMMMM .....OMMM,,..........MMMMM~......,,MMMM ,....MMMMM,,,..~MMMMMMM~,,,.,MMMMM..... .....MMMMM?,.......MMMMM,,.................,,MMD+++++++++++$MM,.,......$MMMM,...............MMMM,.....,+NMMMMMMMMMMMMMM..,....OMMM,,.......... +NMMMMMMMMMMMMMM,.......MMMMMMMMMMMMN,NMMMMMMMMMMMN,..... .....MMMMM?........MMMMM,,.....................::MMMMMMMMM$.,.........,ZMMMM,,..............MMMM,,......, MMMMMMMMMM:.,,......+MMM................MMMMMMMMMM7,,,......,.,MMMMMMMMN.:...MMMMMMMMM,,...... ..........,.......,,.....,.........................,,,,.,...................................................,.,,.,,,...........,,,..................,,..,,,,..............,,..,,,.......,,.,,,,......... ........................................................................................................................................................................................................ ]] " + File.ReadAllText(t3, _fuckingLua).Replace("\n", " "), _fuckingLua); return(true); } catch (Exception e) { Console.WriteLine("ERROR"); Console.WriteLine(e); error = e.ToString(); return(false); } }