Perl to get http page with LWP NTLM authentication

原创 2011年10月10日 15:30:22


1. Make sure the correct Authen::NTLM module written byMark Bush installed.

2. Make sure the module named MIME::base64 & LWP::Authen::Negotiate installed.

You can run: perl -e 'print join "\n", @INC' to know perl modules located and check if these modules are installed.


3. Have manually following patch:

    $domain = substr($c_info->{buffer}, 0, $c_info->{domain}{len});

    replacing to

    $domain = &unicode($domain);


I got below sample code worked.

#!/usr/bin/perl

use LWP::UserAgent;
use HTTP::Request::Common;
use LWP::Debug qw(+);
use strict;
use warnings;

my $url = "http://10.1.1.1";

my $ua = new LWP::UserAgent(keep_alive => 1);

$ua->credentials('10.1.1.1:80', '', 'domain\user', 'password');
my $req = GET $url; 
print "--Peforming request now...---------\n";
my $res = $ua->request($req);
print "--Done with request ...---------\n";

# check the outcome
if ($res->is_success) {
    print $res->content;
} else {
    print "Error: " . $res->status_line . "\n";
}

exit 0;

Now the next problem is happening - it redirects to 10.1.1.2?

Neccessarily modules installation history -


Installing /usr/local/share/perl/5.10.1/Encode/Locale.pm
Installing /usr/local/man/man3/Encode::Locale.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/HTTP-Date-6.00$ sudo make install
Installing /usr/local/share/perl/5.10.1/HTTP/Date.pm
Installing /usr/local/man/man3/HTTP::Date.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/File-Listing-6.03$ sudo make install
Installing /usr/local/share/perl/5.10.1/File/Listing.pm
Installing /usr/local/man/man3/File::Listing.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


Installing /usr/lib/perl/5.10/auto/Compress/Raw/Bzip2/Bzip2.bs
Installing /usr/lib/perl/5.10/auto/Compress/Raw/Bzip2/Bzip2.so
Installing /usr/lib/perl/5.10/auto/Compress/Raw/Bzip2/autosplit.ix
Installing /usr/lib/perl/5.10/Compress/Raw/Bzip2.pm
Installing /usr/share/man/man3/Compress::Raw::Bzip2.3pm
tied@tied-laptop:~/netcrack/Compress-Raw-Bzip2-2.037$ 


tied@tied-laptop:~/netcrack/Compress-Raw-Zlib-2.037$ sudo make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib/perl/5.10/auto/Compress/Raw/Zlib/Zlib.so
Installing /usr/lib/perl/5.10/auto/Compress/Raw/Zlib/Zlib.bs
Installing /usr/lib/perl/5.10/auto/Compress/Raw/Zlib/autosplit.ix
Installing /usr/lib/perl/5.10/Compress/Raw/Zlib.pm
Installing /usr/share/man/man3/Compress::Raw::Zlib.3pm


tied@tied-laptop:~/netcrack/IO-Compress-2.037$ sudo make install
Installing /usr/lib/perl/5.10/Compress/Zlib.pm
Installing /usr/lib/perl/5.10/File/GlobMapper.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/AnyUncompress.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/RawInflate.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/AnyInflate.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Unzip.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Base.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Gunzip.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Bunzip2.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Inflate.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Adapter/Identity.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Adapter/Bunzip2.pm
Installing /usr/lib/perl/5.10/IO/Uncompress/Adapter/Inflate.pm
Installing /usr/lib/perl/5.10/IO/Compress/RawDeflate.pm
Installing /usr/lib/perl/5.10/IO/Compress/Bzip2.pm
Installing /usr/lib/perl/5.10/IO/Compress/Zip.pm
Installing /usr/lib/perl/5.10/IO/Compress/Base.pm
Installing /usr/lib/perl/5.10/IO/Compress/Deflate.pm
Installing /usr/lib/perl/5.10/IO/Compress/Gzip.pm
Installing /usr/lib/perl/5.10/IO/Compress/Gzip/Constants.pm
Installing /usr/lib/perl/5.10/IO/Compress/Base/Common.pm
Installing /usr/lib/perl/5.10/IO/Compress/Adapter/Bzip2.pm
Installing /usr/lib/perl/5.10/IO/Compress/Adapter/Identity.pm
Installing /usr/lib/perl/5.10/IO/Compress/Adapter/Deflate.pm
Installing /usr/lib/perl/5.10/IO/Compress/Zlib/Extra.pm
Installing /usr/lib/perl/5.10/IO/Compress/Zlib/Constants.pm
Installing /usr/lib/perl/5.10/IO/Compress/Zip/Constants.pm
Installing /usr/share/man/man3/File::GlobMapper.3pm
Installing /usr/share/man/man3/IO::Compress::Bzip2.3pm
Installing /usr/share/man/man3/IO::Uncompress::Bunzip2.3pm
Installing /usr/share/man/man3/IO::Uncompress::Unzip.3pm
Installing /usr/share/man/man3/IO::Compress::Zip.3pm
Installing /usr/share/man/man3/IO::Uncompress::Base.3pm
Installing /usr/share/man/man3/IO::Uncompress::AnyInflate.3pm
Installing /usr/share/man/man3/IO::Uncompress::Gunzip.3pm
Installing /usr/share/man/man3/Compress::Zlib.3pm
Installing /usr/share/man/man3/IO::Compress::Gzip.3pm
Installing /usr/share/man/man3/IO::Compress::Base.3pm
Installing /usr/share/man/man3/IO::Compress::RawDeflate.3pm
Installing /usr/share/man/man3/IO::Uncompress::AnyUncompress.3pm
Installing /usr/share/man/man3/IO::Compress::Deflate.3pm
Installing /usr/share/man/man3/IO::Uncompress::RawInflate.3pm
Installing /usr/share/man/man3/IO::Uncompress::Inflate.3pm
tied@tied-laptop:~/netcrack/IO-Compress-2.037$ 


tied@tied-laptop:~/netcrack/LWP-MediaTypes-6.01$ sudo make install
Installing /usr/local/share/perl/5.10.1/LWP/media.types
Installing /usr/local/share/perl/5.10.1/LWP/MediaTypes.pm
Installing /usr/local/man/man3/LWP::MediaTypes.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/HTTP-Message-6.02$ sudo make install
Installing /usr/local/share/perl/5.10.1/HTTP/Status.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Request.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Headers.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Response.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Message.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Config.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Request/Common.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Headers/Auth.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Headers/ETag.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Headers/Util.pm
Installing /usr/local/man/man3/HTTP::Headers.3pm
Installing /usr/local/man/man3/HTTP::Message.3pm
Installing /usr/local/man/man3/HTTP::Headers::Util.3pm
Installing /usr/local/man/man3/HTTP::Config.3pm
Installing /usr/local/man/man3/HTTP::Response.3pm
Installing /usr/local/man/man3/HTTP::Status.3pm
Installing /usr/local/man/man3/HTTP::Request.3pm
Installing /usr/local/man/man3/HTTP::Request::Common.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


Installing /usr/local/share/perl/5.10.1/HTTP/Cookies.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Cookies/Microsoft.pm
Installing /usr/local/share/perl/5.10.1/HTTP/Cookies/Netscape.pm
Installing /usr/local/man/man3/HTTP::Cookies.3pm
Installing /usr/local/man/man3/HTTP::Cookies::Microsoft.3pm
Installing /usr/local/man/man3/HTTP::Cookies::Netscape.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod
tied@tied-laptop:~/netcrack/HTTP-Cookies-6.00$ 


