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)
mointor_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 thread"
self.dbg.suspend_all_thread()
print "[*] Obtaining snapshot."
self.dbg.process_snapshot()
print "[*] Resuming operation"
self.dbg.resume_all_thread()
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)
'프로그래밍 도서관 > Python 리버싱 프로그래밍 스터디' 카테고리의 다른 글
| immunity_dbg (1) | 2022.10.11 |
|---|---|
| pydbg_danger_track (1) | 2022.10.10 |
| pydbg_overflow and access_violation_handler (1) | 2022.10.10 |
| pydbg (1) | 2022.10.10 |
| 파이썬 해킹 프로그래밍 (0) | 2022.07.10 |