Documentation

NTLMAuthenticator
in package
implements AuthInterface

NTLM Auth class

Tags
category

Pop

author

Ward Peeters & Chris Corbyn, from the SwiftMailer library https://github.com/swiftmailer/swiftmailer

version
4.0.0

Table of Contents

Interfaces

AuthInterface
SMTP authenticator interface

Constants

DESCONST  = 'KGS!@#$%'
NTLMSIG  = "NTLMSSP\x00"
NTLM constants

Methods

authenticate()  : bool
Try to authenticate the user with $username and $password
getAuthKeyword()  : string
Get the name of the AUTH mechanism this Authenticator handles
castToByte()  : int
Cast to byte java equivalent to (byte)
convertTo16bit()  : string
Convert UTF-8 to UTF-16
createBlob()  : string
Create blob method
createByte()  : string
Right padding with 0 to certain length
createDesKey()  : string
Create DES key
createLMPassword()  : string
Create LMv1 response
createLMv2Password()  : string
Create LMv2 response
createMessage1()  : string
Create our message 1
createMessage3()  : string
Create our message 3
createNTLMPassword()  : string
Create NTLMv1 response
createNTLMv2Hash()  : string
Create NTLMv2 response
createSecurityBuffer()  : string
Create our security buffer depending on length and offset
debug()  : mixed
Debug method
desEncrypt()  : string
DES Encryption
getCorrectTimestamp()  : string
Convert a normal timestamp to a tenth of a microtime epoch time
getDomainAndUsername()  : array<string|int, mixed>
Get domain and username from our username
getRandomBytes()  : string
Create random bytes
hex2bin()  : string
Hex2bin replacement for < PHP 5.4
md4Encrypt()  : string
MD4 Encryption
md5Encrypt()  : string
MD5 Encryption
parseMessage2()  : array<string|int, mixed>
Fetch all details of our response (message 2)
readSecurityBuffer()  : array<string|int, mixed>
Read our security buffer to fetch length and offset of our value
readSubBlock()  : array<string|int, mixed>
Read the blob information in from message2
sendMessage1()  : string
Send our auth message and returns the response
sendMessage3()  : string
Send our final message with all our data
si2bin()  : null|string
si2bin method
uRShift()  : int
Java unsigned right bitwise $a >>> $b

Constants

Methods

authenticate()

Try to authenticate the user with $username and $password

public authenticate(AgentInterface $agent, string $username, string $password) : bool
Parameters
$agent : AgentInterface
$username : string
$password : string
Tags
throws
LogicException
Return values
bool

getAuthKeyword()

Get the name of the AUTH mechanism this Authenticator handles

public getAuthKeyword() : string
Return values
string

castToByte()

Cast to byte java equivalent to (byte)

protected castToByte(int $v) : int
Parameters
$v : int
Return values
int

convertTo16bit()

Convert UTF-8 to UTF-16

protected convertTo16bit(string $input) : string
Parameters
$input : string
Return values
string

createBlob()

Create blob method

protected createBlob(string $timestamp, string $client, string $targetInfo) : string
Parameters
$timestamp : string

Epoch timestamp in microseconds

$client : string

Random bytes

$targetInfo : string
Return values
string

createByte()

Right padding with 0 to certain length

protected createByte(string $input[, int $bytes = 4 ][, bool $isHex = true ]) : string
Parameters
$input : string
$bytes : int = 4

Length of bytes

$isHex : bool = true

Did we provided hex value

Return values
string

createDesKey()

Create DES key

protected createDesKey(mixed $key) : string
Parameters
$key : mixed
Return values
string

createLMPassword()

Create LMv1 response

protected createLMPassword(string $password, string $challenge) : string
Parameters
$password : string
$challenge : string
Return values
string

createLMv2Password()

Create LMv2 response

protected createLMv2Password(string $password, string $username, string $domain, string $challenge, string $client) : string
Parameters
$password : string
$username : string
$domain : string
$challenge : string

