From 720843cb54ac6ccdee67d989475e66be9a0261f4 Mon Sep 17 00:00:00 2001 From: Ryan Voots Date: Sat, 6 May 2017 22:12:10 -0400 Subject: [PATCH] Node is working! --- lib/EvalServer/Seccomp.pm | 2 ++ lib/eval.pl | 24 ++++++++++++------------ plugins/eval.pm | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/EvalServer/Seccomp.pm b/lib/EvalServer/Seccomp.pm index ea1276a..5b93ed9 100644 --- a/lib/EvalServer/Seccomp.pm +++ b/lib/EvalServer/Seccomp.pm @@ -33,6 +33,7 @@ our %rule_sets = ( {syscall => 'munmap'}, {syscall => 'mremap'}, {syscall => 'mprotect'}, + {syscall => 'madvise'}, {syscall => 'brk'}, {syscall => 'exit'}, @@ -45,6 +46,7 @@ our %rule_sets = ( {syscall => 'geteuid'}, {syscall => 'getcwd'}, {syscall => 'getpid'}, + {syscall => 'gettid'}, {syscall => 'getgid'}, {syscall => 'getegid'}, {syscall => 'getgroups'}, diff --git a/lib/eval.pl b/lib/eval.pl index 9f6662b..66978f5 100755 --- a/lib/eval.pl +++ b/lib/eval.pl @@ -73,7 +73,7 @@ my %exec_map = ( 'perl5.22' => {bin => '/perl5/perlbrew/perls/perl-5.22.3/bin/perl'}, 'perl5.24' => {bin => '/perl5/perlbrew/perls/perl-5.24.0/bin/perl'}, 'ruby' => {bin => '/usr/bin/ruby2.1'}, - 'node' => {bin => '/langs/node-v7.10.0-linux-x64/bin/node'}, + 'node' => {bin => '/langs/node-custom/bin/node'}, ); no warnings; @@ -259,13 +259,15 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem my $limit = 500 * $meg; ( -# setrlimit(RLIMIT_VMEM, 1.5*$limit, 1.5*$limit) -# and -# setrlimit(RLIMIT_DATA, $limit, $limit ) -# and -# setrlimit(RLIMIT_STACK, $limit, $limit ) -# and - setrlimit(RLIMIT_NPROC, 10,10) # CHANGED to 3 for Ruby. Might take it away. + setrlimit(RLIMIT_VMEM, 1.5*$limit, 1.5*$limit) + and + setrlimit(RLIMIT_AS,1.5*$limit,1.5*$limit) + and + setrlimit(RLIMIT_DATA, $limit, $limit ) + and + setrlimit(RLIMIT_STACK, 30 * $meg, 30*$meg ) + and + setrlimit(RLIMIT_NPROC, 20,20) # CHANGED to 3 for Ruby. Might take it away. and setrlimit(RLIMIT_NOFILE, 30,30) and @@ -275,8 +277,6 @@ use Storable qw/nfreeze/; nfreeze([]); #Preload Nfreeze since it's loaded on dem and setrlimit(RLIMIT_LOCKS, 5,5) and -# setrlimit(RLIMIT_AS,$limit,$limit) -# and setrlimit(RLIMIT_MEMLOCK,100,100) and setrlimit(RLIMIT_CPU, 10, 10) @@ -423,11 +423,11 @@ Biqsip biqsip 'ugh chan ghitlh lursa' nuh bey' ngun petaq qeng soj tlhej waqboch sub javascript_code { my ($code) = @_; - my $ft = File::Temp->new(); + my $ft = File::Temp->new(SUFFIX=>'.js'); print $ft $code; $ft->flush(); STDOUT->flush(); - exec($exec_map{'node'}{bin}, qw/--max_old_space_size=64 --max_semi_space_size=64 --optimize_for_size/, "$ft"); + exec($exec_map{'node'}{bin}, "--v8-pool-size=1", "$ft"); } # sub javascript_code { diff --git a/plugins/eval.pm b/plugins/eval.pm index 77936d2..8c03552 100644 --- a/plugins/eval.pm +++ b/plugins/eval.pm @@ -66,7 +66,7 @@ sub command { if( not $type ) { $type = 'perl'; } warn "Found $type: $code"; - if ($command =~ /([ws]+)?eval/i) { + if ($command =~ /^([ws]+)?eval/i) { my $c=$1; $code = "use warnings; ".$code if ($c =~ /w/); $code = "use strict; ".$code if ($c =~ /s/);