VirtualBox

Changeset 33228 in vbox for trunk/src/VBox/HostServices/auth


Ignore:
Timestamp:
Oct 19, 2010 1:12:31 PM (14 years ago)
Author:
vboxsync
Message:

VBoxAuthSimple now requires SHA-256 hashes, no more cleartext passwords

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/auth/simple/VBoxAuthSimple.cpp

    r33185 r33228  
    2424#include <iprt/cdefs.h>
    2525#include <iprt/uuid.h>
     26#include <iprt/sha.h>
    2627
    2728#include <VBox/VRDPAuth.h>
     
    8586        user = (char*)szUser;
    8687
    87     dprintf("VRDPAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword);
    88 
    89 #if 0
    90     /* this is crude stuff, but let's keep it there as a sample */
    91     if (getenv("VBOX_VRDP_AUTH_USER") && getenv("VBOX_VRDP_AUTH_PASSWORD"))
    92     {
    93 
    94         if (   !strcmp(getenv("VBOX_VRDP_AUTH_USER"), user)
    95             && !strcmp(getenv("VBOX_VRDP_AUTH_PASSWORD"), szPassword))
    96         {
    97             result = VRDPAuthAccessGranted;
    98         }
    99     }
    100 #endif
     88    dprintf("VBoxAuth: uuid: %s, user: %s, szPassword: %s\n", uuid, user, szPassword);
    10189
    10290    ComPtr<IVirtualBox> virtualBox;
     
    10694    if (SUCCEEDED(rc))
    10795    {
    108         Bstr key = BstrFmt("VRDPAuthSimple/users/%s", user);
     96        Bstr key = BstrFmt("VBoxAuthSimple/users/%s", user);
    10997        Bstr password;
    11098
     
    120108            virtualBox->GetExtraData(key.raw(), password.asOutParam());
    121109
    122         /* we compare the password or check for special NULL marker */
    123         if (   (!password.isEmpty() && (password == szPassword))
    124             || ((password == "[NULL]") && (!szPassword || (*szPassword == '\0'))))
     110        if (!password.isEmpty())
    125111        {
    126             result = VRDPAuthAccessGranted;
     112            /* calculate hash */
     113            uint8_t abDigest[RTSHA256_HASH_SIZE];
     114            RTSha256(szPassword, strlen(szPassword), abDigest);
     115            char pszDigest[RTSHA256_STRING_LEN + 1];
     116            RTSha256ToString(abDigest, pszDigest, sizeof(pszDigest));
     117                       
     118            if (password == pszDigest)
     119                result = VRDPAuthAccessGranted;
    127120        }
    128121    }
Note: See TracChangeset for help on using the changeset viewer.

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