apparently some folks were using that web-bot I wrote to strip the domains
out of the reseller web interface (which I wrote since it seems to be the
only way to get any form of reconcilliation capabilities... which is
probably the biggest beef I have with OpenSRS)

I have been busy, and hadn't used it in a while... it was pointed out to
me today that it wasn't working... the opensrs folks added a cookie check
that requires you to load their sign-in page and then send back the
"cookiecheck" cookie that they set... the 'bot wasn't doing that, so it
didn't work...

I also made a few other minor changes...  (e.g. the flags)

Keep in mind that I have the opensrs lists _very_ heavily
filtered, and generally only read messages from the tucows staff
addresses...  So, if you want to comment on this, you'll have to
send the message directly to me... 

Note that the script is PERL, and requires Net::SSLeay to be
installed (which requires the OpenSSL libraries...)... given
that, all you need to do is set your userid and password in the
code ... :-)

Hope this makes a couple folks lives easier.


#!/usr/bin/perl
#
# short (too short) script to grab all active domains from 
# https://rr-n1-tor.opensrs.net/~vpop/resellers/
#
# Released to the public domain by Tom Brown, [EMAIL PROTECTED]
# (but I'd still like to have my name in the comments if you use it. :-)
#
# it will scan the pages of active domains... 
# and dump the domains (one perl line) from each page
# to opensrs.active.X where X is the page number.

my $USERID="CHANGEME";  # your reseller id
my $PASS="CHANGEME";       # your reseller password

#################################################

use strict;
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form) ;

use vars qw($opt_c $opt_a $opt_d);
use Getopt::Std;

getopts('cad');   # REDUNDANT -a = active orders 
                  # NO LONGER SUPPORTED -c = completed domains
                  # -d = debugging on

die "completed orders page is no longer supported." if ($opt_c);
warn "this script only supports active domains, so -a is redundant\n"
  if ($opt_a);

my $HOSTNAME="rr-n1-tor.opensrs.net";
my $URI="/~vpop/resellers/index";
my $ACTION="view_domains";  #

my $init_cookie = 'CheckCookie=CheckCookie'; # really should load the login page
my $AGENT='baremetal Reconciller';
my $headers=make_headers( 'User-Agent' => $AGENT,
                          Cookie => $init_cookie );

my ($page, $response, %reply_headers)
                = post_https($HOSTNAME, 443, $URI, $headers,
                       make_form(
                               'username'   => $USERID,
                               'password' => $PASS,
                               'action' => 'login'
                       ));

foreach (keys %reply_headers) {
   printf "header: %s: %s\n", $_, $reply_headers{$_};
}
print "\n$page\n" if $opt_d;

my $cookie = $reply_headers{'SET-COOKIE'} or die "can't get auth cookie!";
print "cookie set to $cookie\n";

$headers=make_headers( 'User-Agent' => $AGENT,
                          Cookie => $cookie );

my @fetchpages = ('0');  
my %validpages = (0=>1); 
while (defined(my $fetchpage = shift(@fetchpages))) {
   ($page, $response, %reply_headers)
                = post_https($HOSTNAME, 443, $URI, $headers,
                       make_form(
                               action => $ACTION,
                               orderby => 'createdate',
                               page => $fetchpage
                       ));
   die "whoa, request failed: $response" unless ($response);
   print "\npage $fetchpage is: $page\n\n" if ($opt_d);

   while ($page =~ m#view_domains&orderby=createdate&domain=&page=(\d+)"#g) {
      my $p = $1;
      if (!defined($validpages{$p})) {
         push(@fetchpages,$p); # schedule it
         $validpages{$p} = 1;  # record the fact it is scheduled
      }
   }

   print "fetched page $fetchpage\n";
   open F, ">opensrs.active.$fetchpage";
   my $found = 0;
   # note the embedded action below is not $ACTION it is the singular form
   #                               reg                 exp            
   while ($page =~ 
m#<tr>\s*<td.*?>(.*?)</td>\s*<td.*?>(.*?)</td>\s*.*?action=view_domain&name=(.*?)">.*?</tr>#igs)
 {
      print F "$3: $1: $2\n";
      $found = 1;
   }
   close F;
   die "Yikes, I couldn't parse any domains out of this page:\n$page\n"
     unless $found;
}


Reply via email to