I need to write a small piece of code to simulate traffic from different source IP addresses, and I wonder if this can be done by spoofing addresses using Perl?
I tried Net :: RAWIP and it worked, but I need to send more complex HTTP traffic (namely POST data) and could not do it using RAWIP
With LWP, I tried using ua-> local_address, but I get this answer:
Can't connect to 10.x.x.x:8080
LWP::Protocol::http::Socket: Cannot assign requested address at /usr/lib/perl5/site_perl/5.10.0/LWP/Protocol/http.pm line 51.
This is the code I'm using:
use strict ;
use warnings ;
use LWP::UserAgent ;
use URI::URL ;
my $path = 'http://142.133.114.130:8080' ;
my $url = new URI::URL $path;
my $ua = LWP::UserAgent->new();
$ua->local_address('10.121.132.112');
$ua->env_proxy ;
my $effing = 'blaj.jpg' ;
my $response = $ua->post( $url,
'Content-Type' => "multipart/form-data",
'Content' => [ userfile => ["$effing" ]],
'Connection' => 'keep-alive' ) ;
print $response->decoded_content();
source
share