Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 11.13 KB | None | 0 0
  1. __int64 __fastcall AccountManager_GetDefaultAccountOldCredentials_sub_4B3ED0(__int64 a1, char a2, __int64 *a3, __int64 a4, __int64 ARG_a5, _DWORD *ARG_a6, __int64 ARG_a7, _DWORD *ARG_a8, _QWORD *ARG_a9)
  2. {
  3.   const char *v12; // rax
  4.   __int64 v13; // rax
  5.   int v14; // eax
  6.   unsigned int v15; // ebx
  7.   __int64 v16; // rax
  8.   __int64 **v17; // rax
  9.   __int64 v18; // rax
  10.   __int64 (__fastcall *v19)(__int64, unsigned __int64 *); // rcx
  11.   __int64 v20; // rax
  12.   bool v21; // al
  13.   __int64 v22; // rax
  14.   __int64 **v23; // rbx
  15.   __int64 v24; // r13
  16.   __int64 v25; // r14
  17.   int v26; // ecx
  18.   unsigned int v27; // eax
  19.   int v28; // ecx
  20.   bool v29; // al
  21.   int v30; // ecx
  22.   char *v31; // rbx
  23.   _BYTE *v32; // r15
  24.   char *v33; // rbx
  25.   __int64 v34; // r15
  26.   _BYTE *v35; // rax
  27.   __int64 v36; // rax
  28.   void *v37; // r14
  29.   int v38; // er15
  30.   __int64 v39; // rbx
  31.   unsigned __int64 v40; // rax
  32.   __int64 _LEN_v41; // r14
  33.   __int64 _DATA_v43; // r13
  34.   char *v44; // rsi
  35.   unsigned int CRC32_v45; // ecx
  36.   _BYTE *v46; // rax
  37.   __int64 v47; // rsi
  38.   int v48; // edi
  39.   spl *v49; // rax
  40.   int v50; // eax
  41.   spl *v51; // rax
  42.   unsigned __int64 a2a[2]; // [rsp+0h] [rbp-1E0h]
  43.   char *v53; // [rsp+10h] [rbp-1D0h]
  44.   __int64 (__fastcall **v54)(); // [rsp+110h] [rbp-D0h]
  45.   __int64 v55; // [rsp+118h] [rbp-C8h]
  46.   char v56; // [rsp+120h] [rbp-C0h]
  47.   __int64 *v58; // [rsp+148h] [rbp-98h]
  48.   __int64 a1a; // [rsp+150h] [rbp-90h]
  49.   MEMORY MEM; // [rsp+160h] [rbp-80h]
  50.   __int64 v62; // [rsp+170h] [rbp-70h]
  51.   __int64 Remain_v63; // [rsp+178h] [rbp-68h]
  52.   __int64 CRC32_v64; // [rsp+180h] [rbp-60h]
  53.   unsigned int LEN_SUB_v65; // [rsp+18Ch] [rbp-54h]
  54.   int attrc_v67; // [rsp+190h] [rbp-50h]
  55.   unsigned int v67; // [rsp+198h] [rbp-48h]
  56.   void *v68; // [rsp+1A0h] [rbp-40h]
  57.  
  58.   v12 = (const char *)std_string_c_sub_2BBBA0(a3);
  59.   v13 = sub_4B0FE0((spl *)a1, v12);
  60.   if ( !*(_BYTE *)(v13 + 4) )
  61.   {
  62.     v62 = a1;
  63.     v58 = a3;
  64.     MEM.Ptr = 0LL;
  65.     MEM.Size = 0;
  66.     if ( a2 )
  67.     {
  68.       _mm_store_si128((__m128i *)&attrc_v67, (__m128i)0LL);
  69.       v68 = 0LL;
  70.       v16 = GetConfig_sub_4C57D0(*(_QWORD *)(v62 + 32));
  71.       v17 = (__int64 **)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v16 + 80LL))(v16);
  72.       sub_2BB240((__int64 **)&CRC32_v64, v17);
  73.       if ( *(_DWORD *)qword_93C108 <= 70 )
  74.       {
  75.         a2a[1] = (unsigned __int64)"GetOldCredentials";
  76.         a2a[0] = 34818LL;
  77.         v53 = (char *)&attrc_v67 + 1;
  78.         auf::LogComponent::log(qword_93C108, 81990LL, 2857999256LL, "%s: missing coexistence creds, err: %s\n", a2a);
  79.       }
  80.       sub_2BBB20(&CRC32_v64);
  81.       if ( attrc_v67 & 1 )
  82.         operator delete(v68);
  83.       goto LABEL_45;
  84.     }
  85.     v18 = sub_2B9FA0(*(_QWORD *)(v62 + 32));
  86.     v19 = *(__int64 (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v18 + 40LL);
  87.     _mm_store_si128((__m128i *)a2a, (__m128i)0LL);
  88.     v53 = 0LL;
  89.     v20 = v19(v18, a2a);
  90.     (*(void (__fastcall **)(__int64 *, __int64, const char *))(*(_QWORD *)v20 + 16LL))(
  91.       &CRC32_v64,
  92.       v20,
  93.       "*Lib/Account/Default");
  94.     if ( a2a[0] & 1 )
  95.       operator delete(v53);
  96.     std_string_ctor_sub_2BB200(&Remain_v63);
  97.     v21 = std_string_c_sub_2BBD60((unsigned __int8 **)&CRC32_v64);
  98.     a1a = a4;
  99.     if ( v21 )
  100.     {
  101.       _mm_store_si128((__m128i *)a2a, (__m128i)0LL);
  102.       v22 = sub_2B9FA0(*(_QWORD *)(v62 + 32));
  103.       (*(void (__fastcall **)(__int64, unsigned __int64 *))(*(_QWORD *)v22 + 64LL))(v22, a2a);
  104.       if ( HIDWORD(a2a[1]) )
  105.       {
  106.         v23 = (__int64 **)a2a[0];
  107.         v24 = 8LL * HIDWORD(a2a[1]);
  108.         v25 = v62;
  109.         while ( 1 )
  110.         {
  111.           Read_Credentials3_sub_4B4810(&attrc_v67, *(_QWORD *)(v25 + 32), (__int64)v23);
  112.           std_string_sub_2BB330((__int64 **)&Remain_v63, (__int64 **)&attrc_v67);
  113.           std_string_sub_2BBB60((__int64)&attrc_v67);
  114.           if ( !std_string_c_sub_2BBD60((unsigned __int8 **)&Remain_v63) )
  115.             break;
  116.           ++v23;
  117.           v24 -= 8LL;
  118.           if ( !v24 )
  119.             goto LABEL_22;
  120.         }
  121.         std_string_sub_2BB330((__int64 **)&CRC32_v64, v23);
  122. LABEL_22:
  123.         v26 = HIDWORD(a2a[1]);
  124.         v27 = --HIDWORD(a2a[1]);
  125.         if ( v26 )
  126.         {
  127.           do
  128.           {
  129.             std_string_sub_2BBB60(a2a[0] + 8LL * v27);
  130.             v28 = HIDWORD(a2a[1]);
  131.             v27 = --HIDWORD(a2a[1]);
  132.           }
  133.           while ( v28 );
  134.         }
  135.       }
  136.       else
  137.       {
  138.         HIDWORD(a2a[1]) = -1;
  139.       }
  140.       MEMMORY_SetSize_sub_2B99E0((__int64)a2a, 0);
  141.       ++HIDWORD(a2a[1]);
  142.       MEMORY_dtor_sub_2B9CA0((void **)a2a);
  143.     }
  144.     else
  145.     {
  146.       Read_Credentials3_sub_4B4810(a2a, *(_QWORD *)(v62 + 32), (__int64)&CRC32_v64);
  147.       std_string_sub_2BB330((__int64 **)&Remain_v63, (__int64 **)a2a);
  148.       std_string_sub_2BBB60((__int64)a2a);
  149.     }
  150.     v29 = std_string_c_sub_2BBD60((unsigned __int8 **)&Remain_v63);
  151.     v30 = *(_DWORD *)qword_93C108;
  152.     if ( v29 )
  153.     {
  154.       if ( v30 <= 60 )
  155.       {
  156.         a2a[0] = 2049LL;
  157.         a2a[1] = (unsigned __int64)"GetOldCredentials";
  158.         auf::LogComponent::log(
  159.           qword_93C108,
  160.           (char *)&loc_1333A + 2,
  161.           719622844LL,
  162.           "%s: did not find credentials for default user\n",
  163.           a2a);
  164.       }
  165.       std_string_sub_2BBB60((__int64)&Remain_v63);
  166.       std_string_sub_2BBB60((__int64)&CRC32_v64);
  167.       v15 = 0;
  168.       goto LABEL_46;
  169.     }
  170.     if ( v30 <= 50 )
  171.     {
  172.       a2a[0] = 2049LL;
  173.       a2a[1] = (unsigned __int64)"GetOldCredentials";
  174.       auf::LogComponent::log(qword_93C108, 79410LL, 1053985249LL, "%s: found credentials for default user\n", a2a);
  175.     }
  176.     v31 = (char *)std_string_c_sub_2BBBA0(&Remain_v63);
  177.     v32 = memchr("0123456789ABCDEF", *v31, 0x11uLL);
  178.     if ( v32 )
  179.     {
  180.       v33 = v31 + 2;
  181.       do
  182.       {
  183.         v34 = v32 - "0123456789ABCDEF";
  184.         if ( v34 > 15 )
  185.           break;
  186.         v35 = memchr("0123456789ABCDEF", *(v33 - 1), 0x11uLL);
  187.         if ( !v35 )
  188.           break;
  189.         v36 = v35 - "0123456789ABCDEF";
  190.         if ( v36 > 15 )
  191.           break;
  192.         LOBYTE(a2a[0]) = v36 + 16 * v34;
  193.         MEMORY_sub_C5F10(&MEM, (unsigned __int64)a2a, 1);
  194.         v32 = memchr("0123456789ABCDEF", *v33, 0x11uLL);
  195.         v33 += 2;
  196.       }
  197.       while ( v32 );
  198.     }
  199.     *(_QWORD *)&attrc_v67 = 0LL;
  200.     v67 = 0;
  201.     if ( loadCryptedToken("skype") )
  202.     {
  203.       v37 = (void *)operator new[](0x20uLL);
  204.       _mm_store_si128(
  205.         (__m128i *)a2a,
  206.         _mm_unpacklo_epi64((__m128i)(unsigned __int64)off_91F3E0, (__m128i)(unsigned __int64)&off_91F420));
  207.       v54 = off_91F438;
  208.       seq_ctor_sub_29B730((unsigned __int64)&a2a[1]);
  209.       v38 = 0;
  210.       seq_init_sub_29B450((__int64)&v56, 0LL);
  211.       v55 = 0LL;
  212.       encryptor_sub_29B620((__int64)v37, 0x20u, *(__int64 *)&attrc_v67, v67);
  213.       __bzero(*(_QWORD *)&attrc_v67, v67);
  214.       MEMMORY_SetSize_sub_2B99E0((__int64)&attrc_v67, 0);
  215.       ((void (__fastcall *)(__int64 (__fastcall ***)(), void *))v54[2])(&v54, v37);
  216.       v55 = 0LL;
  217.       LEN_SUB_v65 = MEM.Size;
  218.       if ( MEM.Size > 1u )
  219.       {
  220.         v39 = MEM.Ptr;
  221.         v40 = encryptor_sub_29B4A0((__int64)&v56, (unsigned int *)&v56, (unsigned __int8 *)MEM.Ptr, (int *)&LEN_SUB_v65);
  222.         encryptor_aes_sub_29C240((__int64)&a2a[1], v39, LEN_SUB_v65, v40, 0, HIDWORD(v55));
  223.         v38 = LEN_SUB_v65;
  224.       }
  225.       else
  226.       {
  227.         LEN_SUB_v65 = 0;
  228.       }
  229.       MEMORY_Resize_sub_C5ED0(&MEM, v38);
  230.       operator delete[](v37);
  231.     }
  232.     std_string_sub_2BB330((__int64 **)v58, (__int64 **)&CRC32_v64);
  233.     MEMORY_dtor_sub_2B9CB0((__int64)&attrc_v67);
  234.     std_string_sub_2BBB60((__int64)&Remain_v63);
  235.     std_string_sub_2BBB60((__int64)&CRC32_v64);
  236.     _LEN_v41 = (unsigned int)MEM.Size;
  237.     if ( (unsigned int)MEM.Size < 145uLL )
  238.     {
  239.       if ( *(_DWORD *)qword_93C108 <= 70 )
  240.       {
  241.         a2a[0] = 2049LL;
  242.         a2a[1] = (unsigned __int64)"GetOldCredentials";
  243.         auf::LogComponent::log(
  244.           qword_93C108,
  245.           84806LL,
  246.           1888273893LL,
  247.           "%s: not enough data to retrieve password hash\n",
  248.           a2a);
  249.         v15 = 0;
  250. LABEL_46:
  251.         MEMORY_Resize_sub_C5ED0(&MEM, 0);
  252.         return v15;
  253.       }
  254. LABEL_45:
  255.       v15 = 0;
  256.       goto LABEL_46;
  257.     }
  258.     _DATA_v43 = MEM.Ptr;
  259.     rt::BASE64::encode((__int64)a2a, MEM.Ptr, 16LL);
  260.     v44 = (char *)a2a + 1;
  261.     if ( a2a[0] & 1 )
  262.       v44 = v53;
  263.     std_string_sub_2BBBD0(a1a, v44);
  264.     LODWORD(CRC32_v64) = -1;
  265.     spl::memcpy_s(&attrc_v67, 0x10uLL, (const void *)_DATA_v43, 0x10uLL);
  266.     CRC32_sub_C44F0(&CRC32_v64, (unsigned __int8 *)&attrc_v67, 16);
  267.     CRC32_v45 = CRC32_v64;
  268.     v46 = (_BYTE *)(_DATA_v43 + 16);
  269.     v47 = (_LEN_v41 & 1) + 16 - _LEN_v41;
  270.     do
  271.     {
  272.       v48 = 69069 * CRC32_v45 + 17009;
  273.       *v46 ^= HIBYTE(v48);
  274.       CRC32_v45 = 69069 * v48 + 17009;
  275.       v15 = (CRC32_v45 >> 24) ^ (unsigned __int8)v46[1];
  276.       v46[1] ^= HIBYTE(CRC32_v45);
  277.       v46 += 2;
  278.       v47 += 2LL;
  279.     }
  280.     while ( v47 );
  281.     if ( _LEN_v41 & 1 )
  282.       *v46 ^= (0x10DCD * CRC32_v45 + 0x4271) >> 24;
  283.     if ( _byteswap_ulong(*(_DWORD *)(_DATA_v43 + 16)) == 0x140 )
  284.     {
  285.       LOBYTE(v15) = 1;
  286.       if ( (unsigned int)_LEN_v41 >= 0x154 )
  287.       {
  288.         CRC32_v64 = _DATA_v43 + 340;
  289.         LEN_SUB_v65 = _LEN_v41 - 340;
  290.         _mm_store_si128((__m128i *)&attrc_v67, (__m128i)0LL);
  291.         LODWORD(Remain_v63) = 307200;
  292.         if ( AttributeContainer_Decode_sub_29A520(
  293.                (__int64)&attrc_v67,
  294.                &CRC32_v64,
  295.                (int *)&LEN_SUB_v65,
  296.                0LL,
  297.                8u,
  298.                &Remain_v63) )
  299.         {
  300.           v49 = AttributeContainer_GetAttrStr_sub_299EF0((__int64)&attrc_v67, 2, "");
  301.           std_string_sub_2BBBD0(ARG_a5, (const char *)v49);
  302.           v50 = AttributeContainer_GetAttr_sub_299D30((__int64)&attrc_v67, 12, 0);
  303.           *ARG_a6 = v50;
  304.           v51 = AttributeContainer_GetAttrStr_sub_299EF0((__int64)&attrc_v67, 6, 0LL);
  305.           std_string_sub_2BBBD0(ARG_a7, (const char *)v51);
  306.           *ARG_a8 = AttributeContainer_GetAttr_sub_299D30((__int64)&attrc_v67, 7, 0);
  307.           *ARG_a9 = AttributeContainer_GetAttr_sub_299D80(&attrc_v67, 3, 0LL, 0);
  308.         }
  309.  
  310.         AttributeContainer_dtor_sub_29A000((LIST *)&attrc_v67);
  311.         if ( !(a2a[0] & 1) )
  312.           goto LABEL_46;
  313.         goto LABEL_65;
  314.       }
  315.     }
  316.     else
  317.     {
  318.       if ( *(_DWORD *)qword_93C108 <= 70 )
  319.       {
  320.         *(_QWORD *)&attrc_v67 = 2049LL;
  321.         *(_QWORD *)&v67 = "GetOldCredentials";
  322.         auf::LogComponent::log(qword_93C108, 87622LL, 4258734260LL, "%s: credentials decryption failed\n", &attrc_v67);
  323.         v15 = 0;
  324.         if ( !(a2a[0] & 1) )
  325.           goto LABEL_46;
  326.         goto LABEL_65;
  327.       }
  328.       v15 = 0;
  329.     }
  330.     if ( !(a2a[0] & 1) )
  331.       goto LABEL_46;
  332. LABEL_65:
  333.     operator delete(v53);
  334.     goto LABEL_46;
  335.   }
  336.   if ( *(_DWORD *)qword_93C108 <= 60 )
  337.   {
  338.     v14 = *(_DWORD *)v13;
  339.     a2a[0] = 257LL;
  340.     LODWORD(a2a[1]) = v14;
  341.     auf::LogComponent::log(
  342.       qword_93C108,
  343.       &loc_1193C,
  344.       83748489LL,
  345.       "AccountManager::GetDefaultAccountOldCredentials: account object already created: %u\n",
  346.       a2a);
  347.   }
  348.   return 0;
  349. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement