gpt4 book ai didi

perl - 无法使用 perl 发出 SSL 请求

转载 作者:太空宇宙 更新时间:2023-11-03 15:02:30 24 4
gpt4 key购买 nike

这是我的代码

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 中遇到这个错误。

write failed: at C:/Perl/lib/LWP/Protocol/http.pm line 356. 500 write failed: at C:/Perl/Workplace/P1/SimpleCSRF.pl line 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;

最佳答案

您使用的每个模块的版本是什么?您使用的是哪个 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);

关于perl - 无法使用 perl 发出 SSL 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19488230/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com