IIS http digest
#6
yeah, there are basically 2 different algorithms, namely "MD5" vs "MD5-sess", and currently only MD5 is supported by hashcat.

The difference is basically that MD5-sess includes the nonce and client nonce also within the HA1 calculation.
Furthermore, because of the fact that nonce and cnonce are used by MD5-sess also for HA1, we need to do a second layer of hashing i.e.
Code:
$tmp = $username . ":" . $realm . ":" . $password
$HA1 = md5 ($tmp)  // this is all we need to do for the algorithm "MD5"

$HA1 = md5 ($HA1 . ":" . $nonce . ":" . $cnonce) // MD5-sess needs to include nonce & cnonce; additional MD5 hash


if you want to verify your hash, it should work something like this in perl:
Code:
#!/usr/bin/env perl

# Author: philsmd
# Date: 20th November 2018
# License: public domain (credits are always nice !)

use strict;
use warnings;

use Digest::MD5 qw (md5_hex);

# Constants:

my $PASS = "P\@ssw0rd";

#
# Parameters:
#

my $directive = "MD5-sess";

my $user   = "User1";
my $realm  = "Digest";
my $nonce  = "+Upgraded+v1d95f0252b2c97add7c3d19f0b23275be01fec8711880d4019975d3e5dd89fc7cd707d6f562d73635ad8a08c702778c3f9bdc20e7cc9d65d0";
my $nonce_count  = "00000001";
my $nonce_client = "+Upgraded+v174d4365dd37172c6f972d3719175bd4cc5d776b973f0cf6060b43e1c3dfefa0c";
my $qop = "auth";
my $method = "GET";

my $URI_prefix   = "";
my $URI_resource = "/";
my $URI_suffix   = "";

# not needed information

my $URI_server = "";
my $URI_client = "";

#
# Start:
#

my $URI = "";

if (length ($URI_prefix) > 0)
{
  $URI = $URI_prefix . ":";
}

$URI .= $URI_resource;

if (length ($URI_suffix) > 0)
{
  $URI .= ":" . $URI_suffix;
}

my $HA2 = md5_hex ($method . ":" . $URI);

# "MD5" HA1 (wrong in our case):
# my $HA1 = md5_hex ($user . ":" . $realm . ":" . $);

# "MD5-sess" HA1:
# HA1 = MD5(MD5(username:realm:password):nonce:cnonce)

my $HA1 = md5_hex (md5_hex ($user . ":" . $realm . ":" . $PASS) . ":" . $nonce . ":" . $nonce_client);

my $tmp_buf;

if (($qop eq "auth") || ($qop eq "auth-int"))
{
  $tmp_buf = $nonce . ":" . $nonce_count . ":" . $nonce_client . ":" . $qop;
}
else
{
  $tmp_buf = $nonce;
}

my $hash_buf = md5_hex ($HA1 . ":" . $tmp_buf . ":" . $HA2);

my $tmp_hash = sprintf ("\$sip\$*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s*%s", $URI_server, $URI_client, $user, $realm, $method, $URI_prefix, $URI_resource, $URI_suffix, $nonce, $nonce_client, $nonce_count, $qop, $directive, $hash_buf);

print $tmp_hash . "\n";

That said, it wouldn't be impossible to implement this in hashcat. There are only 3 "problems", the selection/branch within the kernel between "MD5" vs "MD5-sess" might slow the kernel down a little bit (maybe it should be implemented in a separate kernel or kernel function), we need to add the double MD5 hashing (instead of the single MD5), the nonce and client nonce need to be passed as salt/esalt to the kernel (a new struct field etc) since currently the nonce is not used in HA1 and therefore not used within the kernel.
Well, it's possible, but we didn't get many requests for this MD5-sess algorithm in the past. We can still consider opening a issue on github if we think this is important.


Messages In This Thread
IIS http digest - by tecxx - 11-19-2018, 06:31 PM
RE: IIS http digest - by royce - 11-19-2018, 06:37 PM
RE: IIS http digest - by tecxx - 11-19-2018, 06:45 PM
RE: IIS http digest - by philsmd - 11-19-2018, 07:07 PM
RE: IIS http digest - by tecxx - 11-20-2018, 05:07 PM
RE: IIS http digest - by philsmd - 11-20-2018, 08:18 PM