NTLM Challenge

$client : string

Random string

Return values
string

createMessage1()

Create our message 1

protected createMessage1() : string
Return values
string

createMessage3()

Create our message 3

protected createMessage3(string $domain, string $username, string $workstation, string $lmResponse, string $ntlmResponse) : string
Parameters
$domain : string
$username : string
$workstation : string
$lmResponse : string
$ntlmResponse : string
Return values
string

createNTLMPassword()

Create NTLMv1 response

protected createNTLMPassword(string $password, string $challenge) : string
Parameters
$password : string
$challenge : string
Return values
string

createNTLMv2Hash()

Create NTLMv2 response

protected createNTLMv2Hash(string $password, string $username, string $domain, string $challenge, string $targetInfo, string $timestamp, string $client) : string
Parameters
$password : string
$username : string
$domain : string
$challenge : string

Hex values

$targetInfo : string

Hex values

$timestamp : string
$client : string

Random bytes

Tags
see
http://davenport.sourceforge.net/ntlm.html#theNtlmResponse
Return values
string

createSecurityBuffer()

Create our security buffer depending on length and offset

protected createSecurityBuffer(string $value, int $offset[, bool $is16 = false ]) : string
Parameters
$value : string

Value we want to put in

$offset : int

start of value

$is16 : bool = false

Do we 16bit string or not?

Return values
string

debug()

Debug method

protected debug(string $message) : mixed
Parameters
$message : string

desEncrypt()

DES Encryption

protected desEncrypt(string $value, string $key) : string
Parameters
$value : string

An 8-byte string

$key : string
Return values
string

getCorrectTimestamp()

Convert a normal timestamp to a tenth of a microtime epoch time

protected getCorrectTimestamp(string $time) : string
Parameters
$time : string
Return values
string

getDomainAndUsername()

Get domain and username from our username

protected getDomainAndUsername(string $name) : array<string|int, mixed>
Parameters
$name : string
Tags
example

DOMAIN\username

Return values
array<string|int, mixed>

getRandomBytes()

Create random bytes

protected getRandomBytes(mixed $length) : string
Parameters
$length : mixed
Return values
string

hex2bin()

Hex2bin replacement for < PHP 5.4

protected hex2bin(string $hex) : string
Parameters
$hex : string
Return values
string

Binary

md5Encrypt()

MD5 Encryption

protected md5Encrypt(string $key, string $msg) : string
Parameters
$key : string

Encryption key

$msg : string

Message to encrypt

Return values
string

parseMessage2()

Fetch all details of our response (message 2)

protected parseMessage2(string $response) : array<string|int, mixed>
Parameters
$response : string
Return values
array<string|int, mixed>

our response parsed

readSecurityBuffer()

Read our security buffer to fetch length and offset of our value

protected readSecurityBuffer(string $value) : array<string|int, mixed>
Parameters
$value : string

Securitybuffer in hex

Return values
array<string|int, mixed>

array with length and offset

readSubBlock()

Read the blob information in from message2

protected readSubBlock(mixed $block) : array<string|int, mixed>
Parameters
$block : mixed
Return values
array<string|int, mixed>

sendMessage3()

Send our final message with all our data

protected sendMessage3(string $response, string $username, string $password, string $timestamp, string $client, AgentInterface $agent[, bool $v2 = true ]) : string
Parameters
$response : string

Message 1 response (message 2)

$username : string
$password : string
$timestamp : string
$client : string
$agent : AgentInterface
$v2 : bool = true

Use version2 of the protocol

Return values
string

si2bin()

si2bin method

protected si2bin(mixed $si[, int $bits = 32 ]) : null|string
Parameters
$si : mixed
$bits : int = 32
Return values
null|string

uRShift()

Java unsigned right bitwise $a >>> $b

protected uRShift(int $a, int $b) : int
Parameters
$a : int
$b : int
Return values
int

        
On this page

Search results