def test_command_patch_qword(self): before = gdb_start_silent_command_last_line("x/8bx $pc") after = gdb_start_silent_command_last_line("patch qword $pc 0x4242424242424242", after=["x/8bx $pc",]) self.assertNoException(after) r = difflib.SequenceMatcher(None, before, after).ratio() self.assertTrue( r > 0.50 ) return
def test_command_patch_dword(self): before = gdb_start_silent_command_last_line("display/8bx $pc") after = gdb_start_silent_command_last_line("patch dword $pc 0x42424242", after=["display/8bx $pc",]) self.assertNoException(after) r = difflib.SequenceMatcher(None, before, after).ratio() self.assertTrue( 0.80 < r < 0.90 ) return
def test_command_patch_qword(self): before = gdb_start_silent_command_last_line("x/8bx $pc") after = gdb_start_silent_command_last_line("patch qword $pc 0x4242424242424242", after=["x/8bx $pc",]) self.assertNoException(after) r = difflib.SequenceMatcher(None, before, after).ratio() self.assertTrue( 0.50 < r < 0.70 ) return
def test_command_edit_flags(self): self.assertFailIfInactiveSession(gdb_run_command("edit-flags")) # force enable flag res = gdb_start_silent_command_last_line("edit-flags +carry") self.assertNoException(res) self.assertTrue(b"CARRY " in res) # force disable flag res = gdb_start_silent_command_last_line("edit-flags -carry") self.assertNoException(res) self.assertTrue(b"carry " in res) # toggle flag before = gdb_start_silent_command_last_line("edit-flags") self.assertNoException(before) after = gdb_start_silent_command_last_line("edit-flags ~carry") self.assertNoException(after) s = difflib.SequenceMatcher(None, before, after) self.assertTrue(s.ratio() > 0.90) return
def test_command_patch_string(self): res = gdb_start_silent_command_last_line( "patch string $sp \"Gef!Gef!Gef!Gef!\"", after=[ "grep Gef!Gef!Gef!Gef!", ]) self.assertNoException(res) self.assertTrue(b"\"Gef!Gef!Gef!Gef!\"" in res) return
def test_command_edit_flags(self): self.assertFailIfInactiveSession(gdb_run_command("edit-flags")) # force enable flag res = gdb_start_silent_command_last_line("edit-flags +carry") self.assertNoException(res) self.assertTrue(b"CARRY " in res) # force disable flag res = gdb_start_silent_command_last_line("edit-flags -carry") self.assertNoException(res) self.assertTrue(b"carry " in res) # toggle flag before = gdb_start_silent_command_last_line("edit-flags") self.assertNoException(before) after = gdb_start_silent_command_last_line("edit-flags ~carry") self.assertNoException(after) s = difflib.SequenceMatcher(None, before, after) self.assertTrue(s.ratio() > 0.90) return
def test_command_patch_string(self): res = gdb_start_silent_command_last_line("patch string $sp \"Gef!Gef!Gef!Gef!\"", after=["grep Gef!Gef!Gef!Gef!",]) self.assertNoException(res) self.assertTrue(b"\"Gef!Gef!Gef!Gef!\"" in res) return