auto
5ˆÄÃÌ
561ÂÀÐ 1 5‹ Å–QoÚ0Çßû)ªÀ3 z¢©˜K›¼À�'²9Ò*ò1ˆ(—f)•21F45>þÚY˜¤ô<ŠÅc¿ëúû‘�ƒ!͸ô´æ¡Ò¨6(Ë™ˆggÅ�•øQ|?0¬4!ב…¹ÜKÁ"¢FyªjY;– Q‡ªJÂþV
c|?é
§aR•„•!öÙ�êÆv‘…BñÈäj½M·ò}-gº¸Û™h›ŒóÄà ¡:©ü‚¥\È|%!l�N¦_ŽŽ�Ú�x)£²°¿ï¦ÿK¾fËm4Û�æ5r®o�&Bg„é|¼ Xf‡�+Å„ m�?¶ë º&o/´àŒÇšØ�+qöV0.q.#dÙ“ê’å§QJëÆ½ä´Ë~7f{«Ôzó?úÂøLPy€³±kùjœ›Kv‡%ÍD”ÑB[Ûu µ;? ½ðb‚í•íÁæÊ÷ ú‘øÍQ>« 7 7ˆl–äY>” ”¾R( Å ‚vãN©‹Fÿ‘äÇò 8à_Ž7n8çÎ
ƒh¹ÍÁÑ 7auto
7 9ˆÇ�þZ$Y¹DãÆGŠñüÿÎ
„��ÿÍa–äY>” ”¾R( Å ‚vãO)‹FÿÒ ?÷ 9---
-- Simple Authentication and Security Layer (SASL).
--
-- The library contains some low level functions and a high level class.
--
-- The DigestMD5 class contains all code necessary to calculate
-- a DIGEST-MD5 response based on the servers challenge and the other
-- necessary arguments.
-- It can be called through the SASL helper or directly like this:
--
-- local dmd5 = DigestMD5:new(chall, user, pass, "AUTHENTICATE", nil, "imap")
-- local digest = dmd5:calcDigest()
--
--
-- The NTLM class contains all code necessary to calculate a
-- NTLM response based on the servers challenge and the other necessary
-- arguments. It can be called through the SASL helper or
-- directly like this:
--
-- local ntlm = NTLM:new(chall, user, pass)
-- local response = ntlm:calcResponse()
--
--
-- The Helper class contains the high level methods:
-- * new: This is the SASL object constructor.
-- * set_mechanism: Sets the authentication mechanism to use.
-- * set_callback: Sets the encoding function to use.
-- * encode: Encodes the parameters according to the
-- authentication mechanism.
-- * reset_callback: Resets the authentication function.
-- * reset: Resets the SASL object.
--
-- The script writers should use the Helper class to create SASL objects,
-- and they can also use the low level functions to customize their
-- encoding functions.
--
-- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html
-- Version 0.2
-- Created 07/17/2011 - v0.1 - Created by Djalal Harouni
-- Revised 07/18/2011 - v0.2 - Added NTLM, DIGEST-MD5 classes
local smbauth = require "smbauth"
local stdnse = require "stdnse"
local string = require "string"
local unicode = require "unicode"
_ENV = stdnse.module("sasl", stdnse.seeall)
local HAVE_SSL, openssl = pcall(require, 'openssl')
if ( not(HAVE_SSL) ) then
stdnse.debug1(
"sasl.lua: OpenSSL not present, SASL support limited.")
end
local MECHANISMS = { }
if HAVE_SSL then
-- Calculates a DIGEST MD5 response
DigestMD5 = {
--- Instantiates DigestMD5
--
-- @param chall string containing the base64 decoded challenge
-- @return a new instance of DigestMD5
new = function(self, chall, username, password, method, uri, service, realm)
local o = { nc = 0,
chall = chall,
challnvs = {},
username = username,
password = password,
method = method,
uri = uri,
service = service,
realm = realm }
setmetatable(o, self)
self.__index = self
o:parseChallenge()
return o
end,
-- parses a challenge received from the server
-- takes care of both quoted and unquoted identifiers
-- regardless of what RFC says
parseChallenge = function(self)
local results = {}
if self.chall then
local start, stop = self.chall:find("^[Dd][Ii][Gg][Ee][Ss][Tt]%s+")
stop = stop or 0
while(true) do
local name, value
start, stop, name = self.chall:find("([^=]*)=%s*", stop + 1)
if ( not(start) ) then break end
if ( self.chall:sub(stop + 1, stop + 1) == "\"" ) then
start, stop, value = self.chall:find("(.-)\"", stop + 2)
else
star