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