diff options
Diffstat (limited to '')
| -rw-r--r-- | test/arch/x86/qemu/testqemu.py | 8 | ||||
| -rwxr-xr-x | test/os_dep/linux/test_env.aarch64l | bin | 0 -> 6168 bytes | |||
| -rwxr-xr-x | test/os_dep/linux/test_env.arml | bin | 0 -> 5608 bytes | |||
| -rw-r--r-- | test/os_dep/linux/test_env.c | 10 | ||||
| -rw-r--r-- | test/os_dep/linux/test_env.py | 36 | ||||
| -rwxr-xr-x | test/os_dep/linux/test_env.x86_32 | bin | 0 -> 5588 bytes | |||
| -rwxr-xr-x | test/os_dep/linux/test_env.x86_64 | bin | 0 -> 6312 bytes | |||
| -rwxr-xr-x | test/test_all.py | 9 |
8 files changed, 58 insertions, 5 deletions
diff --git a/test/arch/x86/qemu/testqemu.py b/test/arch/x86/qemu/testqemu.py index 5f26d6f3..e6c487f2 100644 --- a/test/arch/x86/qemu/testqemu.py +++ b/test/arch/x86/qemu/testqemu.py @@ -40,7 +40,7 @@ nb_tests = 1 def xxx___printf_chk(jitter): """Tiny implementation of printf_chk""" global nb_tests - ret_ad, args = jitter.func_args_cdecl(["out", "format"]) + ret_ad, args = jitter.func_args_systemv(["out", "format"]) if args.out != 1: raise RuntimeError("Not implemented") fmt = jitter.get_str_ansi(args.format) @@ -89,7 +89,7 @@ def xxx___printf_chk(jitter): sys.stdout.write("[%d] %s" % (nb_tests, output)) nb_tests += 1 - jitter.func_ret_cdecl(ret_ad, 0) + jitter.func_ret_systemv(ret_ad, 0) def xxx_puts(jitter): ''' @@ -98,7 +98,7 @@ def xxx_puts(jitter): writes the string s and a trailing newline to stdout. ''' - ret_addr, args = jitter.func_args_cdecl(['target']) + ret_addr, args = jitter.func_args_systemv(['target']) output = jitter.get_str_ansi(args.target) # Check with expected result line = expected.next() @@ -106,7 +106,7 @@ def xxx_puts(jitter): print "Expected:", line print "Obtained:", output raise RuntimeError("Bad semantic") - return jitter.func_ret_cdecl(ret_addr, 1) + return jitter.func_ret_systemv(ret_addr, 1) # Parse arguments parser = Sandbox_Linux_x86_32.parser(description="ELF sandboxer") diff --git a/test/os_dep/linux/test_env.aarch64l b/test/os_dep/linux/test_env.aarch64l new file mode 100755 index 00000000..19e97780 --- /dev/null +++ b/test/os_dep/linux/test_env.aarch64l Binary files differdiff --git a/test/os_dep/linux/test_env.arml b/test/os_dep/linux/test_env.arml new file mode 100755 index 00000000..c24d061e --- /dev/null +++ b/test/os_dep/linux/test_env.arml Binary files differdiff --git a/test/os_dep/linux/test_env.c b/test/os_dep/linux/test_env.c new file mode 100644 index 00000000..7b265561 --- /dev/null +++ b/test/os_dep/linux/test_env.c @@ -0,0 +1,10 @@ +#include<stdlib.h> +#include<stdio.h> + +int main(int argc, char** argv, char** envp) +{ + printf("argc %d\n", argc); + printf("argv[0] %s\n", argv[0]); + printf("argv[1] %s\n", argv[1]); + printf("envp[0] %s\n", envp[0]); +} diff --git a/test/os_dep/linux/test_env.py b/test/os_dep/linux/test_env.py new file mode 100644 index 00000000..a44d62c4 --- /dev/null +++ b/test/os_dep/linux/test_env.py @@ -0,0 +1,36 @@ +import os +import sys +from pdb import pm +from miasm2.analysis.binary import Container +from miasm2.analysis.sandbox import Sandbox_Linux_x86_32, Sandbox_Linux_x86_64,\ + Sandbox_Linux_arml, Sandbox_Linux_aarch64l + +if len(sys.argv) < 2: + print "Usage: %s <arch> ..." % sys.argv[0] + exit(0) + +arch = sys.argv[1] + +if arch == "x86_32": + sandbox = Sandbox_Linux_x86_32 +elif arch == "x86_64": + sandbox = Sandbox_Linux_x86_64 +elif arch == "arml": + sandbox = Sandbox_Linux_arml +elif arch == "aarch64l": + sandbox = Sandbox_Linux_aarch64l +else: + raise ValueError("Unsuported arch: %s" % arch) + +# Parse arguments +parser = sandbox.parser(description="ELF sandboxer") +parser.add_argument("filename", help="ELF Filename") +options = parser.parse_args(sys.argv[2:]) + +# Create sandbox +sb = sandbox(options.filename, options, globals()) + +# Run +sb.run() + +assert(sb.jitter.run is False) diff --git a/test/os_dep/linux/test_env.x86_32 b/test/os_dep/linux/test_env.x86_32 new file mode 100755 index 00000000..9f0f96bc --- /dev/null +++ b/test/os_dep/linux/test_env.x86_32 Binary files differdiff --git a/test/os_dep/linux/test_env.x86_64 b/test/os_dep/linux/test_env.x86_64 new file mode 100755 index 00000000..f9d78a1d --- /dev/null +++ b/test/os_dep/linux/test_env.x86_64 Binary files differdiff --git a/test/test_all.py b/test/test_all.py index 0a29d4d3..f76019c4 100755 --- a/test/test_all.py +++ b/test/test_all.py @@ -257,6 +257,12 @@ for script in ["win_api_x86_32.py", ]: testset += RegressionTest([script], base_dir="os_dep", tags=[TAGS['tcc']]) +for arch in ["x86_32", "x86_64", "arml", "aarch64l"]: + testset += RegressionTest(["test_env.py", arch, "test_env.%s" % arch, "-c", + "arg1", "-c", "arg2", "--environment-vars", + "TEST=TOTO", "--mimic-env"], + base_dir="os_dep/linux", tags=[TAGS['tcc']]) + ## Analysis testset += RegressionTest(["depgraph.py"], base_dir="analysis", products=[fname for fnames in ( @@ -608,7 +614,7 @@ for jitter in ExampleJitter.jitter_engines: tags=tags.get(jitter, [])) for script, dep in [(["x86_32.py", Example.get_sample("x86_32_sc.bin")], []), - (["arm.py", Example.get_sample("md5_arm"), "-a", "A684"], + (["arm.py", Example.get_sample("md5_arm"), "--mimic-env"], []), (["sandbox_elf_aarch64l.py", Example.get_sample("md5_aarch64l"), "-a", "0x400A00"], []), @@ -620,6 +626,7 @@ for script, dep in [(["x86_32.py", Example.get_sample("x86_32_sc.bin")], []), "b", "-a", "0"], [test_armb]), (["arm_sc.py", "0", Example.get_sample("demo_arm_l.bin"), "l", "-a", "0"], [test_arml]), + (["sandbox_call.py", Example.get_sample("md5_arm")], []), ] + [(["sandbox_pe_x86_32.py", Example.get_sample("x86_32_" + name + ".bin")], [test_box[name]]) |