Skip to content

Instantly share code, notes, and snippets.

@yevrah
Created November 15, 2015 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yevrah/f45c41afdae7a3dca383 to your computer and use it in GitHub Desktop.
Save yevrah/f45c41afdae7a3dca383 to your computer and use it in GitHub Desktop.
Perl: Ovverride core perl routines
#!/usr/bin/env perl
# See my post on http://stackoverflow.com/questions/33725298/perl-disable-shell-access
# Ref: https://github.com/Perl/perl5/blob/blead/lib/CORE.pod
BEGIN {
*CORE::GLOBAL::system = sub {
die('Do not use system calls.');
};
*CORE::GLOBAL::exec = sub {
die('Do not use exec.');
};
*CORE::GLOBAL::readpipe = sub {
die('Do not use back ticks.');
};
}
#...
my $out = system('ls -lah'); # I will die at this point, but not before
print $out;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment