VirtualBox

Changeset 35581 in vbox


Ignore:
Timestamp:
Jan 17, 2011 12:21:28 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
69471
Message:

VBoxCredProv: Added support for unlocking workstations.

Location:
trunk/src/VBox/Additions/WINNT/VBoxCredProv
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/VBoxCredential.cpp

    r33595 r35581  
    696696    UNREFERENCED_PARAMETER(pcpsiOptionalStatusIcon);
    697697
    698     KERB_INTERACTIVE_LOGON kil;
    699     ZeroMemory(&kil, sizeof(kil));
     698    KERB_INTERACTIVE_UNLOCK_LOGON kiul;
     699    ZeroMemory(&kiul, sizeof(kiul));
     700
     701    /* Save a pointer to the interactive logon struct. */
     702    KERB_INTERACTIVE_LOGON* pkil = &kiul.Logon;
     703    AssertPtr(pkil);
    700704
    701705    HRESULT hr;
     
    707711        /* Is a domain name missing? Then use the name of the local computer. */
    708712        if (NULL == m_rgFieldStrings [SFI_DOMAINNAME])
    709             hr = UnicodeStringInitWithString(wszComputerName, &kil.LogonDomainName);
     713            hr = UnicodeStringInitWithString(wszComputerName, &pkil->LogonDomainName);
    710714        else
    711715            hr = UnicodeStringInitWithString(m_rgFieldStrings [SFI_DOMAINNAME],
    712                                              &kil.LogonDomainName);
     716                                             &pkil->LogonDomainName);
    713717
    714718        /* Fill in the username and password. */
    715719        if (SUCCEEDED(hr))
    716720        {
    717             hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_USERNAME], &kil.UserName);
     721            hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_USERNAME], &pkil->UserName);
    718722            if (SUCCEEDED(hr))
    719723            {
    720                 hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_PASSWORD], &kil.Password);
     724                hr = UnicodeStringInitWithString(m_rgFieldStrings[SFI_PASSWORD], &pkil->Password);
    721725                if (SUCCEEDED(hr))
    722726                {
    723                     /* Allocate copies of, and package, the strings in a binary blob. */
    724                     kil.MessageType = KerbInteractiveLogon;
    725                     hr = KerbInteractiveLogonPack(kil,
    726                                                   &pcpCredentialSerialization->rgbSerialization,
    727                                                   &pcpCredentialSerialization->cbSerialization);
     727                    /* Set credential type according to current usage scenario. */
     728                    AssertPtr(pkil);
     729                    switch (m_cpUS)
     730                    {
     731                        case CPUS_UNLOCK_WORKSTATION:
     732                            pkil->MessageType = KerbWorkstationUnlockLogon;
     733                            break;
     734
     735                        case CPUS_LOGON:
     736                            pkil->MessageType = KerbInteractiveLogon;
     737                            break;
     738
     739                        case CPUS_CREDUI:
     740                            pkil->MessageType = (KERB_LOGON_SUBMIT_TYPE)0; /* No message type required here. */
     741                            break;
     742
     743                        default:
     744                            hr = E_FAIL;
     745                            break;
     746                    }
     747
     748                    if (SUCCEEDED(hr))
     749                    {
     750                        /* Allocate copies of, and package, the strings in a binary blob. */
     751                        hr = KerbInteractiveUnlockLogonPack(kiul,
     752                                                            &pcpCredentialSerialization->rgbSerialization,
     753                                                            &pcpCredentialSerialization->cbSerialization);
     754                    }
    728755                    if (SUCCEEDED(hr))
    729756                    {
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/helpers.cpp

    r33540 r35581  
    170170
    171171//
    172 // WinLogon and LSA consume "packed" KERB_INTERACTIVE_LOGONs.  In these, the PWSTR members of each
     172// WinLogon and LSA consume "packed" KERB_INTERACTIVE_UNLOCK_LOGONs.  In these, the PWSTR members of each
    173173// UNICODE_STRING are not actually pointers but byte offsets into the overall buffer represented
    174 // by the packed KERB_INTERACTIVE_LOGON.  For example:
    175 //
    176 // kil.LogonDomainName.Length = 14                             -> Length is in bytes, not characters
    177 // kil.LogonDomainName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) -> LogonDomainName begins immediately
    178 //                                                                after the KERB_... struct in the buffer
    179 // kil.UserName.Length = 10
    180 // kil.UserName.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14   -> UNICODE_STRINGS are NOT null-terminated
    181 //
    182 // kil.Password.Length = 16
    183 // kil.Password.Buffer = sizeof(KERB_INTERACTIVE_LOGON) + 14 + 10
     174// by the packed KERB_INTERACTIVE_UNLOCK_LOGON.  For example:
     175//
     176// rkiulIn.Logon.LogonDomainName.Length = 14                                    -> Length is in bytes, not characters
     177// rkiulIn.Logon.LogonDomainName.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) -> LogonDomainName begins immediately
     178//                                                                              after the KERB_... struct in the buffer
     179// rkiulIn.Logon.UserName.Length = 10
     180// rkiulIn.Logon.UserName.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) + 14   -> UNICODE_STRINGS are NOT null-terminated
     181//
     182// rkiulIn.Logon.Password.Length = 16
     183// rkiulIn.Logon.Password.Buffer = sizeof(KERB_INTERACTIVE_UNLOCK_LOGON) + 14 + 10
    184184//
    185185// There's more information on this at:
    186186// http://msdn.microsoft.com/msdnmag/issues/05/06/SecurityBriefs/#void
    187187//
    188 
    189 HRESULT KerbInteractiveLogonPack(
    190                                  const KERB_INTERACTIVE_LOGON& rkil,
    191                                  BYTE** prgb,
    192                                  DWORD* pcb
    193                                  )
    194 {
    195     HRESULT hr;
     188HRESULT KerbInteractiveUnlockLogonPack(
     189                                       const KERB_INTERACTIVE_UNLOCK_LOGON& rkiulIn,
     190                                       BYTE** prgb,
     191                                       DWORD* pcb
     192                                       )
     193{
     194    HRESULT hr;
     195
     196    const KERB_INTERACTIVE_LOGON* pkilIn = &rkiulIn.Logon;
    196197
    197198    // alloc space for struct plus extra for the three strings
    198     DWORD cb = sizeof(rkil) +
    199         rkil.LogonDomainName.Length +
    200         rkil.UserName.Length +
    201         rkil.Password.Length;
    202 
    203     KERB_INTERACTIVE_LOGON* pkil = (KERB_INTERACTIVE_LOGON*)CoTaskMemAlloc(cb);
    204 
    205     if (pkil)
    206     {
    207         pkil->MessageType = rkil.MessageType;
     199    DWORD cb = sizeof(rkiulIn) +
     200        pkilIn->LogonDomainName.Length +
     201        pkilIn->UserName.Length +
     202        pkilIn->Password.Length;
     203
     204    KERB_INTERACTIVE_UNLOCK_LOGON* pkiulOut = (KERB_INTERACTIVE_UNLOCK_LOGON*)CoTaskMemAlloc(cb);
     205
     206    if (pkiulOut)
     207    {
     208        ZeroMemory(&pkiulOut->LogonId, sizeof(LUID));
    208209
    209210        //
    210211        // point pbBuffer at the beginning of the extra space
    211212        //
    212         BYTE* pbBuffer = (BYTE*)pkil + sizeof(KERB_INTERACTIVE_LOGON);
     213        BYTE* pbBuffer = (BYTE*)pkiulOut + sizeof(*pkiulOut);
     214
     215        //
     216        // set up the Logon structure within the KERB_INTERACTIVE_UNLOCK_LOGON
     217        //
     218        KERB_INTERACTIVE_LOGON* pkilOut = &pkiulOut->Logon;
     219
     220        pkilOut->MessageType = pkilIn->MessageType;
    213221
    214222        //
     
    217225        // advance buffer pointer over copied characters in extra space
    218226        //
    219         _UnicodeStringPackedUnicodeStringCopy(rkil.LogonDomainName, (PWSTR)pbBuffer, &pkil->LogonDomainName);
    220         pkil->LogonDomainName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);
    221         pbBuffer += pkil->LogonDomainName.Length;
    222 
    223         _UnicodeStringPackedUnicodeStringCopy(rkil.UserName, (PWSTR)pbBuffer, &pkil->UserName);
    224         pkil->UserName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);
    225         pbBuffer += pkil->UserName.Length;
    226 
    227         _UnicodeStringPackedUnicodeStringCopy(rkil.Password, (PWSTR)pbBuffer, &pkil->Password);
    228         pkil->Password.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkil);
    229 
    230         *prgb = (BYTE*)pkil;
     227        _UnicodeStringPackedUnicodeStringCopy(pkilIn->LogonDomainName, (PWSTR)pbBuffer, &pkilOut->LogonDomainName);
     228        pkilOut->LogonDomainName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut);
     229        pbBuffer += pkilOut->LogonDomainName.Length;
     230
     231        _UnicodeStringPackedUnicodeStringCopy(pkilIn->UserName, (PWSTR)pbBuffer, &pkilOut->UserName);
     232        pkilOut->UserName.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut);
     233        pbBuffer += pkilOut->UserName.Length;
     234
     235        _UnicodeStringPackedUnicodeStringCopy(pkilIn->Password, (PWSTR)pbBuffer, &pkilOut->Password);
     236        pkilOut->Password.Buffer = (PWSTR)(pbBuffer - (BYTE*)pkiulOut);
     237
     238        *prgb = (BYTE*)pkiulOut;
    231239        *pcb = cb;
    232240
     
    246254// memory space boundary is not going to work -- repack it if necessary!
    247255//
    248 //
    249 // Unpack a KERB_INTERACTIVE_UNLOCK_LOGON *in place*.  That is, reset the Buffers from being offsets to
    250 // being real pointers.  This means, of course, that passing the resultant struct across any sort of
    251 // memory space boundary is not going to work -- repack it if necessary!
    252 //
    253 void KerbInteractiveLogonUnpackInPlace(
     256void KerbInteractiveUnlockLogonUnpackInPlace(
    254257    __inout_bcount(cb) KERB_INTERACTIVE_UNLOCK_LOGON* pkiul
    255258    )
  • trunk/src/VBox/Additions/WINNT/VBoxCredProv/helpers.h

    r33540 r35581  
    4444
    4545//packages the credentials into the buffer that the system expects
    46 HRESULT KerbInteractiveLogonPack(
    47     const KERB_INTERACTIVE_LOGON& rkil,
     46HRESULT KerbInteractiveUnlockLogonPack(
     47    const KERB_INTERACTIVE_UNLOCK_LOGON& rkiulIn,
    4848    BYTE** prgb,
    4949    DWORD* pcb
     
    5151
    5252//unpacks the "packed" version of the creds in-place into the "unpacked" version
    53 void KerbInteractiveLogonUnpackInPlace(
     53void KerbInteractiveUnlockLogonUnpackInPlace(
    5454    KERB_INTERACTIVE_UNLOCK_LOGON* pkiul
    5555    );
    56 
    5756
    5857//get the authentication package that will be used for our logon attempt
     
    6059    ULONG * pulAuthPackage
    6160    );
     61
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette