コード例 #1
0
ファイル: frmMain.cs プロジェクト: sera619/LuaToolkit
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Title = "Select Binary File";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                if (!File.Exists(fileDialog.FileName))
                {
                    return;
                }

                var           luaF   = new LuaCFile(File.ReadAllBytes(fileDialog.FileName));
                LuaDecoder    d      = new LuaDecoder(luaF);
                LuaDecompiler writer = new LuaDecompiler(d);
                activeGraph = new frmGraph(writer);
                activeGraph.Show();

                lstFuncs.Items.Clear();
                foreach (var f in activeGraph.Writer.LuaFunctions)
                {
                    lstFuncs.Items.Add(f.ToString());
                }

                txtLuaCode.Text = activeGraph.Writer.LuaScript;
            }
        }
コード例 #2
0
        private void ThePersonalityTestShouldHaveBeenProperlyPatched()
        {
            var baseromProject = ApplicationViewModel.CurrentSolution.GetAllProjects().FirstOrDefault(p => p is BaseRomProject) as BaseRomProject;

            if (baseromProject == null)
            {
                Assert.Fail("Failed to find a BaseRomProject");
            }

            var originalScript = Path.Combine(baseromProject.GetRawFilesDir(), "RomFS", "script", "event", "other", "seikakushindan", "seikakushindan.lua");

            if (!File.Exists(originalScript))
            {
                Assert.Inconclusive("Failed to find original personality test script: " + originalScript);
            }

            var modifiedScript = Path.Combine(Environment.CurrentDirectory, "extracted-rom", "RomFS", "script", "event", "other", "seikakushindan", "seikakushindan.lua");

            if (!File.Exists(modifiedScript))
            {
                Assert.Fail("Failed to find modified personality test script: " + modifiedScript);
            }

            var originalScriptContents = LuaDecompiler.DecompileScript(File.ReadAllBytes(originalScript));
            var modifiedScriptContents = LuaDecompiler.DecompileScript(File.ReadAllBytes(modifiedScript));

            Assert.AreNotEqual(originalScriptContents, modifiedScriptContents, "The personality test script should be different than what it was before being patched.");
            Assert.IsTrue(modifiedScriptContents.Contains("WINDOW:SysMsg(200000)"), "The modified script should contain 'WINDOW:SysMsg(200000)', which is evidence of Sky Editor's modifications.");
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("[+] LuaSharpVM\r\n");
            //LuaObfuscator o = new LuaObfuscator(File.ReadAllBytes(@"L:\Projects\LuaBytcodeInterpreter\lua_installer\files\test_if.luac"));
            LuaObfuscator o = new LuaObfuscator(File.ReadAllBytes(@"L:\Projects\LuaBytcodeInterpreter\lua_installer\files\frost.luac"));

            //LuaObfuscator o = new LuaObfuscator(File.ReadAllBytes(@"L:\Projects\LuaBytcodeInterpreter\lua_installer\files\upvalues.luac"));

            // show original lua
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            LuaDecompiler w = new LuaDecompiler(o.Decoder);

            Console.WriteLine(w.LuaScript);
            Console.WriteLine(LuaBeautifier.BeautifieScript(w.LuaScript));

            // obfuscate
            o.Obfuscate("{'test':123}"); // TODO

            // show obfuscated lua
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine(new string('=', Console.WindowWidth));
            w = new LuaDecompiler(o.Decoder);
            Console.WriteLine(LuaBeautifier.BeautifieScript(w.LuaScript));

            Console.ReadLine();
        }
コード例 #4
0
 public Decompiler(byte[] Buffer)
 {
     this.Decoder       = new LuaDecoder(new LuaCFile(Buffer));
     this.LuaDecompiler = new LuaDecompiler(this.Decoder);
 }