tied@tied-laptop:~/netcrack/HTTP-Daemon-6.00$ sudo make install
[sudo] password for tied: 
Installing /usr/local/share/perl/5.10.1/HTTP/Daemon.pm
Installing /usr/local/man/man3/HTTP::Daemon.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/HTTP-Negotiate-6.00$ sudo make install
Installing /usr/local/share/perl/5.10.1/HTTP/Negotiate.pm
Installing /usr/local/man/man3/HTTP::Negotiate.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/Net-HTTP-6.01$ sudo make install
Installing /usr/local/share/perl/5.10.1/Net/HTTPS.pm
Installing /usr/local/share/perl/5.10.1/Net/HTTP.pm
Installing /usr/local/share/perl/5.10.1/Net/HTTP/NB.pm
Installing /usr/local/share/perl/5.10.1/Net/HTTP/Methods.pm
Installing /usr/local/man/man3/Net::HTTP::NB.3pm
Installing /usr/local/man/man3/Net::HTTP.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/WWW-RobotRules-6.01$ sudo make install
Installing /usr/local/share/perl/5.10.1/WWW/RobotRules.pm
Installing /usr/local/share/perl/5.10.1/WWW/RobotRules/AnyDBM_File.pm
Installing /usr/local/man/man3/WWW::RobotRules.3pm
Installing /usr/local/man/man3/WWW::RobotRules::AnyDBM_File.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/libwww-perl-6.02$ sudo make install
[sudo] password for tied: 
Installing /usr/local/share/perl/5.10.1/lwptut.pod
Installing /usr/local/share/perl/5.10.1/LWP.pm
Installing /usr/local/share/perl/5.10.1/lwpcook.pod
Installing /usr/local/share/perl/5.10.1/LWP/MemberMixin.pm
Installing /usr/local/share/perl/5.10.1/LWP/DebugFile.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol.pm
Installing /usr/local/share/perl/5.10.1/LWP/Debug.pm
Installing /usr/local/share/perl/5.10.1/LWP/RobotUA.pm
Installing /usr/local/share/perl/5.10.1/LWP/Simple.pm
Installing /usr/local/share/perl/5.10.1/LWP/ConnCache.pm
Installing /usr/local/share/perl/5.10.1/LWP/UserAgent.pm
Installing /usr/local/share/perl/5.10.1/LWP/Authen/Basic.pm
Installing /usr/local/share/perl/5.10.1/LWP/Authen/Digest.pm
Installing /usr/local/share/perl/5.10.1/LWP/Authen/Ntlm.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/data.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/nntp.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/ftp.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/file.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/loopback.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/cpan.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/mailto.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/GHTTP.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/nogo.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/gopher.pm
Installing /usr/local/share/perl/5.10.1/LWP/Protocol/http.pm
Installing /usr/local/man/man1/lwp-request.1p
Installing /usr/local/man/man1/lwp-download.1p
Installing /usr/local/man/man1/lwp-dump.1p
Installing /usr/local/man/man1/lwp-mirror.1p
Installing /usr/local/man/man3/LWP::MemberMixin.3pm
Installing /usr/local/man/man3/LWP::UserAgent.3pm
Installing /usr/local/man/man3/LWP::ConnCache.3pm
Installing /usr/local/man/man3/lwptut.3pm
Installing /usr/local/man/man3/LWP::Debug.3pm
Installing /usr/local/man/man3/LWP.3pm
Installing /usr/local/man/man3/LWP::Protocol.3pm
Installing /usr/local/man/man3/LWP::Authen::Ntlm.3pm
Installing /usr/local/man/man3/LWP::RobotUA.3pm
Installing /usr/local/man/man3/LWP::Simple.3pm
Installing /usr/local/man/man3/lwpcook.3pm
Installing /usr/local/bin/lwp-download
Installing /usr/local/bin/lwp-request
Installing /usr/local/bin/lwp-mirror
Installing /usr/local/bin/lwp-dump
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/Digest-HMAC-1.03$ sudo make install
Installing /usr/local/share/perl/5.10.1/Digest/HMAC_SHA1.pm
Installing /usr/local/share/perl/5.10.1/Digest/HMAC.pm
Installing /usr/local/share/perl/5.10.1/Digest/HMAC_MD5.pm
Installing /usr/local/man/man3/Digest::HMAC.3pm
Installing /usr/local/man/man3/Digest::HMAC_MD5.3pm
Installing /usr/local/man/man3/Digest::HMAC_SHA1.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/NTLM-1.09$ sudo make install
make[1]: Entering directory `/home/tied/netcrack/NTLM-1.09/DES'
make[1]: Leaving directory `/home/tied/netcrack/NTLM-1.09/DES'
make[1]: Entering directory `/home/tied/netcrack/NTLM-1.09/MD4'
make[1]: Leaving directory `/home/tied/netcrack/NTLM-1.09/MD4'
Installing /usr/local/share/perl/5.10.1/Authen/NTLM.pm
Installing /usr/local/share/perl/5.10.1/Authen/NTLM/DES.pm
Installing /usr/local/share/perl/5.10.1/Authen/NTLM/MD4.pm
Installing /usr/local/man/man3/Authen::NTLM.3pm
Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod


tied@tied-laptop:~/netcrack/MIME-Base64-3.13$ sudo make install
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib/perl/5.10/auto/MIME/Base64/Base64.bs
Installing /usr/lib/perl/5.10/auto/MIME/Base64/Base64.so
Installing /usr/lib/perl/5.10/MIME/Base64.pm
Installing /usr/lib/perl/5.10/MIME/QuotedPrint.pm
Installing /usr/share/man/man3/MIME::QuotedPrint.3pm
Installing /usr/share/man/man3/MIME::Base64.3pm


========================================================================


reference to http://www.innovation.ch/personal/ronald/ntlm.html

相关文章推荐

基于How To Tango With Django 1.9的重新实践(9)——User Authentication

教程的下一部分将教会你Django的用户验证机制.我们将会使用Django标准包django.contrib.auth的auth应用.通过 Django’s official documentatio...

【perl】使用LWP获取带cookie验证的HTTPS网页

最近想到公司网站下一些文档,结果网站上做了下载总大小限制,没办法只好写个脚本来获取。               运行环境1:Windows XP     StrawberryPerl 5.10 ...
  • ace_fei
  • ace_fei
  • 2012年02月16日 15:16
  • 5094

Use Jquery to get json data from the server-side php page

Server-side: $bookmarkarray = array(); if(mysqli_connect_error()) { echo "failed to connect to t...

Liferay on Private Site to get Public Site Page URL

This is a very interesting design in our website. We have a private site only for registered member....

How to get a web page content type

A web page’s content type tells you the page's MIME type (such as “text/html” or “image/png”) and ...

基于How To Tango With Django 1.9的重新实践(11)——User Authentication with {#chapter-redux}

在上一章中,我们通过手动编写URL,视图和模板来添加登录和注册功能。然而,这样的功能是许多web应用程序所共有的,所以开发人员已经创建了许多附加应用程序,可以包括在您的Django项目中,以减少提供登...

spring mvc page not found no mapping found for http request with uri

我这里的报错实际情况是: 14:02:15,736 WARN  [PageNotFound] No mapping found for HTTP request with URI [/spring3...

The NTLM Authentication Protocol

Copyright © 2003 Eric Glass Permission to use, copy, modify, and distribute this document for any pu...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Perl to get http page with LWP NTLM authentication
举报原因:
原因补充:

(最多只允许输入30个字)