mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-07-01 23:43:16 +02:00
Added SMB2 message signing tests
This commit is contained in:
parent
fdf403d424
commit
d3c46361d2
2 changed files with 53 additions and 0 deletions
|
@ -535,6 +535,7 @@
|
|||
<Compile Include="Tests\NTLMSigningTests.cs" />
|
||||
<Compile Include="Tests\RC4Tests.cs" />
|
||||
<Compile Include="Tests\RPCTests.cs" />
|
||||
<Compile Include="Tests\SMB2SigningTests.cs" />
|
||||
<Compile Include="Utilities\LogEntry.cs" />
|
||||
<Compile Include="Utilities\PrefetchedStream.cs" />
|
||||
<Compile Include="Utilities\SocketUtils.cs" />
|
||||
|
|
52
SMBLibrary/Tests/SMB2SigningTests.cs
Normal file
52
SMBLibrary/Tests/SMB2SigningTests.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
|
||||
*
|
||||
* You can redistribute this program and/or modify it under the terms of
|
||||
* the GNU Lesser Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary
|
||||
{
|
||||
public class SMB2SigningTests
|
||||
{
|
||||
public static bool Test1()
|
||||
{
|
||||
byte[] exportedSessionKey = new byte[] { 0xD3, 0x83, 0x54, 0xCC, 0x37, 0x43, 0x39, 0xF0, 0x52, 0x4F, 0x78, 0x91, 0x46, 0x78, 0x99, 0x21 };
|
||||
|
||||
byte[] message = new byte[]{0xfe, 0x53, 0x4d, 0x42, 0x40, 0x00, 0x01, 0x00, 0x28, 0x01, 0x00, 0xc0, 0x0b, 0x00, 0x07, 0x00,
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xfe, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0xfb, 0xd2, 0x84, 0x34, 0x03, 0x24, 0xc6, 0x2f, 0xbe, 0xbb, 0x65, 0xdd, 0x10, 0x51, 0xf3, 0xae,
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
|
||||
|
||||
ByteWriter.WriteBytes(message, 48, new byte[16]);
|
||||
|
||||
byte[] signature = new HMACSHA256(exportedSessionKey).ComputeHash(message);
|
||||
signature = ByteReader.ReadBytes(signature, 0, 16);
|
||||
byte[] expected = new byte[] { 0xfb, 0xd2, 0x84, 0x34, 0x03, 0x24, 0xc6, 0x2f, 0xbe, 0xbb, 0x65, 0xdd, 0x10, 0x51, 0xf3, 0xae };
|
||||
return ByteUtils.AreByteArraysEqual(signature, expected);
|
||||
}
|
||||
|
||||
public static bool Test2()
|
||||
{
|
||||
byte[] exportedSessionKey = new byte[] { 0x04, 0xE7, 0x07, 0x57, 0x1F, 0x8E, 0x03, 0x53, 0xB7, 0x7A, 0x94, 0xC3, 0x65, 0x3B, 0x87, 0xB5 };
|
||||
|
||||
byte[] message = new byte[]{ 0xfe, 0x53, 0x4d, 0x42, 0x40, 0x00, 0x01, 0x00, 0x28, 0x01, 0x00, 0xc0, 0x0b, 0x00, 0x07, 0x00,
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xff, 0xfe, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
|
||||
0xa1, 0x64, 0xff, 0xe5, 0x3d, 0x68, 0x11, 0x98, 0x1f, 0x38, 0x67, 0x72, 0xe3, 0x87, 0xe0, 0x6f,
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
|
||||
|
||||
ByteWriter.WriteBytes(message, 48, new byte[16]);
|
||||
|
||||
byte[] signature = new HMACSHA256(exportedSessionKey).ComputeHash(message);
|
||||
signature = ByteReader.ReadBytes(signature, 0, 16);
|
||||
byte[] expected = new byte[] { 0xa1, 0x64, 0xff, 0xe5, 0x3d, 0x68, 0x11, 0x98, 0x1f, 0x38, 0x67, 0x72, 0xe3, 0x87, 0xe0, 0x6f };
|
||||
return ByteUtils.AreByteArraysEqual(signature, expected);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue