forked from god12l/olympia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigscan.py
83 lines (61 loc) · 3.2 KB
/
sigscan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from __future__ import annotations
import tkinter as tk
from tkinter import ttk, messagebox
from synapse import Synapse
from objects import Instance
from offsets import OffsetFinder
class Sigscan:
def __init__(self, root: tk.Toplevel, synapse: Synapse) -> Sigscan:
self.root = root
self.synapse = synapse
self.leftFrame = ttk.Frame(self.root, padding=(10, 10, 10, 10))
self.inputLabel = ttk.Label(self.leftFrame, text="Signature:")
self.inputEntry = ttk.Entry(self.leftFrame)
self.confirmButton = ttk.Button(self.leftFrame, text="Confirm", command=self.onConfirm)
self.listbox = tk.Listbox(self.leftFrame, selectmode=tk.SINGLE, height=16)
self.rightFrame = ttk.Frame(self.root, padding=(10, 10, 10, 10))
self.hexViewer = tk.Text(self.rightFrame, wrap=tk.WORD, height=20, width=30, state=tk.DISABLED)
self.selectedItem = ""
self.signature = ""
self.signatureLength = 0
self.leftFrame.grid(column=0, row=0, sticky=(tk.W, tk.E, tk.N, tk.S))
self.inputLabel.grid(column=0, row=0, sticky=tk.W)
self.inputEntry.grid(column=0, row=1, pady=5, sticky=tk.W)
self.confirmButton.grid(column=1, row=1, padx=5, pady=5, sticky=tk.W)
self.listbox.grid(column=0, row=2, columnspan=2, pady=10, sticky=(tk.W, tk.E, tk.N, tk.S))
self.listbox.bind("<<ListboxSelect>>", self.onListboxSelect)
self.rightFrame.grid(column=1, row=0, sticky=(tk.W, tk.E, tk.N, tk.S))
self.hexViewer.grid(column=0, row=1, sticky=(tk.W, tk.E, tk.N, tk.S))
self.hexViewer.tag_config('match', background="yellow", foreground="red")
def onConfirm(self):
self.signature = self.inputEntry.get()
self.signatureLength = int(len(self.signature) / 2)
results = self.synapse.aobScan(self.signature, True)
if results == []:
messagebox.showerror("Sigscan", "No results found.")
return
for rn in results:
try:
bytes = self.synapse.memory.read_bytes(rn, self.signatureLength)
print(f"signature match: 0x{self.synapse.d2h(rn)}, {bytes.hex()}")
self.listbox.insert(tk.END, f"0x{self.synapse.d2h(rn)}")
except:
pass
def onListboxSelect(self, event):
self.selectedItem = self.listbox.get(self.listbox.curselection())
self.updateHexViewer()
def updateHexViewer(self):
address = self.synapse.h2d(self.selectedItem)
signBytes = self.synapse.memory.read_bytes(address, self.signatureLength)
signHex = signBytes.hex()
tailBytes = self.synapse.memory.read_bytes(address + self.signatureLength, 0x20)
tailHex = tailBytes.hex()
signHexData = " ".join([signHex.upper()[i:i+2] for i in range(0, len(signHex), 2)])
tailHexData = " ".join([tailHex.upper()[i:i+2] for i in range(0, len(tailHex), 2)])
self.hexViewer.config(state=tk.NORMAL)
self.hexViewer.delete(1.0, tk.END)
self.hexViewer.insert(tk.END, signHexData, 'match')
self.hexViewer.insert(tk.END, " " + tailHexData)
self.hexViewer.config(state=tk.DISABLED)
def render(self):
self.root.mainloop()