Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.69 KB | None | 0 0
  1. usr/bin/perl
  2. use strict;
  3. use Digest::SHA1  qw(sha1 sha1_hex sha1_base64);
  4. require "webpermit/db.cgi";
  5.  
  6. print "Content-Type: text/html\n\n";
  7. if ($ENV{'REQUEST_METHOD'} eq 'GET')
  8. {
  9.  print "Enter your moderator id below:
  10.  <form action=\"moderator.cgi\" method=\"post\">
  11.  <input type=\"hidden\" name=\"action\" value=\"login\">
  12.  <input type=\"text\" name=\"id\" size=15>
  13.  <input type=\"submit\" value=\"log in\"></form>";
  14. }
  15. else
  16. {
  17.     my $data;
  18.     read (STDIN, $data, $ENV{'CONTENT_LENGTH'});
  19.     my ($action, $id, $account) = split('&', $data);
  20.     $action =~ s/^action=//;
  21.     $id =~ s/^id=//;
  22.     $account =~ s/^account=//;
  23.     if (validkey($id) != 0)
  24.     {
  25.         if ($action eq 'view')
  26.         {
  27.             my $cx = 0;
  28.             my @labels = ('username', 'password', 'email address', 'first name', 'middle name', 'last name', 'month of birth', 'day of birth', 'year of birth', 'gender', 'marital status', 'country', 'state', 'city', 'address', 'phone number', 'occupation', 'income', 'dependents', 'first interest/hobby', 'second interest/hobby', 'third interest/hobby', 'fourth interest/hobby', 'fifth interest/hobby', 'about');
  29.             my @ret = getuser($account);
  30.             if (defined($ret[1]))
  31.             {
  32.                 if (isadmin($ret[0]))
  33.                 {
  34.                     print "<b>Admin Account</b>";
  35.                 }
  36.                 while (defined($ret[$cx]))
  37.                 {
  38.                     if ($cx == 1)
  39.                     {
  40.                         print "$labels[$cx]: $ret[$cx]\n";
  41.                         print "Sha1 hash: ".sha1_hex("xG1lxrKu$ret[$cx]")."\n";
  42.                     }
  43.                     else
  44.                     {
  45.                         print "$labels[$cx]: $ret[$cx]\n";
  46.                     }
  47.                     $cx++;
  48.                 }
  49.             }
  50.             else
  51.             {
  52.                 print "That user doesn't exist.";
  53.             }
  54.         }
  55.         elsif ($action eq 'email')
  56.         {
  57.             my @ret = getuser($account);
  58.             if (isadmin($account) || !$ret[0])
  59.             {
  60.                 print "Couldn\'t load user\'s email records.";
  61.             }
  62.             else
  63.             {
  64.                 print getmail($account);
  65.             }
  66.         }
  67.   else
  68.   {
  69.    print "<html><head><title>Moderator Panel</title></head><body>
  70.     <center>
  71.     <h3>Welcome to the moderator panel</h3>
  72.     <form action=\"moderator.cgi\" method=\"post\">
  73.     <input type=\"hidden\" value=\"view\" name=\"action\">
  74.     <input type=\"hidden\" value=\"$id\" name=\"id\">
  75.     &nbsp;&nbsp;View Account Info: <input type=\"text\" name=\"account\" size=20 value=\"\">
  76.     &nbsp;&nbsp;<input type=\"submit\" value=\"Submit\">
  77.    </form>
  78.    
  79.     <form action=\"moderator.cgi\" method=\"post\">
  80.     <b>Email:</b>
  81.     <input type=\"hidden\" value=\"email\" name=\"action\">
  82.     <input type=\"hidden\" value=\"$id\" name=\"id\">
  83.     &nbsp;&nbsp;View Email Traffic: <input type=\"text\" name=\"account\" size=20 value=\"\">
  84.     &nbsp;&nbsp;<input type=\"submit\" value=\"Submit\">
  85.    </form>
  86.     </center>
  87.     </body></html>";
  88.   }
  89.  }
  90.  else
  91.  {
  92.   print "You have entered an invalid id.";
  93.  }
  94. }
  95.  
  96. sub validkey
  97. {
  98.  if (not($_[0] =~ /[A-Z]|[a-z]|[0-9]/))
  99.  {
  100.   return 0;
  101.  }
  102.  my @idchars = split(//, $_[0]);
  103.  my ($total, $counter, $char) = (0, 0);
  104.  while(defined($idchars[$counter]))
  105.  {
  106.   $char = $idchars[$counter];
  107.   $total += (ascii($char)+($total*$counter));
  108.   $counter++;
  109.  }
  110.  
  111.  if ($total > 925559 && $total < 927901)
  112.  {
  113.   return $total;
  114.  }
  115.  else
  116.  {
  117.   return 0;
  118.  }
  119. }
  120.  
  121. sub ascii
  122. {
  123.  my (@str, $pos, $offset);
  124.  if ($_[0] =~ /[0-9]/)
  125.  {
  126.   @str = split(//, '0123456789');
  127.   $offset = 48;
  128.  }
  129.  elsif ($_[0] =~ /[A-Z]/)
  130.  {
  131.   @str = split(//, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  132.   $offset = 65;
  133.  }
  134.  elsif ($_[0] =~ /[a-z]/)
  135.  {
  136.   @str = split(//, 'abcdefghijklmnopqrstuvwxyz');
  137.   $offset = 97;
  138.  }
  139.  else
  140.  {
  141.   return 0;
  142.  }
  143.  $pos = 0;
  144.  while (defined($str[$pos]))
  145.  {
  146.   if ($_[0] eq $str[$pos])
  147.   {
  148.    return ($pos+$offset);
  149.   }
  150.   $pos++;
  151.  }
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement