Skip to content

Commit

Permalink
Added NegotiateResponseParsingTests
Browse files Browse the repository at this point in the history
  • Loading branch information
TalAloni committed Jul 30, 2024
1 parent 2044b09 commit dc52d4e
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions SMBLibrary.Tests/SMB2/NegotiateResponseParsingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Copyright (C) 2024 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 Microsoft.VisualStudio.TestTools.UnitTesting;
using SMBLibrary.SMB2;

namespace SMBLibrary.Tests.SMB2
{
[TestClass]
public class NegotiateResponseParsingTests
{
[TestMethod]
public void ParseNegotiateResponseWithNegotiateContextList()
{
byte[] negotiateResponseCommandBytes = new byte[]
{
0xfe, 0x53, 0x4d, 0x42, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x41, 0x00, 0x01, 0x00, 0x11, 0x03, 0x02, 0x00, 0xdc, 0x13, 0x82, 0xb7, 0x61, 0x5d, 0xd1, 0x49,
0x93, 0x4c, 0xea, 0x51, 0xa2, 0x06, 0x6f, 0x20, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x33, 0xee, 0xd9, 0xe6, 0xa4, 0xe2, 0xda, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00,
0x60, 0x82, 0x01, 0x3c, 0x06, 0x06, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x02, 0xa0, 0x82, 0x01, 0x30,
0x30, 0x82, 0x01, 0x2c, 0xa0, 0x1a, 0x30, 0x18, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82,
0x37, 0x02, 0x02, 0x1e, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x02, 0x0a,
0xa2, 0x82, 0x01, 0x0c, 0x04, 0x82, 0x01, 0x08, 0x4e, 0x45, 0x47, 0x4f, 0x45, 0x58, 0x54, 0x53,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
0x43, 0x41, 0x62, 0x87, 0xb8, 0xbb, 0x52, 0xa8, 0xc2, 0x47, 0x80, 0x3f, 0x56, 0xf8, 0x2d, 0x16,
0xcb, 0x62, 0x1f, 0x91, 0xe1, 0x46, 0xd3, 0x87, 0x1c, 0xec, 0xde, 0x67, 0x34, 0xf3, 0x8d, 0xb7,
0xbe, 0xaa, 0x12, 0x08, 0x7f, 0x7e, 0xa0, 0xcc, 0xc6, 0xcf, 0x30, 0x7d, 0x85, 0x1b, 0xea, 0x48,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x33, 0x53, 0x0d, 0xea, 0xf9, 0x0d, 0x4d,
0xb2, 0xec, 0x4a, 0xe3, 0x78, 0x6e, 0xc3, 0x08, 0x4e, 0x45, 0x47, 0x4f, 0x45, 0x58, 0x54, 0x53,
0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00,
0x43, 0x41, 0x62, 0x87, 0xb8, 0xbb, 0x52, 0xa8, 0xc2, 0x47, 0x80, 0x3f, 0x56, 0xf8, 0x2d, 0x16,
0x5c, 0x33, 0x53, 0x0d, 0xea, 0xf9, 0x0d, 0x4d, 0xb2, 0xec, 0x4a, 0xe3, 0x78, 0x6e, 0xc3, 0x08,
0x40, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x30, 0x56, 0xa0, 0x54, 0x30, 0x52, 0x30, 0x27,
0x80, 0x25, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x54,
0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x50, 0x75, 0x62,
0x6c, 0x69, 0x63, 0x20, 0x4b, 0x65, 0x79, 0x30, 0x27, 0x80, 0x25, 0x30, 0x23, 0x31, 0x21, 0x30,
0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x53, 0x69,
0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4b, 0x65, 0x79,
0x01, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00, 0xa6, 0x4b,
0x12, 0xc0, 0x02, 0xf7, 0xea, 0x63, 0xd9, 0x5a, 0xf1, 0x62, 0x95, 0x16, 0xf9, 0x73, 0xef, 0xa4,
0xe5, 0x74, 0x26, 0x7b, 0x55, 0xe9, 0x14, 0x7e, 0x96, 0xea, 0x2e, 0x56, 0x41, 0xfe, 0x00, 0x00,
0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00
};

NegotiateResponse negotiateResponse = new NegotiateResponse(negotiateResponseCommandBytes, 0);
Assert.AreEqual(SMB2Dialect.SMB311, negotiateResponse.DialectRevision);
Assert.AreEqual(2, negotiateResponse.NegotiateContextList.Count);
}
}
}

0 comments on commit dc52d4e

Please sign in to comment.