Advertisement
Guest User

Untitled

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