From 85e0a54e351b592ae012c5b3c843bb4055997b17 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 14 May 2017 18:11:22 -0700 Subject: [PATCH] Fix Python 3 samples (#836) --- bindings/python/sample_arm64.py | 2 +- bindings/python/sample_arm64eb.py | 2 +- bindings/python/sample_x86.py | 2 +- bindings/python/shellcode.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/python/sample_arm64.py b/bindings/python/sample_arm64.py index 41bd9c34..4b92f098 100755 --- a/bindings/python/sample_arm64.py +++ b/bindings/python/sample_arm64.py @@ -53,7 +53,7 @@ def test_arm64(): # now print out some registers print(">>> Emulation done. Below is the CPU context") - print(">>> As little endian, X15 should be 0x78:"); + print(">>> As little endian, X15 should be 0x78:") x11 = mu.reg_read(UC_ARM64_REG_X11) x13 = mu.reg_read(UC_ARM64_REG_X13) diff --git a/bindings/python/sample_arm64eb.py b/bindings/python/sample_arm64eb.py index 6d46fb5e..4d96f46d 100755 --- a/bindings/python/sample_arm64eb.py +++ b/bindings/python/sample_arm64eb.py @@ -54,7 +54,7 @@ def test_arm64(): # now print out some registers print(">>> Emulation done. Below is the CPU context") - print(">>> As big endian, X15 should be 0x12:"); + print(">>> As big endian, X15 should be 0x12:") x11 = mu.reg_read(UC_ARM64_REG_X11) x13 = mu.reg_read(UC_ARM64_REG_X13) diff --git a/bindings/python/sample_x86.py b/bindings/python/sample_x86.py index a6a54615..32619025 100755 --- a/bindings/python/sample_x86.py +++ b/bindings/python/sample_x86.py @@ -431,7 +431,7 @@ def test_i386_inout(): def test_i386_context_save(): print("Save/restore CPU context in opaque blob") address = 0 - code = '\x40' # inc eax + code = b'\x40' # inc eax try: # Initialize emulator mu = Uc(UC_ARCH_X86, UC_MODE_32) diff --git a/bindings/python/shellcode.py b/bindings/python/shellcode.py index ed65effa..e7b68207 100755 --- a/bindings/python/shellcode.py +++ b/bindings/python/shellcode.py @@ -10,7 +10,7 @@ X86_CODE32 = b"\xeb\x19\x31\xc0\x31\xdb\x31\xd2\x31\xc9\xb0\x04\xb3\x01\x59\xb2\ X86_CODE32_SELF = b"\xeb\x1c\x5a\x89\xd6\x8b\x02\x66\x3d\xca\x7d\x75\x06\x66\x05\x03\x03\x89\x02\xfe\xc2\x3d\x41\x41\x41\x41\x75\xe9\xff\xe6\xe8\xdf\xff\xff\xff\x31\xd2\x6a\x0b\x58\x99\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\xca\x7d\x41\x41\x41\x41\x41\x41\x41\x41" -X86_CODE64 = "\x48\x31\xff\x57\x57\x5e\x5a\x48\xbf\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xef\x08\x57\x54\x5f\x6a\x3b\x58\x0f\x05" +X86_CODE64 = b"\x48\x31\xff\x57\x57\x5e\x5a\x48\xbf\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xef\x08\x57\x54\x5f\x6a\x3b\x58\x0f\x05" # memory address where emulation starts ADDRESS = 0x1000000