PERL   33

cisco cgi

Guest on 19th August 2022 04:32:43 PM

  1. #!/usr/local/bin/perl
  2.  
  3. #
  4. # Cisco icin looking glass v0.1, Ilker TEMIR
  5. #
  6. # Baslangic tarihi :
  7. # Son duzenleme    :
  8. #
  9.  
  10. # Degiskenler
  11. $logo="http://ilker.ulakbim.gov.tr/images/ulaklogo.gif";
  12. $description="ULAKNET MERCEGI";
  13. $contact="ilker\@gmail.com";
  14.  
  15. @validrouters=('Ankara','Istanbul','Izmir');
  16. $routerIP{'Ankara'}='193.140.0.1';
  17. $routerIP{'Istanbul'}='193.140.0.2';
  18. $routerIP{'Izmir'}='194.27.0.1';
  19.  
  20. @validoptions=('bgp','bgp summary','ping','trace');
  21. $command{'bgp'}='show ip bgp %s';
  22. $command{'bgp summary'}='show ip bgp summary';
  23. $command{'ping'}='ping %s';
  24. $command{'trace'}='trace %s';
  25.  
  26. print "Content-type: text/html\n\n";
  27. print "<BODY BGCOLOR=#FFFFFF TEXT=#000000>";
  28.  
  29. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  30.   read (STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
  31. } else {
  32.   $buffer=$ENV {'QUERY_STRING'};
  33. }
  34. @pairs=split(/&/,$buffer);
  35. foreach $pair (@pairs) {
  36.   ($name,$value)=split (/=/,$pair);
  37.   $value=~ tr/+/ /;
  38.   $value=~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
  39.   $contents{$name}=$value;
  40. }
  41.  
  42. $option=$contents{'option'};
  43. $router=$contents{'router'};
  44. $address=$contents{'address'};
  45.  
  46. # Adres icinde gonderilmis ilgisiz/tehlikeli karakterleri yoket
  47. $address =~ s/\;|\||\<|\>|\&|://g;
  48.  
  49. print "<IMG SRC=$logo><BR><H2>$description</H2>\n";
  50. if (($option eq "") || ($router eq "")) {
  51.         print "<FORM>\n";
  52.         print "Yonlendirici:";
  53.         print "<SELECT NAME=router>\n";
  54.         foreach $opt (@validrouters) {
  55.                 print "<DD><OPTION>$opt\n";
  56.         }
  57.         print "</SELECT><BR><BR>\n";
  58.         print "Sorgu:<BR>";
  59.         foreach $opt (@validoptions) {
  60.                 print "<DD><INPUT TYPE=radio NAME=option VALUE='$opt'>$opt\n";
  61.         }
  62.         print "<BR><BR>Adres: <INPUT NAME=address>\n";
  63.         print "<BR><BR><BR>";
  64.         print "<INPUT TYPE=SUBMIT VALUE=Gonder>\n";
  65.         print "</FORM>\n";
  66.         print "<H5>Oneri ve gorusleriniz icin <A HREF=mailto:$contact>$contact</A></H5>";
  67.         print "<H6>Programin dagitim sayfasi icin <A HREF=http://ilker.ulakbim.gov.tr/lg/>buraya</A> tiklayin";
  68.         exit;
  69. }
  70.  
  71. # Router adinda atlatma girisimini kontrol et
  72. $routerIP=$routerIP{$router};
  73. if (!$routerIP) {
  74.         print "Hatali router adi.\n";
  75.         exit;
  76. }
  77.  
  78. $command=$command{$option};
  79.  
  80. # Atlatma komutlari kontrol et
  81. if (!$command) {
  82.         print "Hatali komut.\n";
  83.         exit;
  84. }
  85.  
  86.  
  87. $command =~ s/\%s/$address/g;
  88. select (STDOUT);
  89. $|=1;
  90.  
  91. print "<B>Yonlendirici:</B> $router <B>Komut:</B> $command<BR><BR>";
  92. #print "<PRE>";
  93. @result=`/bin/rsh $routerIP "$command"`;
  94. foreach $result (@result) {
  95.         chop ($result);
  96.         print "$result<BR>";
  97. }
  98. #print "</PRE><BR>";
  99. print "<H5>Oneri ve gorusleriniz icin <A HREF=mailto:$contact>$contact</A></H5>";

Raw Paste


Login or Register to edit or fork this paste. It's free.