#!/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 postdoc {
    my $docurl = shift;
    
    my $req = POST  $docurl,
	[ CardNumber	=> $card,	CurrentPIN	=> $pin1,
	NewPIN		=> $pin2,	AccountNumber	=> $user,
	"Submit.x"	=> $x,		"Submit.y"	=> $y,
	VDaemonValidators				=> $other ];
 
    $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 "302") {
        print "!";
    } else {
        print "x";
    }

    $cookie_jar->extract_cookies($res);

    undef $req;
    undef $res;
}

$ua = LWP::UserAgent->new( keep-alive => 1, timeout => 30);
$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://219.148.127.68/scripts/process.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;

$other='O:13:"cvdvalruntime":5:{s:5:"sPage";s:16:"/scripts/pop.php";s:5:"sArgs";s:0:"";s:7:"sAnchor";s:0:"";s:5:"sForm";s:4:"Citi";s:6:"aNodes";a:5:{i:0;O:7:"xmlnode":3:{s:5:"sName";s:11:"vlvalidator";s:6:"aAttrs";a:4:{s:4:"name";s:13:"CardNumberReq";s:4:"type";s:8:"required";s:7:"control";s:10:"CardNumber";s:6:"errmsg";s:16:"Card+#+required.";}s:9:"aSubNodes";a:0:{}}i:1;O:7:"xmlnode":3:{s:5:"sName";s:11:"vlvalidator";s:6:"aAttrs";a:5:{s:4:"name";s:15:"CardNumberCheck";s:4:"type";s:6:"custom";s:7:"control";s:10:"CardNumber";s:6:"errmsg";s:15:"Invalid+card+#.";s:8:"function";s:5:"CCVal";}s:9:"aSubNodes";a:0:{}}i:2;O:7:"xmlnode":3:{s:5:"sName";s:11:"vlvalidator";s:6:"aAttrs";a:5:{s:4:"name";s:18:"CardNumberNumCheck";s:4:"type";s:9:"checktype";s:7:"control";s:10:"CardNumber";s:6:"errmsg";s:15:"Invalid+card+#.";s:9:"validtype";s:7:"integer";}s:9:"aSubNodes";a:0:{}}i:3;O:7:"xmlnode":3:{s:5:"sName";s:11:"vlvalidator";s:6:"aAttrs";a:4:{s:4:"name";s:13:"CurrentPINReq";s:4:"type";s:8:"required";s:7:"control";s:10:"CurrentPIN";s:6:"errmsg";s:21:"Current+PIN+required.";}s:9:"aSubNodes";a:0:{}}i:4;O:7:"xmlnode":3:{s:5:"sName";s:11:"vlvalidator";s:6:"aAttrs";a:5:{s:4:"name";s:16:"CurrentPINRegExp";s:4:"type";s:6:"regexp";s:7:"control";s:10:"CurrentPIN";s:6:"errmsg";s:20:"Invalid+Current+PIN.";s:6:"regexp";s:9:"/^\d{4}$/";}s:9:"aSubNodes";a:0:{}}}}';


while (1) {
    $card=&gencard();
    $user="";
    $acct = sprintf("%05d",int(rand(99999))) + 71500000;
    $pin1 = sprintf("%04d",int(rand(9999)));
    $pin2 = sprintf("%04d",int(rand(9999)));
    $vdid = sprintf("%08d",int(rand(99999999)));
    $x = int(rand(25)); $y = int(rand(25));

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

    $fucker="$doc";
    postdoc($fucker);
}

