2012-09-13 11 views
5

Ho bisogno di scrivere un piccolo pezzo di codice per simulare il traffico da diversi indirizzi IP sorgente e mi chiedo se ciò possa essere fatto spoofingando gli indirizzi con Perl?IP spoofato con Perl LWP

ho cercato Net :: RawIP e che ha funzionato, ma ho bisogno di inviare una parte del traffico HTTP più complessi (cioè dati POST) ed era in grado di farlo con RawIP

Con LWP Ho provato ad utilizzare 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 utilizzando:

#!/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(); 

risposta

2

non è possibile ottenere una risposta se si invia da un indirizzo che non è tuo. Ciò significa che tutto ciò che puoi fare è inviare la richiesta. Hai indicato che puoi fare l'invio, quindi tutto ciò che ti serve è 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(); 

uscita:

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-- 
+0

Invio il file non è un problema, sta cambiando l'IP di origine della richiesta. Sono su una LAN e ho il controllo sui percorsi e sul server di ascolto, quindi va bene – blackbird

+0

Hai detto che puoi già farlo con Net :: RAWIP. L'unica cosa che non puoi fare con Net :: RAWIP è formattare la richiesta e ti ho mostrato come farlo. – ikegami

+0

Oh questo è per RAWIP! fammi provare ... – blackbird

Problemi correlati