灰帽子里面的pydbg代码

这里除了代码,也放上几个自己写的有漏洞的exe程序方便大家调试,有漏洞的exe程序在:

http://howfile.com/file/2611e8a1/8c414bff/


程序功能只是每隔一秒标题数字加1,有了快照,那么数字可以还原到快照时刻


代码如下,注意修改程序路径,这里的程序是压缩包的 “快照测试.exe”

from pydbg  import *
from pydbg.defines import *
import threading
import time
import sys
class snapshotter(object):
    def __init__(self,exe_path):

        self.exe_path     = exe_path
        self.pid          = None
        self.dbg          = None
        self.running      = True
	
       
        pydbg_thread = threading.Thread(target=self.start_debugger)
        pydbg_thread.setDaemon(0)
        pydbg_thread.start()
            
        while self.pid == None:
            time.sleep(1)
        
        
        monitor_thread = threading.Thread(target=self.monitor_debugger)
        monitor_thread.setDaemon(0)
        monitor_thread.start()
                 
    def monitor_debugger(self): 
        
        while self.running == True:
            
            input = raw_input("Enter: 'snap','restore' or 'quit'")
            input = input.lower().strip()
            
            if input == "quit":
                print "[*] Exiting the snapshotter."
                self.running = False
                self.dbg.terminate_process()
                
            elif input == "snap":
                
                print "[*] Suspending all threads."
                self.dbg.suspend_all_threads()
                
                print "[*] Obtaining snapshot."
                self.dbg.process_snapshot()
                
                print "[*] Resuming operation."
                self.dbg.resume_all_threads()
            
            elif input == "restore":
                
                print "[*] Suspending all threads."
                self.dbg.suspend_all_threads()
                
                print "[*] Restoring snapshot."
                self.dbg.process_restore()
                
                print "[*] Resuming operation."
                self.dbg.resume_all_threads()
                
    def start_debugger(self):
        self.dbg = pydbg()
        pid = self.dbg.load(self.exe_path)
        self.pid = self.dbg.pid
        self.dbg.run()


exe_path = "C:\\aaa.exe"
        
snapshotter(exe_path)	


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值