All Projects → robinpowered → php-ntlm

robinpowered / php-ntlm

Licence: Apache-2.0 license
Message encoder/decoder and password hasher for the NTLM authentication protocol

Programming Languages

PHP
23972 projects - #3 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to php-ntlm

Bughunt
A weekly challenge where we share some code and you find a bug in it.
Stars: ✭ 68 (+385.71%)
Mutual labels:  challenge, hash
developer-challenge
No description or website provided.
Stars: ✭ 36 (+157.14%)
Mutual labels:  challenge
go-http-ntlm
NTLM authenticated http request for Go
Stars: ✭ 43 (+207.14%)
Mutual labels:  ntlm
JSum
Consistent checksum calculation of JSON objects.
Stars: ✭ 64 (+357.14%)
Mutual labels:  hash
hackathon
Repositório de hackathons do Training Center
Stars: ✭ 20 (+42.86%)
Mutual labels:  challenge
pthash
Fast and compact minimal perfect hash functions in C++.
Stars: ✭ 62 (+342.86%)
Mutual labels:  hash
hash
Data management, integration and modeling with blocks #
Stars: ✭ 400 (+2757.14%)
Mutual labels:  hash
awesome-identicons
A curated list of "Visual Hashs" (Identicon, Avatar, Fractal, RandomArt and general Hash Visualization)
Stars: ✭ 156 (+1014.29%)
Mutual labels:  hash
crypthash-net
CryptHash.NET is a .NET multi-target library to encrypt/decrypt/hash/encode/decode strings and files, with an optional .NET Core multiplatform console utility.
Stars: ✭ 33 (+135.71%)
Mutual labels:  hash
phpass-starter
A starter project for Phpass.
Stars: ✭ 24 (+71.43%)
Mutual labels:  hash
proxyplease
Cross-platform proxy selection with optional native authentication negotiation
Stars: ✭ 37 (+164.29%)
Mutual labels:  ntlm
jscrypto
Crypto library for Node/ES6/Typescript/Browser.
Stars: ✭ 20 (+42.86%)
Mutual labels:  hash
komihash
Very fast, high-quality hash function (non-cryptographic, C) + PRNG
Stars: ✭ 68 (+385.71%)
Mutual labels:  hash
Valour
An open source chat client for freedom
Stars: ✭ 52 (+271.43%)
Mutual labels:  hash
lthash
A homomorphic hash function
Stars: ✭ 61 (+335.71%)
Mutual labels:  hash
bromberg sl2
Cayley hashing as in "Navigating in the Cayley Graph of SL₂(𝔽ₚ)"
Stars: ✭ 32 (+128.57%)
Mutual labels:  hash
laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (+64.29%)
Mutual labels:  hash
bootcamp-gostack-desafio-04
Desafio do quarto módulo do Bootcamp GoStack 🚀👨🏻‍🚀
Stars: ✭ 50 (+257.14%)
Mutual labels:  challenge
ten-years
Ten Years Reproducibility Challenge
Stars: ✭ 59 (+321.43%)
Mutual labels:  challenge
LinuxHashCracker
🔨 Linux Hash Cracker
Stars: ✭ 19 (+35.71%)
Mutual labels:  hash

PHP NTLM

Build Status Quality Score Latest Stable Version

PHP-NTLM is a library that handles the encoding and decoding of messages used in the challenge-and-response flow of the NTLM authentication protocol, while also providing separate injectable credential hashing mechanisms to allow for a more secure version of a credential for storage (rather than storing passwords in "plain-text").

Features

  • NTLM client message encoding and decoding
  • Multiple text-encoding native-extensions supported
  • LM, NTv1, and NTv2 hashing algorithms supported

Requirements

  • 64-bit PHP runtime (NTLM negotiation bit flags extend beyond the 32-bit integer size)
  • PHP >=7.1.0

Installation

  1. Get Composer
  2. Add robinpowered/php-ntlm to your Composer required dependencies: composer require robinpowered/php-ntlm
  3. Include the Composer autoloader

Example Usage

// Using Guzzle
$client = new Client();
$request = new Request('get', 'https://my-exchange-url.com');
$user_name = 'user_name';
$password = 'password';
$target_name = 'target_name';
$host_name = 'host_name';

$encoding_converter = new MbstringEncodingConverter();
$random_byte_generator = new NativeRandomByteGenerator();
$hasher_factory = HasherFactory::createWithDetectedSupportedAlgorithms();

$negotiate_message_encoder = new NegotiateMessageEncoder($encoding_converter);
$challenge_message_decoder = new ChallengeMessageDecoder();

$keyed_hasher_factory = KeyedHasherFactory::createWithDetectedSupportedAlgorithms();

$nt1_hasher = new NtV1Hasher($hasher_factory, $encoding_converter);
$nt2_hasher = new NtV2Hasher($nt1_hasher, $keyed_hasher_factory, $encoding_converter);

$authenticate_message_encoder = new NtlmV2AuthenticateMessageEncoder(
    $encoding_converter,
    $nt2_hasher,
    $random_byte_generator,
    $keyed_hasher_factory
);

$negotiate_message = $negotiate_message_encoder->encode(
    $target_name,
    $host_name
);

// Send negotiate message
$request->setHeader('Authorization', sprintf('NTLM %s', base64_encode($negotiate_message)));
$response = $client->send($request);

// Decode returned challenge message
$authenticate_headers = $response->getHeaderAsArray('WWW-Authenticate');
foreach ($authenticate_headers as $header_string) {
    $ntlm_matches = preg_match('/NTLM( (.*))?/', $header_string, $ntlm_header);

    if (0 < $ntlm_matches && isset($ntlm_header[2])) {
        $raw_server_challenge = base64_decode($ntlm_header[2]);
        break;
    }
}
$server_challenge = $challenge_message_decoder->decode($raw_server_challenge);

$authenticate_message = $authenticate_message_encoder->encode(
    $user_name,
    $target_name,
    $host_name,
    new Password($password),
    $server_challenge
);

// Send authenticate message
$request->setHeader('Authorization', sprintf('NTLM %s', base64_encode($authenticate_message)));
$client->send($request);

TODO

  • LM hashing
  • NTv1 hashing
  • NTv2 hashing
  • NTLM negotiate message encoding
  • NTLM challenge message decoding
    • Message structure and data validation
    • Negotiate flag decoding
    • Server challenge "nonce" handling
    • TargetName parsing/handling
    • (Optional) TargetInfo parsing/handling
      • (Optional) AV_PAIR decoding
    • (Optional) Version parsing/handling (for debugging purposes only)
  • NTLM authenticate message encoding
    • NTLM v1 response support
    • NTLM v2 response support
    • Extended session security (NTLM2 session key) support
    • (Add-on) Encrypted session key exchange support
  • Datagram ("connectionless") support
  • Tests

License

PHP-NTLM is licensed under the Apache License, Version 2.0.


Copyright 2019 Robin Powered, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].