a9898625

7 unix commands

Jan 17th, 2021
532
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head><title>Unix Command</title></head>
  3. <body>
  4. <form method=GET action="http://localhost/cgi-bin/7a.pl" >
  5. <center><br><h1>ENTER UNIX COMMAND TO BE EXECUTED</h1>
  6. <input type="text" name="msg">
  7. <input type="submit" value="CLICKME">
  8. </form>
  9. </body>
  10. </html>
  11.  
  12. 7a.pl
  13. #!/usr/bin/perl
  14. use CGI':standard';
  15. print "content-type:text/html";    
  16. $c=param('msg');
  17. system($c);
  18. exit(0);
  19.  
  20. 7b.pl
  21. #!/usr/bin/perl
  22. print "content-type:text/html ";
  23. $count_file="/var/www/cgi-bin/ru.txt";
  24. if(open(FILE,'<'.$count_file))
  25. {
  26.         $no_accesses=<FILE>;
  27.         close(FILE);
  28.         if(open(FILE,'>'.$count_file))
  29.         {
  30.             $no_accesses++;
  31.             print FILE $no_accesses;
  32.             close(FILE);
  33.             print "no. of visitors:",$no_accesses;
  34.         }
  35.         else
  36.         {
  37.             print "[can't write to data file]";
  38. }
  39. }
  40. else
  41. {
  42.         print "[sorry]";
  43. }
  44. exit(0);
  45.  
RAW Paste Data