lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


hi
I am trying to create a binder for Lua .
I am writting binder in visual C++ 2010.
in this program we must create lua52.dll and lua52.exe in a special path and also create script file we need to run in that path , so the script can run with 2 file ( lua52.dll and lua52.exe must be in the target system to run every script in Lua).
for creating lua52.dll in the target system we must create a exe file and raise the size of it .
HANDLE hFile3=CreateFile("C:\\a.exe", GENERIC_READ | GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_FLAG_OVERLAPPED,NULL);
CloseHandle(hFile3);
FILE *p,*q;
p=fopen("C:\\a.exe","w");
int pp=0;
while(pp<270000)
{
putc(NULL,p);
pp++;
}
fclose(p);
after that we must inject code of lua52.exe to that created file . we get the code of lua52.exe with using Ollydbg . the first hex code are :
unsigned char data[256] = {
    0x4D, 0x5A, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00,
    0xB8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
    0x0E, 0x1F, 0xBA, 0x0E, 0x00, 0xB4, 0x09, 0xCD, 0x21, 0xB8, 0x01, 0x4C, 0xCD, 0x21, 0x54, 0x68,
    0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F,
    0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20,
    0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0D, 0x0A, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x50, 0x45, 0x00, 0x00, 0x4C, 0x01, 0x15, 0x00, 0xDE, 0x01, 0xEA, 0x4F, 0x00, 0x06, 0x03, 0x00,
    0x40, 0x09, 0x00, 0x00, 0xE0, 0x00, 0x06, 0x21, 0x0B, 0x01, 0x02, 0x16, 0x00, 0xBE, 0x01, 0x00,
    0x00, 0xB2, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x58, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
    0x00, 0xD0, 0x01, 0x00, 0x00, 0x00, 0x78, 0x6D, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
    0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0xF0, 0x03, 0x00, 0x00, 0x06, 0x00, 0x00, 0xC7, 0xEC, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x02, 0x00, 0x1F, 0x0E, 0x00, 0x00
};
now I search for how to inject them to target file ?