这是我的代码
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use HTTP::Cookies;
use LWP::Protocol::https;
use strict;
use warnings;
use CACertOrg::CA;
my $URL="https://ta.example.co.il/f5-w-687474703a2f2f746573742e636c616c6e65742e636f2e696c$$/toolsandforms/specialissearch/policysearch/Pages/default.aspx";
my $UA = LWP::UserAgent->new();
my $xml = <<XMLREQUEST;
__SPSCEditMenu=true
XMLREQUEST
$UA->ssl_opts(
SSL_verify_mode => 'SSL_VERIFY_NONE',
);
my $req =HTTP::Request::Common::POST("$URL",
Content_type=>'form-data',
Content =>$xml
);
$req->header('Cookie' =>q( Cookie: TIN=294000; LastMRH_Session=ca480946; MRHSession=7e53c7507df395d38a2eb230ca480946; F5_ST=1382338632c900c100c1382338632c604800c600c; MRHSequence=1382338609),
'DNT'=>'1',
'Referer'=> 'https://ta.example.co.il/f5-w-687474703a2f2f746573742e636c616c6e65742e636f2e696c$$/testing/notificationsandalerts/Pages/Default.aspx?txtTabID=0&txtType=1',
'User-Agent'=>'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; EIE10;HEILMSN',
'Content-Type'=>'application/x-www-form-urlencoded');
my $response=$UA->request($req);
if ($response->is_success) {
print $response->decoded_content;
}
else {
die $response->status_line;
}
我在eclipse中收到此错误。
写入失败:在C:/Perl/lib/LWP/Protocol/http.pm第356行。 500写入失败:在C:/Perl/Workplace/P1/SimpleCSRF.pl第41行。
为什么写不出来?这是对ssl页面的简单请求? 如何启用更详细的调试以查看返回的内容?
我也尝试使用SSL轻松,每次都得到302响应。
use strict;
使用警告; 使用Net :: SSLeay qw(get_https post_https sslcat make_headers make_form);
my $head=<<HEADREQUEST;
Host: ta.example.co.il
Connection: keep-alive
Content-Length: 154768
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: https://ta.example.co.il
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: https://ta.example.co.il/f5-w-687474703a2f2f746573742e636c616c6e65742e636f2e696c$$/testing/notificationsandalerts/Pages/Default.aspx?txtTabID=0&txtType=1
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en,en-US;q=0.8
Cookie: TIN=15000; LastMRH_Session=8acc0244; MRHSession=f5d160f7be2a40e290cd37f38acc0244; MRHSequence=1382340967; F5_ST=1382340968c900c100c1382340968c604800c600c
HEADREQUEST
my $body=<<BODY;
AGRkZAIDDc_46c9_9a5a_167e29fefb40%24txtCSRFValidation=&ctl00%24SPWebPartManager1%24g_137a0e02_1a49_45df_a17f_45dd7b48cbca%24txtCSRFValidation=
BODY
my $url='/f5-w-687474703a2f2f746573742e636c616c6e65742e636f2e696c$$/testing/notificationsandalerts/Pages/Default.aspx?txtTabID=0&txtType=1 ';
my ($page, $response, %reply_headers)= post_https('ta.example.co.il', 443, $url, $head,$body );
print $response;
答案 0 :(得分:0)
您从每个模块使用哪些版本?您使用的是哪个perl版本?
他们安装得好吗?
如果有帮助,那么在sisyphusion回购网站(以及可能在其他地方)的Net :: SSLeay都有ppm套餐:
ppm install http://www.sisyphusion.tk/ppm/Net-SSLeay.ppd
我使用了这段代码,但它确实有效。
use LWP::UserAgent;
use HTTP::Request::Common;
use Data::Dumper;
local $ENV{'HTTPS_DEBUG'} = 1; # Will show SSL assertions
my $URL="https://www.google.com/";
my $UA = LWP::UserAgent->new();
my $xml = <<XMLREQUEST;
__SPSCEditMenu=true
XMLREQUEST
$UA->ssl_opts(
SSL_verify_mode => 'SSL_VERIFY_NONE',
);
my $req =HTTP::Request::Common::POST("$URL",
Content_type=>'form-data',
Content =>$xml
);
$req->header('Cookie' =>q( Cookie: TIN=294000; LastMRH_Session=ca480946; MRHSession=7e53c7507df395d38a2eb230ca480946; F5_ST=1382338632c900c100c1382338632c604800c600c; MRHSequence=1382338609),
'DNT'=>'1',
'Referer'=> 'https://google.co.uk',
'User-Agent'=>'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; EIE10;HEILMSN',
'Content-Type'=>'application/x-www-form-urlencoded');
print Dumper($req);