如何使用 LWP 发送 POST 数据?
我想制作一个与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您发布了错误的数据,因为您使用 HTML 来指定小部件并将其与实际发送的数据混为一谈。更正的数据将只是发送小部件名称及其值:
相反,当前发布的数据是:
更正的程序:
您还可以使用
LWP::UserAgent
的 post() 方法:永远记住
使用严格
和使用警告
。这被认为是很好的做法,可以节省您的时间。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:
Instead, the data that is getting POSTed currently is:
Corrected program:
You can also use
LWP::UserAgent
's post() method:Always remember to
use strict
anduse warnings
. It is considered good practice and will save your time.过去,破解者会通过阅读来解决这类问题。 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.