Untitled

 avatar
unknown
plain_text
3 years ago
2.8 kB
2
Indexable
bool __fastcall sub_1400016B0(__int64 a1)
{
  bool result; // al
  unsigned __int8 *v2; // rax
  signed __int64 v3; // rcx
  unsigned __int8 v4; // dl
  int v5; // eax
  signed __int64 v6; // [rsp+48h] [rbp-C0h]
  signed __int64 v7; // [rsp+50h] [rbp-B8h]
  DWORD pdwDataLen; // [rsp+68h] [rbp-A0h]
  HCRYPTKEY phKey; // [rsp+70h] [rbp-98h]
  HCRYPTHASH phHash; // [rsp+78h] [rbp-90h]
  HCRYPTPROV phProv; // [rsp+80h] [rbp-88h]
  int v12; // [rsp+88h] [rbp-80h]
  char pbData[80]; // [rsp+90h] [rbp-78h]
  _BYTE *v14; // [rsp+110h] [rbp+8h]

  v14 = (_BYTE *)a1;
  phProv = 0i64;
  phKey = 0i64;
  v12 = 0;
  qmemcpy(pbData, "passwd_checker_2022_key_len_only_0x10_you_must_care_about_it_homie", 0x44ui64);
  v6 = -1i64;
  do
    ++v6;
  while ( pbData[v6] );
  pdwDataLen = 0;
  if ( !CryptAcquireContextW(&phProv, 0i64, 0i64, 1u, 0) )
  {
    if ( GetLastError() != -2146893802 )
      return 0;
    if ( !CryptAcquireContextW(&phProv, 0i64, 0i64, 1u, 8u) )
      return 0;
  }
  if ( !CryptCreateHash(phProv, 0x8004u, 0i64, 0, &phHash) )// sha1
    return 0;
  if ( CryptHashData(phHash, (const BYTE *)pbData, v6, 0) )
  {
    if ( CryptDeriveKey(phProv, 0x6801u, phHash, 1u, &phKey) )
    {
      CryptDestroyHash(phHash);
      if ( CryptEncrypt(phKey, 0i64, 1, 0, 0i64, &pdwDataLen, 0) )
      {
        v7 = -1i64;
        do
          ++v7;
        while ( v14[v7] );
        pdwDataLen = v7 + 1;
        sub_140001140(&::pbData, 0x100ui64);
        sub_140001000(&::pbData, pdwDataLen, v14, (unsigned int)(v7 + 1));
        if ( CryptEncrypt(phKey, 0i64, 1, 0, &::pbData, &pdwDataLen, v7 + 1) )
        {
          if ( sub_140001610((DWORD *)&v12, &::pbData, v7 + 1) )
          {
            v2 = (unsigned __int8 *)&unk_140017A50;
            v3 = "E2J4z66WDHCgvxlWlILStr8epTuHJ5FFuTeK6LmBwVnN" - (char *)&unk_140017A50;
            while ( 1 )
            {
              v4 = *v2;
              if ( *v2 != v2[v3] )
                break;
              ++v2;
              if ( !v4 )
              {
                v5 = 0;
                goto LABEL_34;
              }
            }
            v5 = -(v4 < v2[v3]) | 1;
LABEL_34:
            result = v5 == 0;
          }
          else
          {
            if ( phKey )
              CryptDestroyKey(phKey);
            result = 0;
          }
        }
        else
        {
          if ( phKey )
            CryptDestroyKey(phKey);
          result = 0;
        }
      }
      else
      {
        if ( phKey )
          CryptDestroyKey(phKey);
        result = 0;
      }
    }
    else
    {
      CryptDestroyHash(phHash);
      result = 0;
    }
  }
  else
  {
    CryptDestroyHash(phHash);
    result = 0;
  }
  return result;
}