



(15 votes)#!/usr/bin/perl # # run.pl by detour@metalshell.com # # Execute another program using three different methods. # # http://www.metalshell.com/ use strict; my $buff; # commands inside `s are run externally $buff = `ps -ax`; # change any occurence of run.pl to hacker.pl to show we # have full control over what gets printed. $buff =~ s/run.pl/hacker.pl/g; print $buff; print "\nsystem() and exec() are the same except system\n"; print "will fork the program and return.\n\n"; print "The output from ls will be displayed but you can't\n"; print "alter it before it gets printed\n"; system("ls"); print "\nExec will not return to your program\n"; print "You are now in another shell, type 'exit'\n"; exec "/bin/sh", "-s"; print "This will not be seen.\n";