void ntlm_output_restriction_encoding(NTLM_CONTEXT* context) { PStream s; AV_PAIR* restrictions = &context->av_pairs->Restrictions; BYTE machineID[32] = "\x3A\x15\x8E\xA6\x75\x82\xD8\xF7\x3E\x06\xFA\x7A\xB4\xDF\xFD\x43" "\x84\x6C\x02\x3A\xFD\x5A\x94\xFE\xCF\x97\x0F\x3D\x19\x2C\x38\x20"; restrictions->value = malloc(48); restrictions->length = 48; s = PStreamAllocAttach(restrictions->value, restrictions->length); StreamWrite_UINT32(s, 48); /* Size */ StreamZero(s, 4); /* Z4 (set to zero) */ /* IntegrityLevel (bit 31 set to 1) */ StreamWrite_UINT8(s, 1); StreamZero(s, 3); StreamWrite_UINT32(s, 0x00002000); /* SubjectIntegrityLevel */ StreamWrite(s, machineID, 32); /* MachineID */ PStreamFreeDetach(s); }
void ntlm_write_ntlm_v2_client_challenge(PStream s, NTLMv2_CLIENT_CHALLENGE* challenge) { ULONG length; StreamWrite_UINT8(s, challenge->RespType); StreamWrite_UINT8(s, challenge->HiRespType); StreamWrite_UINT16(s, challenge->Reserved1); StreamWrite_UINT32(s, challenge->Reserved2); StreamWrite(s, challenge->Timestamp, 8); StreamWrite(s, challenge->ClientChallenge, 8); StreamWrite_UINT32(s, challenge->Reserved3); length = ntlm_av_pair_list_length(challenge->AvPairs); StreamWrite(s, challenge->AvPairs, length); }
void ntlm_output_av_pairs(NTLM_CONTEXT* context, PSecBuffer buffer) { PStream s; AV_PAIRS* av_pairs = context->av_pairs; s = PStreamAllocAttach(buffer->pvBuffer, buffer->cbBuffer); if (av_pairs->NbDomainName.length > 0) { StreamWrite_UINT16(s, MsvAvNbDomainName); /* AvId */ StreamWrite_UINT16(s, av_pairs->NbDomainName.length); /* AvLen */ StreamWrite(s, av_pairs->NbDomainName.value, av_pairs->NbDomainName.length); /* Value */ } if (av_pairs->NbComputerName.length > 0) { StreamWrite_UINT16(s, MsvAvNbComputerName); /* AvId */ StreamWrite_UINT16(s, av_pairs->NbComputerName.length); /* AvLen */ StreamWrite(s, av_pairs->NbComputerName.value, av_pairs->NbComputerName.length); /* Value */ } if (av_pairs->DnsDomainName.length > 0) { StreamWrite_UINT16(s, MsvAvDnsDomainName); /* AvId */ StreamWrite_UINT16(s, av_pairs->DnsDomainName.length); /* AvLen */ StreamWrite(s, av_pairs->DnsDomainName.value, av_pairs->DnsDomainName.length); /* Value */ } if (av_pairs->DnsComputerName.length > 0) { StreamWrite_UINT16(s, MsvAvDnsComputerName); /* AvId */ StreamWrite_UINT16(s, av_pairs->DnsComputerName.length); /* AvLen */ StreamWrite(s, av_pairs->DnsComputerName.value, av_pairs->DnsComputerName.length); /* Value */ } if (av_pairs->DnsTreeName.length > 0) { StreamWrite_UINT16(s, MsvAvDnsTreeName); /* AvId */ StreamWrite_UINT16(s, av_pairs->DnsTreeName.length); /* AvLen */ StreamWrite(s, av_pairs->DnsTreeName.value, av_pairs->DnsTreeName.length); /* Value */ } if (av_pairs->Timestamp.length > 0) { StreamWrite_UINT16(s, MsvAvTimestamp); /* AvId */ StreamWrite_UINT16(s, av_pairs->Timestamp.length); /* AvLen */ StreamWrite(s, av_pairs->Timestamp.value, av_pairs->Timestamp.length); /* Value */ } if (av_pairs->Flags > 0) { StreamWrite_UINT16(s, MsvAvFlags); /* AvId */ StreamWrite_UINT16(s, 4); /* AvLen */ StreamWrite_UINT32(s, av_pairs->Flags); /* Value */ } if (av_pairs->Restrictions.length > 0) { StreamWrite_UINT16(s, MsvAvRestrictions); /* AvId */ StreamWrite_UINT16(s, av_pairs->Restrictions.length); /* AvLen */ StreamWrite(s, av_pairs->Restrictions.value, av_pairs->Restrictions.length); /* Value */ } if (av_pairs->ChannelBindings.length > 0) { StreamWrite_UINT16(s, MsvChannelBindings); /* AvId */ StreamWrite_UINT16(s, av_pairs->ChannelBindings.length); /* AvLen */ StreamWrite(s, av_pairs->ChannelBindings.value, av_pairs->ChannelBindings.length); /* Value */ } if (av_pairs->TargetName.length > 0) { StreamWrite_UINT16(s, MsvAvTargetName); /* AvId */ StreamWrite_UINT16(s, av_pairs->TargetName.length); /* AvLen */ StreamWrite(s, av_pairs->TargetName.value, av_pairs->TargetName.length); /* Value */ } /* This indicates the end of the AV_PAIR array */ StreamWrite_UINT16(s, MsvAvEOL); /* AvId */ StreamWrite_UINT16(s, 0); /* AvLen */ if (context->ntlm_v2) { StreamZero(s, 8); } free(s); }