diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/glang-galaxy-conf/snippets/perl_snippet_text.pl	Fri Jun 26 05:21:44 2015 -0400
@@ -0,0 +1,26 @@
+#!/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;