view glang-galaxy-conf/snippets/perl_snippet_text.pl @ 2:8947fca5f715 draft default tip

Uploaded
author ktnyt
date Fri, 26 Jun 2015 05:21:44 -0400
parents
children
line wrap: on
line source

#!/usr/bin/env perl
use warnings;

my $script = shift;
open OUT, ">", shift;
open STDOUT, ">", shift;
open STDERR, ">", shift;

print OUT $script, "\n";

my $open = "";
my @files;
for(my $i = 0; @ARGV; $i++) {
    my $fn = shift;
    push @files, $fn;
    $open .= qq(open IN$i, "<", "$fn";\n);
}

if($script =~ /(open)|(system)|(`.+`)|([$@%]ENV)/smg) {
    printf(STDERR "Found vulnerable code (open, system, backticks) in given script.");
    exit(1);
}

eval("$open$script");

close OUT;