コード例 #5
0
ファイル: frmGraph.cs プロジェクト: xxspokiixx/LuaToolkit
        public frmGraph(LuaDecompiler writter)
        {
            InitializeComponent();

            //Init Direct Draw
            //Set Rendering properties
            RenderTargetProperties renderProp = new RenderTargetProperties()
            {
                PixelFormat = new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied),
            };

            //set hwnd target properties (permit to attach Direct2D to window)
            HwndRenderTargetProperties winProp = new HwndRenderTargetProperties()
            {
                Hwnd           = this.Handle,
                PixelSize      = new Size2(this.ClientSize.Width, this.ClientSize.Height),
                PresentOptions = PresentOptions.None
            };

            //target creation
            DrawTarget = new WindowRenderTarget(factory, renderProp, winProp);

            //redBrush = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0xFE, 0x6B, 0x64, 0xFF));
            redBrush    = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(255, 0, 0, 255));
            yellowBrush = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0xFB, 0xFD, 0x98, 0xFF));
            greenBrush  = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0, 255, 0, 0xFF));
            //greenBrush = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0x77, 0xDD, 0x77, 0xFF));
            whiteBrush  = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0xFF, 0xFF, 0xFF, 0xFF));
            purpleBrush = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0xB2, 0x9D, 0xD9, 0xFF));
            blueBrush   = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0x77, 0x9E, 0xCB, 0xFF));
            blue2Brush  = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0, 0, 255, 255));
            blackBrush  = new SharpDX.Direct2D1.SolidColorBrush(DrawTarget, new RawColor4(0x00, 0x00, 0x00, 0xFF));

            backgroundBrush = new SharpDX.Direct2D1.LinearGradientBrush(DrawTarget, new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(0, (int)(this.Height * 0.2)),
                EndPoint   = new RawVector2(0, this.Height),
            },
                                                                        new SharpDX.Direct2D1.GradientStopCollection(DrawTarget, new SharpDX.Direct2D1.GradientStop[]
            {
                new GradientStop()
                {
                    Color    = new RawColor4(0xFF, 0xFF, 0xFF, 0xFF),
                    Position = 0,
                },
                new GradientStop()
                {
                    Color    = new RawColor4(140, 200, 00, 10), //E0F8FF
                    Position = 1,
                }
            }));

            //create textformat
            fontFat   = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Consolas", 36);
            fontBig   = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Consolas", 24);
            font      = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Consolas", 16);
            fontSmall = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Consolas", 12);
            fontMini  = new SharpDX.DirectWrite.TextFormat(factoryWrite, "Consolas", 8);

            //avoid artifacts
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            Writer = writter;

            Thread render = new Thread(new ThreadStart(drawloop));

            render.Priority = ThreadPriority.BelowNormal;
            render.Start();


            void drawloop()
            {
                Initialise(); // create graph blocks & arrows

                if (GBlocks.Count > 0)
                {
                    graphY = (int)GBlocks[TargetFunc].BoundryBox.Top; // jump to first block TODO: fix bug that causes this!
                }
                while (true)
                {
                    DrawData();
                    Thread.Sleep(50);
                }
            }
        }
コード例 #6
0
 public LuaObfuscator(byte[] originalLuaC)
 {
     this.ObfuscatedLuaC = originalLuaC;
     this.Decoder        = new LuaDecoder(new LuaCFile(this.ObfuscatedLuaC));
     this.Decompiler     = new LuaDecompiler(this.Decoder);
 }
コード例 #7
0
 public static void Closure(LuaFile.LuaFunction function, LuaFile.LuaOPCode opCode, int index, int functionLevel, LuaDecompiler luaDecomp)
 {
     function.Registers[opCode.A] = String.Format("__FUNC_{0:X}_", function.subFunctions[opCode.Bx].beginPosition);
     function.doingUpvals         = opCode.A;
     function.lastFunctionClosure = opCode.Bx;
     if (function.OPCodes[index + 1].OPCode != 0x54 && function.getName() != "__INIT__")
     {
         luaDecomp.doFunctionClosure(function, functionLevel);
     }
 }