Update .travis.yml
Update eflags_nosync.c Update sigill2.c Update ro_mem_test.c Update ro_mem_test.c Update nr_mem_test.c Update mem_fuzz.c Update mem_double_unmap.c Update emu_stop_in_hook_overrun.c Update eflags_nosync.c remove unused Update Makefile Update Makefile Update Makefile Update Makefile Update Makefile Update Makefile Update Makefile Update mem_64_c.c Update mem_64_c.c Update Makefile Update Makefile Update Makefile Update Makefile Update Makefile Update Makefile Update .travis.yml try android ndk build Update unicorn.py Update unicorn.py Update Makefile Update unicorn.py Update unicorn.py remove an untrue comment if a dll/so/dylib gets loaded at runtime is dependent on many different factors, primarily the LD/DYLD paths. Those do not always include the current working directory Update Makefile Update .appveyor.yml Update .travis.yml Update Makefile Update .appveyor.yml Fix bad sample
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
# Unicorn Engine
|
||||
# By Nguyen Anh Quynh & Dang Hoang Vu, 2015
|
||||
TMP_DIR = /tmp/unicorn_sample
|
||||
DIFF = diff
|
||||
|
||||
DIFF = diff -u -w
|
||||
|
||||
SAMPLE_ARM = $(TMP_DIR)/sample_arm
|
||||
SAMPLE_ARM64 = $(TMP_DIR)/sample_arm64
|
||||
SAMPLE_MIPS = $(TMP_DIR)/sample_mips
|
||||
SAMPLE_M68K = $(TMP_DIR)/sample_m68k
|
||||
SAMPLE_SPARC = $(TMP_DIR)/sample_sparc
|
||||
SAMPLE_X86 = $(TMP_DIR)/sample_x86
|
||||
SAMPLE_SOURCE = $(wildcard ../samples/*.c)
|
||||
SAMPLE = $(SAMPLE_SOURCE:../samples/%.c=%)
|
||||
SAMPLE := $(SAMPLE:mem_apis=)
|
||||
SAMPLE := $(SAMPLE:sample_batch_reg=)
|
||||
SAMPLE := $(SAMPLE:sample_x86_32_gdt_and_seg_regs=)
|
||||
SAMPLE := $(SAMPLE:shellcode=)
|
||||
|
||||
ENV_VARS = LD_LIBRARY_PATH=../ DYLD_LIBRARY_PATH=../
|
||||
|
||||
.PHONY: build install expected python sample_diff clean check test
|
||||
.PHONY: build install python c clean check test
|
||||
|
||||
build:
|
||||
$(MAKE) -C python gen_const
|
||||
@@ -26,39 +24,22 @@ install: build
|
||||
$(MAKE) -C python install
|
||||
$(MAKE) -C java install
|
||||
|
||||
test: expected python sample_diff
|
||||
test: $(SAMPLE:%=%.py.test)
|
||||
|
||||
expected:
|
||||
c:
|
||||
$(MAKE) -C ../samples
|
||||
mkdir -p $(TMP_DIR)
|
||||
$(ENV_VARS) ../samples/sample_arm > $(SAMPLE_ARM)_e
|
||||
$(ENV_VARS) ../samples/sample_arm64 > $(SAMPLE_ARM64)_e
|
||||
$(ENV_VARS) ../samples/sample_mips > $(SAMPLE_MIPS)_e
|
||||
$(ENV_VARS) ../samples/sample_sparc > $(SAMPLE_SPARC)_e
|
||||
$(ENV_VARS) ../samples/sample_m68k > $(SAMPLE_M68K)_e
|
||||
$(ENV_VARS) ../samples/sample_x86 -16 > $(SAMPLE_X86)_e
|
||||
$(ENV_VARS) ../samples/sample_x86 -32 >> $(SAMPLE_X86)_e
|
||||
$(ENV_VARS) ../samples/sample_x86 -64 >> $(SAMPLE_X86)_e
|
||||
|
||||
python:
|
||||
$(MAKE) -C python
|
||||
$(ENV_VARS) python python/sample_arm.py > $(SAMPLE_ARM)_o
|
||||
$(ENV_VARS) python python/sample_arm64.py > $(SAMPLE_ARM64)_o
|
||||
$(ENV_VARS) python python/sample_mips.py > $(SAMPLE_MIPS)_o
|
||||
$(ENV_VARS) python python/sample_sparc.py > $(SAMPLE_SPARC)_o
|
||||
$(ENV_VARS) python python/sample_m68k.py > $(SAMPLE_M68K)_o
|
||||
$(ENV_VARS) python python/sample_x86.py > $(SAMPLE_X86)_o
|
||||
%.c.txt: c
|
||||
$(ENV_VARS) ../samples/$(@:%.c.txt=%) > $@
|
||||
%.py.txt: python
|
||||
$(ENV_VARS) python python/$(@:%.txt=%) > $@
|
||||
|
||||
sample_diff:
|
||||
$(DIFF) $(SAMPLE_ARM)_e $(SAMPLE_ARM)_o
|
||||
$(DIFF) $(SAMPLE_ARM64)_e $(SAMPLE_ARM64)_o
|
||||
$(DIFF) $(SAMPLE_MIPS)_e $(SAMPLE_MIPS)_o
|
||||
$(DIFF) $(SAMPLE_SPARC)_e $(SAMPLE_SPARC)_o
|
||||
$(DIFF) $(SAMPLE_M68K)_e $(SAMPLE_M68K)_o
|
||||
$(DIFF) $(SAMPLE_X86)_e $(SAMPLE_X86)_o
|
||||
%.py.test: %.c.txt %.py.txt
|
||||
$(DIFF) $(@:%.py.test=%.c.txt) $(@:%.py.test=%.py.txt)
|
||||
|
||||
clean:
|
||||
rm -rf $(TMP_DIR)
|
||||
# rm -rf *.txt
|
||||
$(MAKE) -C python clean
|
||||
$(MAKE) -C java clean
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# Go binding for Unicorn engine. Ryan Hileman <lunixbochs@gmail.com>
|
||||
|
||||
.PHONY: gen_const test
|
||||
.PHONY: all gen_const test
|
||||
|
||||
all:
|
||||
$(MAKE) gen_const
|
||||
all: gen_const
|
||||
cd unicorn && go build
|
||||
$(MAKE) test
|
||||
|
||||
gen_const:
|
||||
cd .. && python const_generator.py go
|
||||
|
||||
test:
|
||||
cd unicorn && go test
|
||||
test: all
|
||||
cd unicorn && LD_LIBRARY_PATH=../../../ DYLD_LIBRARY_PATH=../../../ go test
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -O3
|
||||
#cgo LDFLAGS: -lunicorn
|
||||
#cgo CFLAGS: -O3 -Wall -Werror -I../../../include
|
||||
#cgo LDFLAGS: -L../../../ -lunicorn -lglib-2.0
|
||||
#include <unicorn/unicorn.h>
|
||||
#include "uc.h"
|
||||
*/
|
||||
|
||||
@@ -442,38 +442,25 @@ def test_i386_context_save():
|
||||
# write machine code to be emulated to memory
|
||||
mu.mem_write(address, code)
|
||||
|
||||
print(">>> set eax to 1")
|
||||
# set eax to 1
|
||||
mu.reg_write(UC_X86_REG_EAX, 1)
|
||||
|
||||
print(">>> execute 'inc eax'")
|
||||
print(">>> Running emulation for the first time")
|
||||
mu.emu_start(address, address+1)
|
||||
|
||||
print(">>> save the CPU context")
|
||||
print(">>> Emulation done. Below is the CPU context")
|
||||
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
|
||||
print(">>> Saving CPU context")
|
||||
saved_context = mu.context_save()
|
||||
|
||||
print(">>> execute 'inc eax'")
|
||||
print(">>> Running emulation for the second time")
|
||||
mu.emu_start(address, address+1)
|
||||
print(">>> Emulation done. Below is the CPU context")
|
||||
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
|
||||
|
||||
print(">>> assert eax == 3")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 3
|
||||
|
||||
print(">>> restore the CPU context")
|
||||
print(">>> CPU context restored. Below is the CPU context")
|
||||
mu.context_restore(saved_context)
|
||||
|
||||
print(">>> assert eax == 2")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 2
|
||||
|
||||
print(">>> execute 'inc eax'")
|
||||
mu.emu_start(address, address+1)
|
||||
|
||||
print(">>> assert eax == 3")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 3
|
||||
|
||||
print(">>> restore the CPU context")
|
||||
mu.context_restore(saved_context)
|
||||
|
||||
print(">>> assert eax == 2")
|
||||
assert mu.reg_read(UC_X86_REG_EAX) == 2
|
||||
print(">>> EAX = 0x%x" %(mu.reg_read(UC_X86_REG_EAX)))
|
||||
|
||||
except UcError as e:
|
||||
print("ERROR: %s" % e)
|
||||
@@ -644,6 +631,8 @@ if __name__ == '__main__':
|
||||
print("=" * 35)
|
||||
test_i386_inout()
|
||||
print("=" * 35)
|
||||
test_i386_context_save()
|
||||
print("=" * 35)
|
||||
test_i386_jump()
|
||||
print("=" * 35)
|
||||
test_i386_loop()
|
||||
|
||||
@@ -21,7 +21,7 @@ def hook_code(uc, address, size, user_data):
|
||||
print(">>> Tracing instruction at 0x%x, instruction size = 0x%x" %(address, size))
|
||||
# read this instruction code from memory
|
||||
tmp = uc.mem_read(address, size)
|
||||
print(">>> Instruction code at [0x%x] =" %(address), end="")
|
||||
print("*** EIP = %x *** :" %(address), end="")
|
||||
for i in tmp:
|
||||
print(" %02x" %i, end="")
|
||||
print("")
|
||||
|
||||
@@ -17,12 +17,11 @@ _python2 = sys.version_info[0] < 3
|
||||
if _python2:
|
||||
range = xrange
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
_lib = "libunicorn.dylib"
|
||||
elif sys.platform in ('win32', 'cygwin'):
|
||||
_lib = "unicorn.dll"
|
||||
else:
|
||||
_lib = "libunicorn.so"
|
||||
_lib = { 'darwin': 'libunicorn.dylib',
|
||||
'win32': 'unicorn.dll',
|
||||
'cygwin': 'cygunicorn.dll',
|
||||
'linux': 'libunicorn.so',
|
||||
'linux2': 'libunicorn.so' }
|
||||
|
||||
# Windows DLL in dependency order
|
||||
_all_windows_dlls = (
|
||||
@@ -45,7 +44,7 @@ def _load_lib(path):
|
||||
if sys.platform in ('win32', 'cygwin'):
|
||||
_load_win_support(path)
|
||||
|
||||
lib_file = os.path.join(path, _lib)
|
||||
lib_file = os.path.join(path, _lib[sys.platform])
|
||||
return ctypes.cdll.LoadLibrary(lib_file)
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
.PHONY: gen_const
|
||||
|
||||
install:
|
||||
$(MAKE) gen_const
|
||||
# Use bundle install && rake to install gem and test
|
||||
install: gen_const
|
||||
cd unicorn_gem && rake build
|
||||
cd unicorn_gem && gem install --local pkg/unicorn-0.9.0.gem
|
||||
|
||||
|
||||
Reference in New Issue
Block a user