Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Visualizer not working Continuation of issue #6 #9

Open
Lerissonf opened this issue Dec 6, 2017 · 7 comments
Open

Java Visualizer not working Continuation of issue #6 #9

Lerissonf opened this issue Dec 6, 2017 · 7 comments

Comments

@Lerissonf
Copy link

Hello,
at first I have the same issue # 6 issue, I tried to solve with the tips you gave it. However I come across this error.
captura de tela de 2017-12-06 17-45-00

Can you help me?

@daveagp
Copy link
Owner

daveagp commented Dec 9, 2017

Is it working at the command line, following the documentation?

@Lerissonf
Copy link
Author

Thanks for answering.

image

I followed the documentation.
Even then the above example is not working on the command line.

presented the above error when I ran this example:

/var/www/html/safeexec/safeexec --chroot_dir . --exec_dir / --share_newnet --nproc 50 --mem 3000000 --nfile 30 --env_vars CLASSPATH=/cp/:/cp/javax.json-1.0.jar:/java/lib/tools.jar --exec /java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt

@Lerissonf
Copy link
Author

when I used example 1 it worked quietly.
example 1:

./java/bin/java -cp .:cp:cp/javax.json-1.0.jar:java/lib/tools.jar traceprinter.InMemory < cp/traceprinter/test-input.txt

Output:

{"code":"public class Test { public static void main(String[] args) { int x = 4; x += x; } }","stdin":"","trace":[{"stdout":"","event":"call","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{},"ordered_varnames":[],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"1","frame_id":1}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{},"ordered_varnames":[],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"2","frame_id":2}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":4},"ordered_varnames":["x"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"4","frame_id":4}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":8},"ordered_varnames":["x"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"8","frame_id":8}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"return","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":8,"__return__":["VOID"]},"ordered_varnames":["x","__return__"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"9","frame_id":9}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}}],"userlog":"Debugger VM maxMemory: 1652M\n"}

image

@daveagp
Copy link
Owner

daveagp commented Dec 11, 2017

On face value, the error is saying that the file /var/www/html/java_jail/java/bin/java doesn't exist or isn't readable by the safeexec user. Do all users ("others") have permission to read/execute (list) the java_jail/java and java/bin folders as well as the bin/java executable?

It may be a bad idea to keep all this stuff in the html directory if you are planning to make a web server, because it makes it readable by the public.

@Lerissonf
Copy link
Author

No, I just want to run offline.

saida

When running this command without chroot that you suggested in issue # 6, it worked.

/var/www/html/safeexec/safeexec --share_newnet --nproc 50 --mem 30000000 --nfile 30 --env_vars CLASSPATH=./cp/:./cp/javax.json-1.0.jar:./java/lib/tools.jar --exec ./java/bin/java traceprinter.InMemory < cp/traceprinter/test-input.txt

Output:

{"code":"public class Test { public static void main(String[] args) { int x = 4; x += x; } }","stdin":"","trace":[{"stdout":"","event":"call","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{},"ordered_varnames":[],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"1","frame_id":1}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{},"ordered_varnames":[],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"2","frame_id":2}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":4},"ordered_varnames":["x"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"4","frame_id":4}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"step_line","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":8},"ordered_varnames":["x"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"8","frame_id":8}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}},{"stdout":"","event":"return","line":1,"stack_to_render":[{"func_name":"main:1","encoded_locals":{"x":8,"__return__":["VOID"]},"ordered_varnames":["x","__return__"],"parent_frame_id_list":[],"is_highlighted":true,"is_zombie":false,"is_parent":false,"unique_hash":"9","frame_id":9}],"globals":{},"ordered_globals":[],"func_name":"main","heap":{}}],"userlog":"Debugger VM maxMemory: 1652M\n"}OK
elapsed time: 5 seconds
memory usage: 286476 kbytes
cpu usage: 7.776 seconds

saida jpg

@Lerissonf
Copy link
Author

I run this command:

sudo strace -f /var/www/html/safeexec/safeexec --chroot_dir /var/www/html/java_jail --exec_dir / --share_newnet --nproc 50 --mem 30000000 --nfile 30 --env_vars CLASSPATH=./cp/:./cp/javax.json-1.0.jar:./java/lib/tools.jar --exec ./java/bin/java traceprinter.InMemory < /var/www/html/java_jail/cp/traceprinter/test-input.txt

Output:

