Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add of NTLM support in order parse IIS site #52

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions anemone.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ spec = Gem::Specification.new do |s|
s.add_dependency("nokogiri", ">= 1.3.0")
s.add_dependency("robotex", ">= 1.0.0")

s.add_development_dependency "ruby-ntlm", ">=0.0.1"
s.add_development_dependency "rake", ">=0.9.2"
s.add_development_dependency "rdoc", ">=3.12"
s.add_development_dependency "rspec", ">=2.8.0"
Expand Down
10 changes: 9 additions & 1 deletion lib/anemone/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,15 @@ class Core
# proxy server port number
:proxy_port => false,
# HTTP read timeout in seconds
:read_timeout => nil
:read_timeout => nil,
# Are we using NTLM protocol ?
:use_ntlm => false,
# NTLM user name
:ntlm_user => nil,
# NTLM domain name
:ntlm_domain => nil,
# NTLM password
:ntlm_password => nil
}

# Create setter methods for all options to be called from the crawl block
Expand Down
21 changes: 16 additions & 5 deletions lib/anemone/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,22 @@ def get_response(url, referer = nil)
retries = 0
begin
start = Time.now()
# format request
req = Net::HTTP::Get.new(full_path, opts)
# HTTP Basic authentication
req.basic_auth url.user, url.password if url.user
response = connection(url).request(req)
req = nil
response = nil
if ! @opts[:use_ntlm]
# format request
req = Net::HTTP::Get.new(full_path, opts)
# HTTP Basic authentication
req.basic_auth url.user, url.password if url.user
response = connection(url).request(req)
else
require 'ntlm/http'
# format request
req = Net::HTTP::Get.new(full_path, opts)
# NTLM authentication
req.ntlm_auth(@opts[:ntlm_user], @opts[:ntlm_domain], @opts[:ntlm_password])
response = connection(url).request(req)
end
finish = Time.now()
response_time = ((finish - start) * 1000).round
@cookie_store.merge!(response['Set-Cookie']) if accept_cookies?
Expand Down