Devo scrivere un piccolo pezzo di codice per simulare il traffico proveniente da diversi indirizzi IP di origine e mi chiedo se ciò possa essere fatto falsificando gli indirizzi con Perl?
Ho provato Net :: RAWIP e ha funzionato, ma ho bisogno di inviare un traffico HTTP più complesso (vale a dire i dati POST) e non sono riuscito a farlo con RAWIP
Con LWP ho provato a usare ua-> local_address ma ottengo questa risposta:
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.
Questo è il codice che sto usando:
#!/usr/bin/perl -w
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();
risposte:
2 per risposta № 1Non è possibile ottenere una risposta se si invia da unindirizzo che "non è tuo. Ciò significa che tutto ciò che puoi fare è inviare la richiesta. Hai indicato che puoi fare l'invio, quindi tutto ciò di cui hai bisogno è la richiesta da inviare. Questo è facile.
use strict;
use warnings;
use HTTP::Request::Common qw( POST );
my $req = POST("http://www.example.org/",
"Content-Type" => "multipart/form-data",
"Content" => [ userfile => [ $0 ]],
"Connection" => "keep-alive",
);
print $req->as_string();
Produzione:
POST http://www.example.org/
Connection: keep-alive
Content-Length: 376
Content-Type: multipart/form-data; boundary=xYzZY
--xYzZY
Content-Disposition: form-data; name="userfile"; filename="x.pl"
Content-Type: text/plain
use strict;
use warnings;
use HTTP::Request::Common qw( POST );
my $req = POST("http://www.example.org/",
"Content-Type" => "multipart/form-data",
"Content" => [ userfile => [ $0 ]],
"Connection" => "keep-alive",
);
print $req->as_string();
--xYzZY--