private string GetNtlmsspListItem(byte[] type2Token, int id0) { int ri = 58; for (;;) { int id = Encdec.Dec_uint16le(type2Token, ri); int len = Encdec.Dec_uint16le(type2Token, ri + 2); ri += 4; if (id == 0 || (ri + len) > type2Token.Length) { break; } if (id == id0) { try { return Runtime.GetStringForBytes(type2Token, ri, len, SmbConstants.UniEncoding); } catch (UnsupportedEncodingException) { break; } } ri += len; } return null; }
public virtual int Dec_ndr_short() { Align(2); int val = Encdec.Dec_uint16le(Buf, Index); Advance(2); return(val); }
/// <exception cref="System.IO.IOException"></exception> protected internal override ServerMessageBlock PeekKey() { int n; do { if ((n = Readn(In, Sbuf, 0, 4)) < 4) { return(null); } }while (Sbuf[0] == 0x85); if ((n = Readn(In, Sbuf, 4, 32)) < 32) { return(null); } if (Log.Level >= 4) { Log.WriteLine("New data read: " + this); Hexdump.ToHexdump(Log, Sbuf, 4, 32); } for (;;) { if (Sbuf[0] == 0x00 && Sbuf[1] == 0x00 && Sbuf[4] == 0xFF && Sbuf[5] == 'S' && Sbuf[6] == 'M' && Sbuf[7] == 'B') { break; } for (int i = 0; i < 35; i++) { Sbuf[i] = Sbuf[i + 1]; } int b; if ((b = In.Read()) == -1) { return(null); } Sbuf[35] = unchecked ((byte)b); } Key.Mid = Encdec.Dec_uint16le(Sbuf, 34) & 0xFFFF; return(Key); }
/// <exception cref="System.IO.IOException"></exception> protected internal override void DoReceiveFragment(byte[] buf, bool isDirect) { int off; int flags; int length; if (buf.Length < MaxRecv) { throw new ArgumentException("buffer too small"); } if (IsStart && !isDirect) { // start of new frag, do trans off = In.Read(buf, 0, 1024); } else { off = In.ReadDirect(buf, 0, buf.Length); } if (buf[0] != 5 && buf[1] != 0) { throw new IOException("Unexpected DCERPC PDU header"); } flags = buf[3] & unchecked (0xFF); // next read is start of new frag IsStart = (flags & DcerpcConstants.DcerpcLastFrag) == DcerpcConstants.DcerpcLastFrag; length = Encdec.Dec_uint16le(buf, 8); if (length > MaxRecv) { throw new IOException("Unexpected fragment length: " + length); } while (off < length) { off += In.ReadDirect(buf, off, length - off); } }