如何使用 LWP 发送 POST 数据?

发布于 2024-09-25 12:04:09 字数 753 浏览 1 评论 0原文

我想制作一个与 http://www.md5crack.com/crackmd5.php。我的目标是向该网站发送一个哈希值 (md5),并希望该网站能够破解它。之后,我想显示哈希的明文。我的问题是将数据发送到站点。我查阅了有关使用 LWP 的文章,但我仍然迷失方向。现在,哈希值没有发送,而是其他一些垃圾数据。我将如何向网站发送特定的数据字符串?

use HTTP::Request::Common qw(POST);  
use LWP::UserAgent; 


$ua = LWP::UserAgent->new();  
my $req = POST 'http://www.md5crack.com/crackmd5.php', [ 
 maxlength=> '2048',
 name=> 'term',
 size=>'55',
 title=>'md5 hash to crack',
 value=> '098f6bcd4621d373cade4e832627b4f6',
 name=>'crackbtn',
 type=>'submit',
 value=>'Crack that hash baby!',

]; 
$content = $ua->request($req)->as_string; 

print "Content-type: text/html\n\n"; 
print $content;

I want to make a program that communicates with http://www.md5crack.com/crackmd5.php. My goal is to send the site a hash (md5) and hopefully the site will be able to crack it. After, I would like to display the plaintext of the hash. My problem is sending the data to the site. I looked up articles about using LWP however I am still lost. Right now, the hash is not sending, some other junk data is. How would I go about sending a particular string of data to the site?

use HTTP::Request::Common qw(POST);  
use LWP::UserAgent; 


$ua = LWP::UserAgent->new();  
my $req = POST 'http://www.md5crack.com/crackmd5.php', [ 
 maxlength=> '2048',
 name=> 'term',
 size=>'55',
 title=>'md5 hash to crack',
 value=> '098f6bcd4621d373cade4e832627b4f6',
 name=>'crackbtn',
 type=>'submit',
 value=>'Crack that hash baby!',

]; 
$content = $ua->request($req)->as_string; 

print "Content-type: text/html\n\n"; 
print $content;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏别ゝ 2024-10-02 12:04:09

您发布了错误的数据,因为您使用 HTML 来指定小部件并将其与实际发送的数据混为一谈。更正的数据将只是发送小部件名称及其值:

term: 098f6bcd4621d373cade4e832627b4f6

相反,当前发布的数据是:

maxlength: 2048
name:      term
size:      55
title:     md5 hash to crack
value:     098f6bcd4621d373cade4e832627b4f6
name:      crackbtn
type:      submit
value:     Crack that hash baby!

更正的程序:

use strict;
use warnings;

use LWP::UserAgent; 
use HTTP::Request::Common qw{ POST };
use CGI;

my $md5 = '098f6bcd4621d373cade4e832627b4f6';
my $url = 'http://www.md5crack.com/crackmd5.php';

my $ua      = LWP::UserAgent->new();
my $request = POST( $url, [ 'term' => $md5 ] );
my $content = $ua->request($request)->as_string();

my $cgi = CGI->new();
print $cgi->header(), $content;

您还可以使用 LWP::UserAgent 的 post() 方法:

use strict;
use warnings;

use LWP::UserAgent;
use CGI;

my $md5 = '098f6bcd4621d373cade4e832627b4f6';
my $url = 'http://www.md5crack.com/crackmd5.php';

my $ua       = LWP::UserAgent->new();
my $response = $ua->post( $url, { 'term' => $md5 } );
my $content  = $response->decoded_content();

my $cgi = CGI->new();
print $cgi->header(), $content;

永远记住 使用严格使用警告。这被认为是很好的做法,可以节省您的时间。

You are POSTing the wrong data because you're taking the HTML to specify the widget and conflating it with the data it actually sends. The corrected data would be to just send the widget name and its value:

term: 098f6bcd4621d373cade4e832627b4f6

Instead, the data that is getting POSTed currently is:

maxlength: 2048
name:      term
size:      55
title:     md5 hash to crack
value:     098f6bcd4621d373cade4e832627b4f6
name:      crackbtn
type:      submit
value:     Crack that hash baby!

Corrected program:

use strict;
use warnings;

use LWP::UserAgent; 
use HTTP::Request::Common qw{ POST };
use CGI;

my $md5 = '098f6bcd4621d373cade4e832627b4f6';
my $url = 'http://www.md5crack.com/crackmd5.php';

my $ua      = LWP::UserAgent->new();
my $request = POST( $url, [ 'term' => $md5 ] );
my $content = $ua->request($request)->as_string();

my $cgi = CGI->new();
print $cgi->header(), $content;

You can also use LWP::UserAgent's post() method:

use strict;
use warnings;

use LWP::UserAgent;
use CGI;

my $md5 = '098f6bcd4621d373cade4e832627b4f6';
my $url = 'http://www.md5crack.com/crackmd5.php';

my $ua       = LWP::UserAgent->new();
my $response = $ua->post( $url, { 'term' => $md5 } );
my $content  = $response->decoded_content();

my $cgi = CGI->new();
print $cgi->header(), $content;

Always remember to use strict and use warnings. It is considered good practice and will save your time.

看春风乍起 2024-10-02 12:04:09

过去,破解者会通过阅读来解决这类问题。 HTTP::Request::Common 中有示例,LWP::UserAgent 告诉您检查是否发送 POST 数据。您只需要发送表单数据,而不是随之而来的元数据。

您可能会更轻松地使用 WWW::Mechanize,因为它具有更人性化的功能 -中心界面。

It used to be that crackers would figure this sort of stuff out by reading. There are examples in HTTP::Request::Common, which LWP::UserAgent tells you to check out for sending POST data. You only need to send the form data, not the meta data that goes with it.

You might have an easier time using WWW::Mechanize since it has a much more human-centric interface.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文