public static byte[] GetBytes(NetBIOSSessionService netBIOSSessionService, SMB2Header smb2Header, object smb2Command) { byte[] headerData = smb2Header.GetBytes(); byte[] commandData = new byte[0]; switch (smb2Header.Command) { case 0: { SMB2NegotiateResponse command = (SMB2NegotiateResponse)smb2Command; commandData = command.GetBytes(); } break; case 1: { SMB2SessionSetupResponse command = (SMB2SessionSetupResponse)smb2Command; commandData = command.GetBytes(); } break; } netBIOSSessionService.Length = (ushort)(commandData.Length + 64); byte[] netbiosData = netBIOSSessionService.GetBytes(); return(Utilities.BlockCopy(netbiosData, headerData, commandData)); }
public void Write(SMB2Helper Packet, NetworkStream Stream) { byte[] headerData = Packet.Header.GetBytes(); byte[] commandData = new byte[0]; switch (Packet.Header.Command) { case 0: { SMB2NegotiateResponse command = (SMB2NegotiateResponse)Packet.Payload; commandData = command.GetBytes(); } break; case 1: { SMB2SessionSetupResponse command = (SMB2SessionSetupResponse)Packet.Payload; commandData = command.GetBytes(); } break; } Packet.NetBIOS.Length = (ushort)(commandData.Length + 64); byte[] netbiosData = Packet.NetBIOS.GetBytes(); byte[] buffer = Utilities.BlockCopy(netbiosData, headerData, commandData); Stream.Write(buffer, 0, buffer.Length); Stream.Flush(); }