HTTP요청 스크립트(ActivePerl)
programming/perl 2009. 9. 30. 18:52 |* HTTP GET *
==========================================================================================
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
require HTTP::Request;
require HTTP::Response;
if( $#ARGV != 1 )
{ die "Usage: geturireq.pl [target IP] [FileName]\nEx: geturireq.pl 192.168.1.20 Query.txt\n"; }
$ipaddress = $ARGV[0];
$fileName = $ARGV[1] ;
if( -d $fileName )
{ die "$fileName is a directory.\n"; }
-e $fileName || die "$fileName is not exist.\n";
-T $fileName || die "$fileName is not a text file.\n";
open( fileHandle, $fileName ) || die "Cannot open $fileName.\n";
$i = 1;
while($aLine =<fileHandle>)
{
$qu = 'http://'.$ipaddress.$aLine;
$req = HTTP::Request->new(GET => $qu);
$res = $ua->request($req);
print $i.'. '.$qu;
$i=$i+1;
}
==========================================================================================
* HTTP Header *
==========================================================================================
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
require HTTP::Request;
require HTTP::Response;
if( $#ARGV != 1 )
{ die "Usage: geturireq.pl [target IP] [FileName]\nEx: geturireq.pl 192.168.1.20 Query.txt\n"; }
$ipaddress = $ARGV[0];
$fileName = $ARGV[1] ;
if( -d $fileName )
{ die "$fileName is a directory.\n"; }
-e $fileName || die "$fileName is not exist.\n";
-T $fileName || die "$fileName is not a text file.\n";
open( fileHandle, $fileName ) || die "Cannot open $fileName.\n";
$i = 1;
while($aLine =<fileHandle>)
{
$aLine=~/[\w_-]{1,30}(?=:\s)/;
$fieldname = $&;
$aLine=~/(?<=[\w_-]{4}:\s).+/;
$fielddata=$&;
$qu = 'http://'.$ipaddress.'_'.$i;
$req = HTTP::Request->new(GET => $qu);
$req->header($fieldname=>$fielddata);
$res = $ua->request($req);
print $i." OK!\r\n";
$i=$i+1;
print $fieldname."\r\n".$fielddata."\r\n";
}
==========================================================================================
* HTTP Post Data *
==========================================================================================
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
require HTTP::Request;
require HTTP::Response;
if( $#ARGV != 1 )
{ die "Usage: geturireq.pl [target IP] [FileName]\nEx: geturireq.pl 192.168.1.20 Query.txt\n"; }
$ipaddress = $ARGV[0];
$fileName = $ARGV[1] ;
if( -d $fileName )
{ die "$fileName is a directory.\n"; }
-e $fileName || die "$fileName is not exist.\n";
-T $fileName || die "$fileName is not a text file.\n";
open( fileHandle, $fileName ) || die "Cannot open $fileName.\n";
$i = 1;
while($aLine =<fileHandle>)
{
$qu = 'http://'.$ipaddress.'/post_'.$i;
$req = HTTP::Request->new(POST => $qu);
$req->content_type('application/x-www-form-urlencoded');
$req->content($aLine);
$res = $ua->request($req);
print $i."\x0d\x0a";
$i=$i+1;
}
==========================================================================================
'programming > perl' 카테고리의 다른 글
HTTP 파일업로드(Perl) (0) | 2009.12.30 |
---|---|
web login dictionary attack (0) | 2009.12.03 |
HTTP요청 스크립트(ActivePerl) form-data (0) | 2009.11.19 |
apache log shooter(GET) (0) | 2009.10.11 |
WireShark HTTP파싱 스크립트 (0) | 2009.09.30 |