execve("/var/www/html/safeexec/safeexec", ["/var/www/html/safeexec/safeexec", "--chroot_dir", "/var/www/html/java_jail", "--exec_dir", "/", "--share_newnet", "--nproc", "50", "--mem", "30000000", "--nfile", "30", "--env_vars", "CLASSPATH=./cp/:./cp/javax.json-"..., "--exec", "./java/bin/java", ...], [/* 17 vars */]) = 0
brk(NULL)                               = 0x1ccc000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0425ce6000
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=90903, ...}) = 0
mmap(NULL, 90903, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0425ccf000
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\0P\t\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f04256f9000
mprotect(0x7f04258b9000, 2097152, PROT_NONE) = 0
mmap(0x7f0425ab9000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f0425ab9000
mmap(0x7f0425abf000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f0425abf000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0425cce000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0425ccd000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0425ccc000
arch_prctl(ARCH_SET_FS, 0x7f0425ccd700) = 0
mprotect(0x7f0425ab9000, 16384, PROT_READ) = 0
mprotect(0x604000, 4096, PROT_READ)     = 0
mprotect(0x7f0425ce8000, 4096, PROT_READ) = 0
munmap(0x7f0425ccf000, 90903)           = 0
rt_sigaction(SIGPIPE, {SIG_DFL, [], SA_RESTORER, 0x7f042572e4b0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGPIPE, {SIG_DFL, [], SA_RESTORER, 0x7f042572e4b0}, {SIG_DFL, [], SA_RESTORER, 0x7f042572e4b0}, 8) = 0
getpid()                                = 12260
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0425ccd9d0) = 12261
strace: Process 12261 attached
[pid 12260] rt_sigaction(SIGALRM, {0x402129, [ALRM], SA_RESTORER|SA_RESTART, 0x7f042572e4b0}, {SIG_DFL, [], 0}, 8) = 0
[pid 12260] alarm(60)                   = 0
[pid 12260] select(0, NULL, NULL, NULL, {0, 67000} <unfinished ...>
[pid 12261] setrlimit(RLIMIT_AS, {rlim_cur=30000000*1024, rlim_max=30000000*1024}) = 0
[pid 12261] setrlimit(RLIMIT_DATA, {rlim_cur=30000000*1024, rlim_max=30000000*1024}) = 0
[pid 12261] setrlimit(RLIMIT_CORE, {rlim_cur=0, rlim_max=0}) = 0
[pid 12261] setrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=8192*1024}) = 0
[pid 12261] setrlimit(RLIMIT_FSIZE, {rlim_cur=0, rlim_max=0}) = 0
[pid 12261] setrlimit(RLIMIT_CPU, {rlim_cur=10, rlim_max=10}) = 0
[pid 12261] setrlimit(RLIMIT_NOFILE, {rlim_cur=30, rlim_max=30}) = 0
[pid 12261] setrlimit(RLIMIT_NPROC, {rlim_cur=51, rlim_max=51}) = 0
[pid 12261] chdir("/var/www/html/java_jail") = 0
[pid 12261] chroot(".")                 = 0
[pid 12261] chdir("/")                  = 0
[pid 12261] setpriority(PRIO_PROCESS, 12261, 16) = 0
[pid 12261] unshare(CLONE_FS|CLONE_FILES|CLONE_NEWNS|CLONE_SYSVSEM|CLONE_NEWUTS|CLONE_NEWIPC) = 0
[pid 12261] setsid()                    = 12261
[pid 12261] setgid(1000)                = 0
[pid 12261] getgid()                    = 1000
[pid 12261] setgroups(0, [])            = 0
[pid 12261] getgroups(0, NULL)          = 0
[pid 12261] setuid(22260)               = 0
[pid 12261] getuid()                    = 22260
[pid 12261] execve("./java/bin/java", ["./java/bin/java", "traceprinter.InMemory"], [/* 1 var */]) = -1 ENOENT (No such file or directory)
[pid 12261] write(2, "error 2 (No such file or directo"..., 37error 2 (No such file or directory): ) = 37
[pid 12261] write(2, "execve error\n", 13execve error
) = 13
[pid 12261] write(2, "\n", 1
)           = 1
[pid 12261] exit_group(1)               = ?
[pid 12261] +++ exited with 1 +++
<... select resumed> )                  = ? ERESTARTNOHAND (To be restarted if no handler)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=12261, si_uid=22260, si_status=1, si_utime=0, si_stime=0} ---
select(0, NULL, NULL, NULL, {0, 10724}) = 0 (Timeout)
open("/proc/12261/status", O_RDONLY)    = 3
read(3, "Name:\tsafeexec\nState:\tZ (zombie)"..., 8192) = 937
close(3)                                = 0
wait4(12261, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], WNOHANG|WSTOPPED, {ru_utime={0, 0}, ru_stime={0, 0}, ...}) = 12261
write(2, "Command exited with non-zero sta"..., 40Command exited with non-zero status (1)
) = 40
write(2, "elapsed time: 0 seconds\n", 24elapsed time: 0 seconds
) = 24
write(2, "memory usage: 0 kbytes\n", 23memory usage: 0 kbytes
) = 23
write(2, "cpu usage: 0.000 seconds\n", 25cpu usage: 0.000 seconds
) = 25
setgid(1000)                            = 0
getgid()                                = 1000
setgroups(0, [])                        = 0
getgroups(0, NULL)                      = 0
setuid(22260)                           = 0
getuid()                                = 22260
getuid()                                = 22260
getuid()                                = 22260
geteuid()                               = 22260
geteuid()                               = 22260
getgid()                                = 1000
getgid()                                = 1000
kill(4294967295, SIGKILL)               = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++

I noticed that with chroot it does not find this file:

execve("./java/bin/java", ["./java/bin/java", "traceprinter.InMemory"], [/* 1 var */]) = -1 ENOENT (No such file or directory)

@daveagp
Copy link
Owner

daveagp commented Dec 11, 2017

What if you put some other simple test binary there (like a compiled C++ hello world) in the bin folder? Does this command work if you do java/bin/hello instead of java/bin/java?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants