{"id":16909265,"url":"https://github.com/jumanji144/lvm","last_synced_at":"2025-10-24T11:06:30.910Z","repository":{"id":49405292,"uuid":"517436940","full_name":"jumanji144/LVM","owner":"jumanji144","description":"Lua virtualsation toolset in Java","archived":false,"fork":false,"pushed_at":"2022-09-01T18:43:02.000Z","size":361,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T11:52:27.874Z","etag":null,"topics":["bytecode","deobf","deobfuscation","file","interpreter","java","lua","parser","reader","reverse-engineering","scripting","virtual-machine","virtualization","vm"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jumanji144.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-24T21:07:03.000Z","updated_at":"2025-03-03T12:21:41.000Z","dependencies_parsed_at":"2022-09-15T01:21:45.129Z","dependency_job_id":null,"html_url":"https://github.com/jumanji144/LVM","commit_stats":null,"previous_names":["jumanji144/lvm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanji144%2FLVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanji144%2FLVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanji144%2FLVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumanji144%2FLVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumanji144","download_url":"https://codeload.github.com/jumanji144/LVM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248434615,"owners_count":21102877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytecode","deobf","deobfuscation","file","interpreter","java","lua","parser","reader","reverse-engineering","scripting","virtual-machine","virtualization","vm"],"created_at":"2024-10-13T18:55:07.436Z","updated_at":"2025-10-24T11:06:25.870Z","avatar_url":"https://github.com/jumanji144.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LVM\nLua virtualsation toolset in Java\n\n## Parts\n- [x] bytecode parsing libary (5.x)\n- [x] instruction sets (DONE: 5.1)\n- [ ] emulation of execution (IN PROGRESS)\n- [ ] access of frames and interception\n\n## Goals\nTo be used to analyse and other things on compiled lua scripts\n\n## Usages\n\n### File parser\nThe file parser works for all luac compiled files from version 5.0 -\u003e 5.3   \nHere is some simple code to read a compiled file:\n```java\n...\nbyte[] data = ...;\nLuaDataStream stream = new LuaDataStream(data);\nLuaFileReader reader = new LuaFileReader(stream);\n\nLuaFile file = reader.read();\n```\n\n### Disassembly and intstruction operations\nDisassembly gives direct insight into the programs behaviour and operations\n```java\n...\nLuaFunction main = file.getFunction();\nDisassembler disasm = new Disassembler(main, System.out);\ndisasm.disassemble(); // print disassembly to main\n\n// assuming that some function calls get set up in this sample\nClosureInstruction inst = main.getInstructions().get(0); \n// get the function referenced by this instruction\nLuaFunction refFunction = inst.getProto();\n...\n```\n\n### Virtual machine \u0026 code exection\nThe Virtual machine allows for virtualizing and executing compiled bytecode allowing for full static analysis of lua binaries\n```java\n// prepare a vm\nVM vm = new VM();\nvm.initialize();\n// execute the main function\nExecutionContext result = vm.getHelper().invoke(main, vm.getGlobal());\nValue val = results.get(0); // get R0\n\nSystem.out.println(val.asString()); // print R0\n```\n\n#### Function overwriting\nIn the vm it is possible to overwrite functions to give control what these do, this includes library functions\n```java\n// get the vm libraries\nLibraries libs = vm.getLibraries();\nLibrary base = libs.getTop(); // get the top library (the base library)\n// choose a method (in this case 'print')\n// then provide a new method to execute\nbase.set(\"print\", (ctx) -\u003e {\n    System.out.println(\"Custom print call!\");\t\n});\n\n// or during/before execution access the global table and overwrite functions directly\nTable global = vm.getGlobal();\n// first define a new Closure\nClosure customClosure = new Closure((ctx) -\u003e {   \n\tSystem.out.println(\"Intercepted call!\");\n});\n// wrap in ClosureValue\nClosureValue value = new ClosureValue(customClosure);        \n// set new closure\nglobal.set(\"customFunction\", value);\n```\n\n#### Instruction overwriting\nIt is also possible to overwrite the behaviour of specific instructions entirely\n```java\nvm.getInterpreter().install(Opcodes.MOVE, (Executor\u003cLoadInstruction\u003e) (insn, ctx) -\u003e {\n\tSystem.out.println(\"Custom instructions\");\n});\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumanji144%2Flvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumanji144%2Flvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumanji144%2Flvm/lists"}