From c87a487fecf91e77340e6ac2942ab92b935f09db Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Fri, 29 Jul 2016 00:28:43 -0700 Subject: [PATCH] Get Python samples running on Python 3 --- bindings/python/sample_arm.py | 4 ++-- bindings/python/sample_arm64.py | 2 +- bindings/python/sample_m68k.py | 2 +- bindings/python/sample_mips.py | 4 ++-- bindings/python/sample_network_auditing.py | 2 +- bindings/python/sample_sparc.py | 2 +- bindings/python/sample_x86.py | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bindings/python/sample_arm.py b/bindings/python/sample_arm.py index 689412f7..a8491d19 100755 --- a/bindings/python/sample_arm.py +++ b/bindings/python/sample_arm.py @@ -8,8 +8,8 @@ from unicorn.arm_const import * # code to be emulated -ARM_CODE = "\x37\x00\xa0\xe3\x03\x10\x42\xe0" # mov r0, #0x37; sub r1, r2, r3 -THUMB_CODE = "\x83\xb0" # sub sp, #0xc +ARM_CODE = b"\x37\x00\xa0\xe3\x03\x10\x42\xe0" # mov r0, #0x37; sub r1, r2, r3 +THUMB_CODE = b"\x83\xb0" # sub sp, #0xc # memory address where emulation starts ADDRESS = 0x10000 diff --git a/bindings/python/sample_arm64.py b/bindings/python/sample_arm64.py index 59cae994..2afee8c4 100755 --- a/bindings/python/sample_arm64.py +++ b/bindings/python/sample_arm64.py @@ -8,7 +8,7 @@ from unicorn.arm64_const import * # code to be emulated -ARM64_CODE = "\xab\x01\x0f\x8b" #add x11, x13, x15 +ARM64_CODE = b"\xab\x01\x0f\x8b" #add x11, x13, x15 # memory address where emulation starts ADDRESS = 0x10000 diff --git a/bindings/python/sample_m68k.py b/bindings/python/sample_m68k.py index 9a85f96f..d9579f66 100755 --- a/bindings/python/sample_m68k.py +++ b/bindings/python/sample_m68k.py @@ -8,7 +8,7 @@ from unicorn.m68k_const import * # code to be emulated -M68K_CODE = "\x76\xed" # movq #-19, %d3 +M68K_CODE = b"\x76\xed" # movq #-19, %d3 # memory address where emulation starts ADDRESS = 0x10000 diff --git a/bindings/python/sample_mips.py b/bindings/python/sample_mips.py index b065ef39..9b9f9e8f 100755 --- a/bindings/python/sample_mips.py +++ b/bindings/python/sample_mips.py @@ -8,8 +8,8 @@ from unicorn.mips_const import * # code to be emulated -MIPS_CODE_EB = "\x34\x21\x34\x56" # ori $at, $at, 0x3456; -MIPS_CODE_EL = "\x56\x34\x21\x34" # ori $at, $at, 0x3456; +MIPS_CODE_EB = b"\x34\x21\x34\x56" # ori $at, $at, 0x3456; +MIPS_CODE_EL = b"\x56\x34\x21\x34" # ori $at, $at, 0x3456; # memory address where emulation starts ADDRESS = 0x10000 diff --git a/bindings/python/sample_network_auditing.py b/bindings/python/sample_network_auditing.py index 69a2d2d7..bfccf828 100755 --- a/bindings/python/sample_network_auditing.py +++ b/bindings/python/sample_network_auditing.py @@ -199,7 +199,7 @@ def hook_intr(uc, intno, user_data): buf = ecx count = edx - dummy_content = str(uuid.uuid1())[:32] + dummy_content = str(uuid.uuid1()).encode("latin1")[:32] if len(dummy_content) > count: dummy_content = dummy_content[:count] diff --git a/bindings/python/sample_sparc.py b/bindings/python/sample_sparc.py index ad47d387..f6f154d6 100755 --- a/bindings/python/sample_sparc.py +++ b/bindings/python/sample_sparc.py @@ -8,7 +8,7 @@ from unicorn.sparc_const import * # code to be emulated -SPARC_CODE = "\x86\x00\x40\x02" # add %g1, %g2, %g3; +SPARC_CODE = b"\x86\x00\x40\x02" # add %g1, %g2, %g3; # memory address where emulation starts ADDRESS = 0x10000 diff --git a/bindings/python/sample_x86.py b/bindings/python/sample_x86.py index 32947a3c..7010327f 100755 --- a/bindings/python/sample_x86.py +++ b/bindings/python/sample_x86.py @@ -12,8 +12,8 @@ X86_CODE32_MEM_READ = b"\x8B\x0D\xAA\xAA\xAA\xAA\x41\x4a" # mov ecx,[0xaaaaaaaa] X86_CODE32_MEM_WRITE = b"\x89\x0D\xAA\xAA\xAA\xAA\x41\x4a" # mov [0xaaaaaaaa], ecx; INC ecx; DEC edx X86_CODE64 = b"\x41\xBC\x3B\xB0\x28\x2A\x49\x0F\xC9\x90\x4D\x0F\xAD\xCF\x49\x87\xFD\x90\x48\x81\xD2\x8A\xCE\x77\x35\x48\xF7\xD9\x4D\x29\xF4\x49\x81\xC9\xF6\x8A\xC6\x53\x4D\x87\xED\x48\x0F\xAD\xD2\x49\xF7\xD4\x48\xF7\xE1\x4D\x19\xC5\x4D\x89\xC5\x48\xF7\xD6\x41\xB8\x4F\x8D\x6B\x59\x4D\x87\xD0\x68\x6A\x1E\x09\x3C\x59" X86_CODE32_INOUT = b"\x41\xE4\x3F\x4a\xE6\x46\x43" # INC ecx; IN AL, 0x3f; DEC edx; OUT 0x46, AL; INC ebx -X86_CODE64_SYSCALL = '\x0f\x05' # SYSCALL -X86_CODE16 = '\x00\x00' # add byte ptr [bx + si], al +X86_CODE64_SYSCALL = b'\x0f\x05' # SYSCALL +X86_CODE16 = b'\x00\x00' # add byte ptr [bx + si], al # memory address where emulation starts ADDRESS = 0x1000000