不工作PyDBG进程快照(PyDBG process snapshots not working)

2019-10-16 20:07发布

我下面的灰帽Python书籍和复制了他们的代码使用PyDBG进程快照。 当我运行该脚本,我没有得到任何错误和预期产出但是我的程序实际上并未恢复到快照。 当我在调试去,好像值在快照变量,如果存储的快照信息,但我真的不知道,足以肯定地说。

这里是代码:

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:\\WINDOWS\\System32\\calc.exe"
snapshotter(exe_path)

Answer 1:

您的代码为我工作对XP SP1(虚拟机)的Python 2.7。 哪个版本的Windows,你运行? 此外,也可能是你pydbg安装? 我使用的是二进制,我发现在:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pydbg



文章来源: PyDBG process snapshots not working