develooper Front page | perl.libnet | Postings from April 2002

wrapper for bots to get outside corp firewall proxy username/passwd

From:
Sciencelife
Date:
April 21, 2002 02:07
Subject:
wrapper for bots to get outside corp firewall proxy username/passwd
Message ID:
12.1df933f1.29f36587@aol.com

I've included 3 functional test scripts (below).  None are able to get
beyond corp firewall to do work.  How do we extend these (or even for 
one) to provide a wrapper  to authenticate corp proxy firewall - allowing
 them to go outside?  

1.)  This code:
  Is supposed to authenticate firewall proxy & get outside (per LWP docs).
    Actually, It only prints ip addresses of what appear to be blocking
    masks for recieving (iie, offending) firewall.  Scrambling valid
 user/passwds  into invalid credentials, does not change output (see
 below).  This indicates the username passwd is not even being used to
 authenticate with firewall proxy.    When using IE to get beyond firewall, 
  user/passwd must be entered in popup dialog for any URL address which 
  pegs one of these ip masks coded into the firewall proxy.   IE has been
 config'd to reference proxy for non local URLs.  the IE  config info
   (under:  tools > internet options > connections > lan settings > 
  auto config script ) does not seem to apply to standalone network 
bots.  without recognition of these settings and a response of 
username/passwd
to answer the challenge, ftp or http bots cannot get outside!?

A little help is requested...

           ********************************************

2.)  This code Dumps an html page but errors when url is outside
     firewall proxy.

            ************************************

3.)  This code gets/puts ftp files but is thwarted when going outside    
     proxy firewall (which is entered into browser).

------------------------- ( 1. script )--------------
#!/usr/bin/perl -w
use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$ua->proxy(['http', 'ftp']=> 'http://sxxprxy.xx.com:8001/proxy.pac');

$req = HTTP::Request->new('GET',"http://www.perl.com");
("proxy_user", "proxy_password");
$req->proxy_authorization_basic("xxxx", "xxx002");
$res = $ua->request($req);
print $res->content if $res->is_success;

              ---------------          ( 1. output )             
-------------
>gitoutsid.pl

function FindProxyForURL(url, host)
        {
                if (isPlainHostName(host)||
            shExpMatch(host, "*.xx.com")||
                    shExpMatch(host, "*.xx.com")||
                    shExpMatch(host, "*.xx.com")||
          shExpMatch(host, "*.x.org")||
                    shExpMatch(host, "10.*.*.*")||
                    shExpMatch(host, "16x.179.*.*")||
      shExpMatch(host, "19x.168.*.*")||
                    shExpMatch(host, "*.cerx.net")||
                    shExpMatch(host, "*.wex.net")||
                    shExpMatch(host, "*.prx.com")||
        shExpMatch(host, "208.xxx.xxx.xxx"))
                    return "DIRECT";
                else
                {
                      return "PROXY 10.1.xx.xx:xx";
                }
        }
--------------------- 2. script ----------------

#!d:/perl/bin/perl.exe

use strict;
use IO::Socket qw(:DEFAULT :crlf);
$/ = CRLF . CRLF;
my $data;

my $url = shift or die "to use, type: <scriptname> <URL>/ \n;
my ($host,$path) = $url=~m!^http://([^/]+)(/[^\#]*)!
or die "Invalid URL.\n";

my $socket = IO::Socket::INET->new (PeerAddr => $host,
                                     PeerPort => 'http(80)')
or die "Can't connect: $!";
print $socket "GET $path HTTP/1.0", CRLF,CRLF;

my $header = <$socket>;
$header    =~ s/$CRLF/\n/g;
print $header;
print $data while read($socket,$data,1024) > 0;

------- 2. output when external url used ----------------

>fetchitHTML.pl http://cpan.org/

Can't connect: Unknown error at H:\pl\fetchitHTML.pl line 15.

---------- 3. FTP script ----------------------
H:\pl>cat putfile.pl
#!d:/perl/bin/perl.exe
use Net::FTP;
use constant HOST => 'sx.us.xp.com';
use constant DIR  => '/dmp';
use constant FILE => 'cxx.jar';
use constant PASS => 'xx';
use constant USERNAME => 'root';
#use constant TYPE => 'ascii';
use constant Firewall => 'http://sroxy.sxx.com:8001/prxy.pac';

my $ftp = Net::FTP->new(HOST,Firewall=>$Firewall,Debug=>3) or die "cant\n";
$ftp->login (USERNAME,PASS) or die $ftp->message;
$ftp->binary;

#$ftp->type(TYPE) or die $ftp->message;
$ftp->cwd(DIR) or die $ftp->message;
$ftp->get(FILE) or die $ftp->message;

use constant TYPE => 'ascii';
#$ftp->type(TYPE) or die $ftp->message;
$ftp->ascii;

use constant FILE => 'cxx.jarout';
$ftp->get(FILE) or die $ftp->message;

use constant FILE => 'cgxx.jartout';
$ftp->get(FILE) or die $ftp->message;

$ftp->quit;
warn "File retrieved success.\n";
------------------------------------------------



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About