Articles

Affichage des articles du août, 2017

Cracking Lua program using code injection

Image
Hello, t his is the writeup of a small crackme I made. Crackme download links: 32 bit : https://drive.google.com/open?id=0B7U3AsTA9UVfQzVGbHl0cTRTa00 64 bit : https://drive.google.com/open?id=0B7U3AsTA9UVfYTYwZWt3dER0ems Source code : https://pastebin.com/v3EfAtLu Method 1 (The recommended way) After reading the hints (there is an obvious flaw in the source code), we start thinking, what are the possible security flaws in a Lua program? After looking at the Wikipedia page of Lua, we find an interesting section : the C API, we find a code snippet that executes code in the context of the program. #include <stdio.h> #include <lua.h> //Lua main library (lua_*) #include <lauxlib.h> //Lua auxiliary library (luaL_*) int main(void) {     //create a Lua state     lua_State *L = luaL_newstate();     //load and execute a string     if (luaL_dostring(L, "function foo (x,y) return x+y end")) {         return -1;     }     lua_close(L);     return 0; } One