6.3.1 自己动手写一个windows调试器

第一种方法, 其实就是从调试器本身调用这个程序 (调试器就是父进程, 对被调试进程

的控制权限更大) 。在 Windows 上创建一个进程用 CreateProcessA()函数。

1.my_debugger_defines.py文件

==============

from ctypes import *
# Let's map the Microsoft types to ctypes for clarity
WORD      = c_ushort
DWORD     = c_ulong
LPBYTE    = POINTER(c_ubyte)
LPTSTR    = POINTER(c_char) 
HANDLE    = c_void_p

# Constants
DEBUG_PROCESS         = 0x00000001
CREATE_NEW_CONSOLE    = 0x00000010

# Structures for CreateProcessA() function
# STARTUPINFO describes how to spawn the process
class STARTUPINFO(Structure):
    _fields_ = [
        ("cb",            DWORD),        
        ("lpReserved",    LPTSTR), 
        ("lpDesktop",     LPTSTR),  
        ("lpTitle",       LPTSTR),
        ("dwX",           DWORD),
        ("dwY",           DWORD),
        ("dwXSize",       DWORD),
        ("dwYSize",       DWORD),
        ("dwXCountChars", DWORD),
        ("dwYCountChars", DWORD),
        ("dwFillAttribute",DWORD),
        ("dwFlags",       DWORD),
        ("wShowWindow",   WORD),
        ("cbReserved2",   WORD),
        ("lpReserved2",   LPBYTE),
        ("hStdInput",     HANDLE),
        ("hStdOutput",    HANDLE),
        ("hStdError",     HANDLE),
        ]


# PROCESS_INFORMATION receives its information
# after the target process has been successfully
# started.
class PROCESS_INFORMATION(Structure):
    _fields_ = [
        ("hProcess",    HANDLE),
        ("hThread",     HANDLE),
        ("dwProcessId", DWORD),
        ("dwThreadId",  DWORD),
        ]

2.my_debugger.py                            调用my_debugger_defines.py

======================
from ctypes import *
from my_debugger_defines import *

kernel32 = windll.kernel32
class debugger():
    def __init__(self):
        pass        
    def load(self,path_to_exe):
        
        # dwCreation flag determines how to create the process
        # set creation_flags = CREATE_NEW_CONSOLE if you want
        # to see the calculator GUI
        creation_flags = DEBUG_PROCESS
    
        # instantiate the structs
        startupinfo         = STARTUPINFO()
        process_information = PROCESS_INFORMATION()
        
        # The following two options allow the started process
        # to be shown as a separate window. This also illustrates
        # how different settings in the STARTUPINFO struct can affect
        # the debuggee.
        startupinfo.dwFlags     = 0x1
        startupinfo.wShowWindow = 0x0
        
        # We then initialize the cb variable in the STARTUPINFO struct
        # which is just the size of the struct itself
        startupinfo.cb = sizeof(startupinfo)


        if kernel32.CreateProcessW(path_to_exe,
                                   None,
                                   None,
                                   None,
                                   None,
                                   creation_flags,
                                   None,
                                   None,
                                   byref(startupinfo),
                                   byref(process_information)):
            
            print ("[*] We have successfully launched the process!")
            print ("[*] PID:%d" % process_information.dwProcessId)
            
        else:    
            print ("[*] Error with error code %d." % kernel32.GetLastError())

3.my_test.py,      调用my_debugger.py

================

import my_debugger
                                        
debugger = my_debugger.debugger()
         
debugger.load('C:\\Windows\\System32\\calc.exe')
   

    本实例,就是在debugger_defines中定义了两个结构体,然后再debugger中的createprocessW进行调用,然后再test中运行。启动进程

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CDH 6.3.1 Parcel是支持Cloudera大数据平台的一种软件安装和部署方式。Parcel是一种二进制软件包的格式,用于在CDH集群中分发和安装各种组件和服务。CDH 6.3.1 Parcel即表示适用于CDH版本6.3.1的Parcel软件包。 CDH 6.3.1 Parcel是由Cloudera官方提供的,其中包含了一系列的开源大数据组件和工具,例如Hadoop、Hive、Spark、HBase等。这些组件和工具可以帮助用户处理和分析大规模的结构化和非结构化数据。它们被构建为高度扩展和分布式的系统,具有高可靠性和可伸缩性。 使用CDH 6.3.1 Parcel能够简化大数据平台的安装和管理过程。它可以通过Cloudera Manager进行集中管理和监控,用户可以通过Cloudera Manager进行集群的配置和升级,同时也提供了一套丰富的图形界面和命令行工具帮助用户管理和监控集群的运行状态。 CDH 6.3.1 Parcel还支持自定义配置和扩展。用户可以根据自己的需求进行集群的配置和组件的安装,同时还可以根据需要添加第三方工具和插件。这为用户提供了更大的灵活性和可定制性,可以根据自己的需求构建适合自己业务场景的大数据平台。 总之,CDH 6.3.1 Parcel是一种方便的软件包格式,用于安装和部署Cloudera大数据平台的各种组件和服务。它简化了集群的管理和监控,提供了灵活的配置和扩展选项,帮助用户构建高效、可靠的大数据集群。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值