0

这是我的代码

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 easy,每次都得到 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;
4

1 回答 1

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);
于 2013-10-21T08:52:06.053 回答