Advertisement
Guest User

Untitled

a guest
May 1st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <windows.h>
  4. #include <wincrypt.h>
  5.  
  6.  
  7. #define SEED_CONSTANT 0xba0da71d
  8.  
  9. unsigned char secretKey[16]={ 0xa3,0x1e,0xf3,0x69,
  10. 0x07,0x62,0xd9,0x1f,
  11. 0x1e,0xe9,0x35,0x7d,
  12. 0x4f,0xd2,0x7d,0x48 };
  13.  
  14. int Decode(char output[], char passEntry[], DWORD entryLen)
  15. {
  16. int ret = -1;
  17. HANDLE hToken;
  18. char sid[512], name[512]="osrima",domain[512]="BINTER_AD", namex[512],domainx[512];
  19. LPWSTR name2= (LPWSTR)&namex, domain2= (LPWSTR)&domainx;
  20. DWORD SidSize = 0, i, j;
  21. DWORD cchName,cchDomain;
  22. SID_NAME_USE peUse;
  23. TOKEN_USER *SidUser = (TOKEN_USER*)&sid;
  24.  
  25. unsigned char staticKey[16];
  26. unsigned int seed;
  27. unsigned char *a,*b;
  28.  
  29. memcpy(staticKey,secretKey,sizeof(staticKey));
  30.  
  31. if((OpenProcessToken(GetCurrentProcess(),TOKEN_QUERY,&hToken)))
  32. {
  33. if((GetTokenInformation(hToken,TokenUser,SidUser,sizeof(sid),&SidSize)))
  34. {
  35. cchName = cchDomain = sizeof(name);
  36.  
  37. if((LookupAccountSid(NULL,SidUser->User.Sid,
  38. (LPWSTR)name2,&cchName,(LPWSTR)domain2,&cchDomain,&peUse)))
  39. {
  40. seed = SEED_CONSTANT;
  41.  
  42. // mix username with key
  43.  
  44. for(i = 0;i < cchName;i++)
  45. {
  46. ((unsigned int*)staticKey)[ i % 4 ] ^= name[i] * seed;
  47. seed *= 48271;
  48. }
  49.  
  50. // mix domain name with key
  51.  
  52. for(j = 0;j < cchDomain;i++,j++)
  53. {
  54. ((unsigned int*)staticKey)[ i % 4 ] ^= domain[j] * seed;
  55. seed *= 48271;
  56. }
  57.  
  58. // decode string
  59.  
  60. seed = (((unsigned int*)staticKey)[0] | 1);
  61. a = (unsigned char*)&passEntry[4];
  62. b = (unsigned char*)&passEntry[5];
  63.  
  64. for(i = 0;i < entryLen;i += 2)
  65. {
  66. passEntry[ i / 2 ] = (((a[i]-1)*16) | (b[i]-33)) - (seed & 0xff);
  67. seed *= 69621;
  68. }
  69.  
  70. // use protected storage to decrypt data
  71.  
  72. DATA_BLOB DataIn, DataEntropy, DataOut;
  73.  
  74. DataEntropy.cbData = sizeof(staticKey);
  75. DataEntropy.pbData = (BYTE*)&staticKey;
  76.  
  77. DataIn.cbData = (i/2);
  78. DataIn.pbData = (BYTE*)passEntry;
  79.  
  80. //passEntry[(i/2)+4]=0;
  81.  
  82. if(CryptUnprotectData(&DataIn,
  83. NULL,
  84. &DataEntropy,
  85. NULL,
  86. NULL,
  87. 1,
  88. &DataOut)) {
  89. memcpy(output,DataOut.pbData,DataOut.cbData);
  90. output[DataOut.cbData] = 0;
  91. LocalFree(DataOut.pbData);
  92. ret = 0;
  93. }
  94. }
  95. }
  96. CloseHandle(hToken);
  97. }
  98. return(ret);
  99. }
  100.  
  101. int main(void) {
  102. char pwd[1024],
  103. out[1024],
  104. *p;
  105.  
  106. printf(
  107. "paste your encrypted password here\n"
  108. "(\"pw\" from HKEY_CURRENT_USER\\Software\\Google\\Google Talk\\Accounts):\n");
  109. fgets(pwd, sizeof(pwd), stdin);
  110. for(p = pwd; *p && (*p != '\n') && (*p != '\r'); p++);
  111. *p = 0;
  112.  
  113. if(!Decode(out, pwd, strlen(pwd))) {
  114. printf("\nPASSWORD: %s\n", out);
  115. } else {
  116. printf("\nthe password cannot be decrypted on this account/machine\n");
  117. }
  118. printf("\npress return to quit\n");
  119. fgetc(stdin);
  120. return(0);
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement