我正在使用Ubuntu 17.04,我将bash脚本转换为二进制文件。例如:
shc -v -T -r -f test.sh
文件test.sh的代码如下:
#!/bin/bash
echo "test"
编译后我得到了2个文件(test.sh.x和test.sh.x.c)。 当我尝试执行test.sh.x时,我什么也没得到。
我试着追踪它(strace ./test.sh.x)但strace显示无限输出。
stat("/home/master/Desktop", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/master/Desktop", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/master/Desktop/BOX", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/home/master", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
getpid() = 22371
open("/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26258, ...}) = 0
mmap(NULL, 26258, PROT_READ, MAP_SHARED, 3, 0) = 0x7f2ec76ba000
close(3) = 0
getppid() = 22369
brk(0x12ff000) = 0x12ff000
brk(0x1300000) = 0x1300000
brk(0x1301000) = 0x1301000
getpgrp() = 22369
ioctl(2, TIOCGPGRP, 0x7fff6581f8ec) = -1 ENOTTY (Inappropriate ioctl for device)
rt_sigaction(SIGCHLD, {0x44cf60, [], SA_RESTORER|SA_RESTART, 0x7f2ec6ce07f0}, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f2ec6ce07f0}, 8) = 0
ioctl(2, TIOCGPGRP, 0x7fff6581f8cc) = -1 ENOTTY (Inappropriate ioctl for device)
getrlimit(RLIMIT_NPROC, {rlim_cur=31314, rlim_max=31314}) = 0
brk(0x1302000) = 0x1302000
brk(0x1303000) = 0x1303000
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
getpeername(0, 0x7fff6581fa10, 0x7fff6581fa0c) = -1 ENOTSOCK (Socket operation on non-socket)
brk(0x1304000) = 0x1304000
brk(0x1305000) = 0x1305000
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f2ec6ce07f0}, {SIG_DFL, [], SA_RESTORER, 0x7f2ec6ce07f0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f2ec6ce07f0}, {SIG_IGN, [], SA_RESTORER, 0x7f2ec6ce07f0}, 8) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER|SA_RESTART, 0x7f2ec6ce07f0}, {0x44cf60, [], SA_RESTORER|SA_RESTART, 0x7f2ec6ce07f0}, 8) = 0
execve("/home/master/Desktop/BOX/test.sh.x", ["./test.sh.x"], [/* 71 vars */]) = 0
brk(NULL) = 0x562df4879000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2827d84000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=135904, ...}) = 0
mmap(NULL, 135904, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2827d62000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\5\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1856752, ...}) = 0
mmap(NULL, 3959200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f282779b000
mprotect(0x7f2827959000, 2093056, PROT_NONE) = 0
mmap(0x7f2827b58000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bd000) = 0x7f2827b58000
mmap(0x7f2827b5e000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2827b5e000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2827d60000
arch_prctl(ARCH_SET_FS, 0x7f2827d60700) = 0
mprotect(0x7f2827b58000, 16384, PROT_READ) = 0
mprotect(0x562df34f2000, 4096, PROT_READ) = 0
mprotect(0x7f2827d87000, 4096, PROT_READ) = 0
munmap(0x7f2827d62000, 135904) = 0
getpid() = 22371
brk(NULL) = 0x562df4879000
brk(0x562df489a000) = 0x562df489a000
execve("/bin/bash", ["./test.sh.x", "-c", "exec './test.sh.x' \"$@\"", "./test.sh.x"], [/* 72 vars */]strace: Process 22371 detached
<detached ...>
有人能告诉我如何解决这个问题? 感谢。