python类LPCVOID的实例源码

named_pipes.py 文件源码 项目:driverlib 作者: sam-b 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def WriteFile(file, buffer, number_of_bytes_to_write, number_of_bytes_written, overlapped):
    """See: WriteFile function 
        https://msdn.microsoft.com/en-us/library/windows/desktop/aa365747(v=vs.85).aspx
    """
    WriteFile_Fn = windll.kernel32.WriteFile
    WriteFile_Fn.argtypes = [
        wintypes.HANDLE,    # _In_        HANDLE       hFile,
        wintypes.LPCVOID,   # _In_        LPCVOID      lpBuffer,
        wintypes.DWORD,     # _In_        DWORD        nNumberOfBytesToWrite,
        LPDWORD,            # _Out_opt_   LPDWORD      lpNumberOfBytesWritten,
        LPOVERLAPPED        # _Inout_opt_ LPOVERLAPPED lpOverlapped
    ]
    WriteFile_Fn.restype = wintypes.BOOL
    ret = wintypes.BOOL(WriteFile_Fn(
        file, 
        buffer, 
        number_of_bytes_to_write, 
        number_of_bytes_written, 
        overlapped
    ))
    return ret
driverlib.py 文件源码 项目:driverlib 作者: sam-b 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def control_service(service_handle, control, service_status):
    """See: ControlService function
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms682108(v=vs.85).aspx
    """
    ControlService_Fn = windll.Advapi32.ControlService      #BOOL WINAPI ControlService(
    ControlService_Fn.argtypes = [                          #
        wintypes.SC_HANDLE,                                 #   _In_  SC_HANDLE        hService,
        wintypes.DWORD,                                     #   _In_  DWORD            dwControl,
        wintypes.LPCVOID                                    #   _Out_ LPSERVICE_STATUS lpServiceStatus
    ]
    ControlService_Fn.restype = wintypes.BOOL
    bool = ControlService_Fn(
        service_handle,
        control,
        service_status
    )
    return bool
driverlib.py 文件源码 项目:win_driver_plugin 作者: mwrlabs 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def control_service(service_handle, control, service_status):
    """See: ControlService function
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms682108(v=vs.85).aspx
    """
    ControlService_Fn = windll.Advapi32.ControlService      #BOOL WINAPI ControlService(
    ControlService_Fn.argtypes = [                          #
        wintypes.SC_HANDLE,                                 #   _In_  SC_HANDLE        hService,
        wintypes.DWORD,                                     #   _In_  DWORD            dwControl,
        wintypes.LPCVOID                                    #   _Out_ LPSERVICE_STATUS lpServiceStatus
    ]
    ControlService_Fn.restype = wintypes.BOOL
    bool = ControlService_Fn(
        service_handle,
        control,
        service_status
    )
    return bool
create_dynamic_artifacts.py 文件源码 项目:TC2017 作者: G4lB1t 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_spora_mutex():
    """
    Creates a mutex just like the notorious Spora ransomware
    This prevents the execution of known Spora variants

    Based on Minerva's blog post:
    https://www.minerva-labs.com/post/vaccinating-against-spora-ransomware-a-proof-of-concept-tool-by-minerva
    """
    try:
        vol_serial = int(subprocess.check_output(['cmd', '/c', 'vol'])[-11:-2].replace("-", ""), 16)
        spora_mutex = 'm' + str(vol_serial)
        _CreateMutex = ctypes.windll.kernel32.CreateMutexA
        _CreateMutex.argtypes = [wintypes.LPCVOID, wintypes.BOOL, wintypes.LPCSTR]
        _CreateMutex.restype = wintypes.HANDLE

        ret = _CreateMutex(None, False, spora_mutex)
    except Exception as e:
        print "Got exception {0} while creating {1}".format(e, "Spora mutex")


问题


面经


文章

微信
公众号

扫码关注公众号