【问题标题】:PyDBG process snapshots not workingPyDBG 进程快照不起作用
【发布时间】:2012-06-11 16:57:57
【问题描述】:

我正在关注 Gray Hat 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)

【问题讨论】:

    标签: snapshot pydbg


    【解决方案1】:

    您的代码在 XP SP1(虚拟机)上的 Python 2.7 上为我工作。您运行的是哪个版本的 Windows?另外,它可能是你的 pydbg 安装吗?我正在使用在以下位置找到的二进制文件:

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

    【讨论】:

    • 问题将出现在 windows 7 上。这本书是为 windows XP 编写的,bur 进程快照似乎在 windows 7 上不起作用,可能是由于比特率。我从来没有让它工作,但我使用 64 位 python 发行版取得了进展......
    猜你喜欢
    • 2015-02-23
    • 1970-01-01
    • 2018-07-27
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-07
    • 1970-01-01
    相关资源
    最近更新 更多