使用Perl LWP欺骗IP
我需要编写一段代码来模拟来自不同源IP地址的流量,我想知道是否可以通过Perl欺骗地址来实现这一点 我尝试了Net::RAWIP,但我需要发送一些更复杂的HTTP流量(即POST数据),而RAWIP无法做到这一点 对于LWP,我尝试使用ua->local_address,但得到以下响应:使用Perl LWP欺骗IP,perl,testing,networking,ip,spoofing,Perl,Testing,Networking,Ip,Spoofing,我需要编写一段代码来模拟来自不同源IP地址的流量,我想知道是否可以通过Perl欺骗地址来实现这一点 我尝试了Net::RAWIP,但我需要发送一些更复杂的HTTP流量(即POST数据),而RAWIP无法做到这一点 对于LWP,我尝试使用ua->local_address,但得到以下响应: Can't connect to 10.x.x.x:8080 LWP::Protocol::http::Socket: Cannot assign requested address at /usr/lib/
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.
这是我正在使用的代码:
#!/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();
如果您发送的地址不是您的,则无法收到回复。这意味着你所能做的就是发送请求。您已经表示可以发送,所以您只需要发送请求。那很容易
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();
输出:
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--
发送文件不是问题,它正在更改请求的源IP。我在局域网上,我可以控制路由和监听服务器,所以你说你已经可以用Net::RAWIP做到这一点了。使用Net::RAWIP唯一不能做的就是格式化请求,我向您展示了如何做到这一点。对象设置完成后,print语句真的会发送数据吗?RAWIP使用send()方法,但不接受任何数据参数。构造函数中的数据字段只接受stringsNo,它将其发送到STDOUT。显然,换掉它。