def add_hook(self): input = InputDialog.input(hint='insert pointer') if input[0]: ptr = int(self.app.get_script().exports.getpt(input[1]), 16) if ptr > 0: hook = self.app.get_script().exports.hook(ptr) if hook: self.insertRow(self.rowCount()) h = Hook() h.set_ptr(ptr) h.set_input(input[1]) h.set_widget_row(self.rowCount() - 1) self.hooks[ptr] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(ptr)) q.setForeground(Qt.red) self.setItem(self.rowCount() - 1, 1, q) q = NotEditableTableWidgetItem('0') self.setItem(self.rowCount() - 1, 2, q) self.resizeColumnsToContents()
def hook_native_callback(self, hook): if self.columnCount() == 0: self.setColumnCount(2) self.setHorizontalHeaderLabels(['input', 'address']) self.insertRow(self.rowCount()) q = HookWidget(hook.get_input()) q.set_hook_data(hook) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 0, q) q = MemoryAddressWidget(hex(hook.get_ptr())) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_java_callback(self, class_method): self.insertRow(self.rowCount()) h = Hook() h.set_ptr(1) h.set_input(class_method) if self.java_pending_args: h.set_condition(self.java_pending_args['condition']) h.set_logic(self.java_pending_args['logic']) parts = class_method.split('.') self.java_hooks[class_method] = h q = HookWidget('.'.join(parts[:len(parts)-1])) q.set_hook_data(h) q.setForeground(Qt.darkYellow) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(parts[len(parts) - 1]) self.setItem(self.rowCount() - 1, 1, q) q = NotEditableTableWidgetItem('0') q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 2, q) self.resizeRowToContents(0) self.resizeRowToContents(1)
def hook_native_callback(self, ptr): self.insertRow(self.rowCount()) h = Hook(Hook.HOOK_NATIVE) h.set_ptr(ptr) h.set_input(self.temporary_input) self.temporary_input = '' if self.native_pending_args: h.set_condition(self.native_pending_args['condition']) h.set_logic(self.native_pending_args['logic']) self.native_pending_args = {} self.hooks[ptr] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 0, q) q = MemoryAddressWidget(hex(ptr)) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_onload_callback(self, h): if h is None: return if self.columnCount() == 0: self.setColumnCount(2) self.setHorizontalHeaderLabels(['input', 'address']) self.insertRow(self.rowCount()) q = HookWidget(h.get_input()) q.set_hook_data(h) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.darkGreen) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(0)) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_java_callback(self, hook): if self.columnCount() == 0: self.setColumnCount(2) self.setHorizontalHeaderLabels(['input', 'address']) self.insertRow(self.rowCount()) parts = hook.get_input().split('.') q = HookWidget('.'.join(parts[:len(parts) - 1])) q.set_hook_data(hook) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.darkYellow) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(parts[len(parts) - 1]) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.white) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_onload(self, input=None): if input is None or not isinstance(input, str): input = InputDialog.input(self.app, hint='insert module name', placeholder='libtarget.so') if not input[0]: return input = input[1] if len(input) == 0: return if not input.endswith('.so'): input += '.so' if input in self.app.get_dwarf().on_loads: return if self.columnCount() == 0: self.setColumnCount(2) self.setHorizontalHeaderLabels(['input', 'address']) h = self.app.get_dwarf().hook_onload(input) self.insertRow(self.rowCount()) q = HookWidget(h.get_input()) q.set_hook_data(h) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.darkGreen) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(0)) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_java_callback(self, class_method): self.insertRow(self.rowCount()) h = Hook(Hook.HOOK_JAVA) h.set_ptr(1) h.set_input(class_method) if self.java_pending_args: h.set_condition(self.java_pending_args['condition']) h.set_logic(self.java_pending_args['logic']) parts = class_method.split('.') self.java_hooks[class_method] = h q = HookWidget('.'.join(parts[:len(parts) - 1])) q.set_hook_data(h) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.darkYellow) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(parts[len(parts) - 1]) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.white) self.setItem(self.rowCount() - 1, 1, q) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_onload(self, input=None): if input is None or not isinstance(input, str): input = InputDialog.input(hint='insert module name') if not input[0]: return input = input[1] if len(input) == 0: return if not input.endswith('.so'): input += '.so' if input in self.onloads: return self.insertRow(self.rowCount()) h = Hook(Hook.HOOK_ONLOAD) h.set_ptr(0) h.set_input(input) self.onloads[input] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.darkGreen) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(0)) q.setFlags(Qt.NoItemFlags) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 1, q) self.app.dwarf_api('hookOnLoad', input) self.resizeRowsToContents() self.horizontalHeader().setStretchLastSection(True)
def hook_on_load(self): input = InputDialog.input(hint='insert module name') if input[0]: module = input[1] if not module.endswith('.so'): module += '.so' self.insertRow(self.rowCount()) h = Hook() h.set_ptr(0) h.set_input(module) h.set_widget_row(self.rowCount() - 1) self.onloads[module] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setForeground(Qt.darkGreen) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(0)) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 1, q) q = NotEditableTableWidgetItem('-') q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 2, q) self.app.get_script().exports.onload(module)
def hook_native_callback(self, ptr): self.insertRow(self.rowCount()) h = Hook() h.set_ptr(ptr) h.set_input(self.temporary_input) if self.native_pending_args: h.set_condition(self.native_pending_args['condition']) h.set_logic(self.native_pending_args['logic']) self.hooks[ptr] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(ptr)) q.setForeground(Qt.red) self.setItem(self.rowCount() - 1, 1, q) q = NotEditableTableWidgetItem('0') q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 2, q) self.resizeRowToContents(0) self.resizeRowToContents(1)
def hook_onload(self, input=None): if input is None or not isinstance(input, str): input = InputDialog.input(hint='insert module name') if not input[0]: return input = input[1] if not input.endswith('.so'): input += '.so' if input in self.onloads: return self.insertRow(self.rowCount()) h = Hook() h.set_ptr(0) h.set_input(input) self.onloads[input] = h q = HookWidget(h.get_input()) q.set_hook_data(h) q.setForeground(Qt.darkGreen) self.setItem(self.rowCount() - 1, 0, q) q = NotEditableTableWidgetItem(hex(0)) q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 1, q) q = NotEditableTableWidgetItem('-') q.setForeground(Qt.gray) self.setItem(self.rowCount() - 1, 2, q) self.app.get_script().exports.onload(input) self.resizeRowToContents(0) self.resizeRowToContents(1)