2012-06-07 2 views
1

저는 Gray Hat Python 책을 읽고 PyDBG를 사용하여 프로세스 스냅 샷 코드를 복사했습니다. 스크립트를 실행할 때 오류가없고 예상되는 결과가 나오지만 프로그램이 실제로 스냅 샷으로 되돌아 가지 않습니다. 내가 디버그에 들어가면 마치 스냅 샷 정보를 저장하는 것처럼 값이 스냅 샷 변수에있는 것처럼 보이지만 확실하게 말할 충분한 것을 알지 못합니다.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) 

답변

0

귀하의 코드가 XP SP1 (가상 머신)에 파이썬 2.7에 나를 위해 일한 : 여기

는 코드입니다. 실행중인 Windows 버전은 무엇입니까? 또한, 그것은 pydbg 설치 수 있습니까? , 가시 프로세스 스냅 숏 아마 비트 레이트로 인해, 윈도우 7에서 작동하는 것 나던 문제는 창문이 책은 윈도우 XP 용으로 작성되었다 (7)에있을 것입니다

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

+1

: 난에서 발견 바이너리를 사용하고 있습니다 . 절대로 작동하지 않지만 64 비트 파이썬 배포판을 사용하여 진행했습니다 ... –

관련 문제