annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
1 #!/usr/bin/env perl
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
2 use warnings;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
3
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
4 my $script = shift;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
5 open OUT, ">", shift;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
6 open STDOUT, ">", shift;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
7 open STDERR, ">", shift;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
8
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
9 print OUT $script, "\n";
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
10
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
11 my $open = "";
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
12 my @files;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
13 for(my $i = 0; @ARGV; $i++) {
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
14 my $fn = shift;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
15 push @files, $fn;
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
16 $open .= qq(open IN$i, "<", "$fn";\n);
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
17 }
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
18
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
19 if($script =~ /(open)|(system)|(`.+`)|([$@%]ENV)/smg) {
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
20 printf(STDERR "Found vulnerable code (open, system, backticks) in given script.");
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
21 exit(1);
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
22 }
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
23
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
24 eval("$open$script");
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
25
8947fca5f715 Uploaded
ktnyt
parents:
diff changeset
26 close OUT;