#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
#
# HTTPCON openHTTPConnection(STRING peer)
#
sub openHTTPConnection
{
my ($target,$me) = @_;
return new IO::Socket::INET(
LocalAddr => $me,
PeerAddr => $target,
PeerPort => '80',
Proto => 'tcp');
}
my $target = "<removed>"; #website goes here
my $me = "<removed>"; #IP address goes here
my $con = openHTTPConnection($target,$me);
unless($con)
{
#CRASHES HERE
die("Could not open connection. Reason: $!");
}
#open dump file
open(HFILE,">C:\\USERS\\DIEGO\\DESKTOP\\OUT.HTML") or die("Could not open buffer file. Reason: $!");
#send HTTP request.
printf $con "GET / HTTP/1.1\nHost: $target\n\n";
my ($tmpbuf,$pagebuf) = ("","");
#dump webpage contents into file
while(defined($tmpbuf = <$con>))
{
printf HFILE $tmpbuf;
}
#clean up and exit
close $con;
close HFILE;
It crashes where indicated with the error message "unknown error". Any ideas?
Edited by dargueta, 04 March 2009 - 06:21 PM.
Fixed formatting


Sign In
Create Account

Back to top










