Go Back   Gaming Gutter > Non-Gaming > Programming > Source Code


Source Code - Have a source code/project files you want to post? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post What are you currently...
09-12-2008 04:16 PM
by Ocean
Last post by April<33
Today 01:36 AM
218 Replies, 1,404 Views
Go to first new post Lil Wayne
10-21-2008 09:33 PM
Last post by April<33
Today 01:34 AM
44 Replies, 365 Views
Go to first new post mOBSCENE's score sender...
Today 01:11 AM
Last post by April<33
Today 01:30 AM
3 Replies, 12 Views
Go to first new post Which Neopet hack makes...
11-09-2008 02:14 PM
by weezer
Last post by April<33
Today 01:26 AM
27 Replies, 835 Views
Go to first new post neopets account info...
Yesterday 07:26 AM
by lyro34
Last post by April<33
Today 01:25 AM
4 Replies, 65 Views
Reply
 
LinkBack Thread Tools Display Modes

 perl Neopets Login
Old 04-08-2007, 09:06 PM   #1 (permalink)
sockopen
Guest

 
Posts: n/a
GPoints: 0 [Check]
iTrader: / %
perl Neopets Login

Simple Neopets Login and 'HTTPWrapper' I wrote.

Code:
#!/usr/local/bin/perl

use Socket;
use Compress::Zlib;

print 'Username: '; 
$II11III1I1III1II = <STDIN>; chop $II11III1I1III1II;
if ((length($II11III1I1III1II) < 3) || (length($II11III1I1III1II) > 20)) { 
  print 'ERROR: Invalid username'; exit; }
print 'Password: '; 
$IIIII1I1II111II1 = <STDIN>; chop $IIIII1I1II111II1;
if (length($II11III1I1III1II) < 5) { 
  print 'ERROR: Invalid password'; exit; }

Request('GET', 'neopets.com/index.phtml', '', 'neopets.com/');
$III1II11I111111I = Request('POST', 'neopets.com/hi.phtml', "destination=%2Fpetcentral.phtml&username=$II11III1I1III1II", 'neopets.com/index.phtml');
if ($III1II11I111111I =~ 'Sorry, we did not find an account with that username.') { 
  print 'ERROR: Invalid username'; exit; }
$III1II11I111111I = Request('POST', 'neopets.com/login.phtml', "username=$II11III1I1III1II&password=$IIIII1I1II111II1&destination=%2Fpetcentral.$II1I1I1I1II1111I", 'neopets.com/hi.phtml');
if ($III1II11I111111I =~ "Welcome, <a class=tl href=/randomfriend.phtml") {
  print 'Login was successful';
} elsif ($III1II11I111111I =~ 'Sorry, you have tried too many times to guess this password') { 
  print 'ERROR: Too many invalid login attempts'; exit;
} elsif ($III1II11I111111I =~ 'This account has been <span style="color:#FF0000;font-weight:bold;">FROZEN</span>') { 
  print "ERROR: Account $II11III1I1III1II has been frozen"; exit;
} elsif ($III1II11I111111I =~ 'That <font color="#FF0000"><strong>username/password</strong></font> combination is invalid.') {
  print 'ERROR: Account password is invalid'; exit; }
else { print 'ERROR: Login was unsuccessful'; exit; }

sub Request {
  ($I111IIIII1111111, $IIIII1I1III1I1II) = ($_[1] =~ m#([^/]*)(/.*)?$#III1I11111I11I11);
  Request: {
    socket(sock, AF_INET, SOCK_STREAM, getprotobyname('tcp'));
    connect(sock, pack('S n a4 x8', AF_INET, 80, (gethostbyname($I111IIIII1111111))[4]));
    select(sock); $|=1; select(STDOUT);
    if ($_[0] != 'POST') {
      print sock "$_[0] $IIIII1I1III1I1II HTTP/1.1\015\012",
                "Host: $I111IIIII1111111\015\012",
                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\015\012",
                "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\015\012",
                "Accept-Language: en-us,en;q=0.5\015\012",
                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\015\012",
                "Keep-Alive: 300\015\012",
                "Connection: keep-alive\015\012",
                "Referer: $_[3]\015\012",
                "$II1I1111I1I1I1II\015\012";
    } elsif ($_[0] == 'POST') {
      print sock "$_[0] $IIIII1I1III1I1II HTTP/1.1\015\012",
                "Host: $I111IIIII1111111\015\012",
                "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3\015\012",
                "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\015\012",
                "Accept-Language: en-us,en;q=0.5\015\012",
                "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\015\012",
                "Keep-Alive: 300\015\012",
                "Connection: keep-alive\015\012",
                "Referer: $_[3]\015\012",
                "$II1I1111I1I1I1II",
                "Content-Type: application/x-www-form-urlencoded\015\012",
                "Content-Length: ", length($_[2]), "\015\012\015\012$_[2]";
    }
    vec($I11IIIII111II1I1 = '', fileno(sock), 1) = 1;
    select($I11IIIII111II1I1, undef, undef, 60) || die "ERROR: $!";
    $I1I11IIIIIII11II = 0;
    while (($I1I11IIIIIII11II < 5) && ($IIII1II11IIIII11 = read(sock, $II1111I1I11I1I1I, 5 - $I1I11IIIIIII11II, $I1I11IIIIIII11II))) {
      $I1I11IIIIIII11II+= $IIII1II11IIIII11; }
    defined($IIII1II11IIIII11) || die "ERROR: $!";
    
    $III111II111I1I1I = '';
    if ($II1111I1I11I1I1I !~ m#^HTTP/#) {
      $III111II111I1I1I.= $_ while read(sock, $_, 16384);
    } else {
      $II1111I1I11I1I1I.= <sock>;
      ($I1III1IIII11II11) = ($II1111I1I11I1I1I =~ m#^HTTP/\d+\.\d+\s+(\d+)#);
      $I11I1III1I1IIII1 = '';
      while (<sock>) {
        last if /^\015?\012/; $I11I1III1I1IIII1.= $_;
      }
      $I11I1III1I1IIII1 =~ s/\015?\012[ \t]+/ /g;
      
      @I11I1III1I1IIII1 = split(/\n/, $I11I1III1I1IIII1);
      foreach $I11I111111I1I111 (@I11I1III1I1IIII1) {
        if ($I11I111111I1I111 =~ /set-cookie:/i) {
          @I1I1II11I11I11I1 = split(/:.(.+?)=/, $I11I111111I1I111);
          @II11I1I11I11111I = split(/(.+?);/, @I1I1II11I11I11I1[2]);
          if ($I1I1III1I1I1I1II !~ /@I1I1II11I11I11I1[1]=/) {
            $I1I1III1I1I1I1II.= @I1I1II11I11I11I1[1].'=';
            $I1I1III1I1I1I1II.= @II11I1I11I11111I[1].'; '; }
          elsif ($I1I1III1I1I1I1II =~ /@I1I1II11I11I11I1[1]=/) {
            $I1I1III1I1I1I1II =~ substr($I1I1III1I1I1I1II, index($I1I1III1I1I1I1II, @I1I1II11I11I11I1[1]) + length(@I1I1II11I11I11I1[1]) + 1, index($I1I1III1I1I1I1II, ";", index($I1I1III1I1I1I1II, @I1I1II11I11I11I1[1])) - index($I1I1III1I1I1I1II, @I1I1II11I11I11I1[1]) - length(@I1I1II11I11I11I1[1]) - 1, @II11I1I11I11111I[1]);
          }
        }
      }
      if (substr($I1I1III1I1I1I1II, length($I1I1III1I1I1I1II) - 4, length($I1I1III1I1I1I1II)) =~ /;./) {
        $II1I1111I1I1I1II = "Cookie: ".substr($I1I1III1I1I1I1II, 0, length($I1I1III1I1I1I1II) - 2)."\015\012"; }

      if ($I1III1IIII11II11 =~ /^(301|302|303)$/) {
        unless (($IIIII1I1III1I1II) = ($I11I1III1I1IIII1 =~ /^location:[ \t]*(\S*)/im)) {
          die "ERROR: No location in redirect"; }
        ($I11I11I1I1I1I1I1++ > 5) && die "ERROR: Too many location redirects";
        close(sock);
        $IIIII1I1III1I1II.= 'phtml';
        redo Request;
      }
      ($I1III1IIII11II11 == 200) || die "ERROR: HTTP Response not OK";

      if (($I1IIIIII1I11II11) = ($I11I1III1I1IIII1 =~ /^content-length:[ \t]*(\d*)/im)) {
        $III1I1I1I1I1111I = $I1IIIIII1I11II11;
        while ($III1I1I1I1I1111I && ($IIII1II11IIIII11 = read(sock, $I1111111I1II11II, &min($III1I1I1I1I1111I, 16384)))) {
          $III111II111I1I1I.= $I1111111I1II11II; $III1I1I1I1I1111I -= $IIII1II11IIIII11; }
        defined($IIII1II11IIIII11) || die "ERROR: $!";
        $III1I1I1I1I1111I && die "ERROR: Expected response was not received";
      } else {
        $III111II111I1I1I.= $_ while read(sock, $_, 16384);
      }
    }
    close(sock);
  }
  if ($I11I1III1I1IIII1 =~ /content-encoding:.?gzip/i) {
    $III111II111I1I1I = Compress::Zlib::memGunzip($III111II111I1I1I); }
  return $III111II111I1I1I;
}
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 01:38 AM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.09114194 seconds (100.00% PHP - 0% MySQL) with 17 queries