Advertisement
JuanDeLemos

wannacry DLL ops

May 14th, 2017
24,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *** DLL operations ***
  2.  
  3. 1] Checks to see if task already running by attempting to open mutex with name MsWinZonesCacheCounterMutexA
  4. If already exists, app exits
  5.  
  6. 2] Obtains name of current directory.
  7.  
  8. 3] Reads 780 bytes of information from c.wnry which it expects in current directory. This has
  9. bitcoin and TOR info.
  10.  
  11. 4] Checks if running as LocalSystem. Sets a flag used later when running @wanadecryptor@.exe
  12.  
  13. 5] Resolves api from advapi32.dll
  14.  
  15. CryptAcquireContextA
  16. CryptImportKey
  17. CryptDestroyKey
  18. CryptEncrypt
  19. CryptDecrypt
  20. CryptGenKey
  21.  
  22. 6] Resolves api from kernel32.dll
  23.  
  24. CreateFileW
  25. WriteFile
  26. ReadFile
  27. MoveFileW
  28. MoveFileExW
  29. DeleteFileW
  30. CloseHandle
  31.  
  32. 7] Initializes names of files
  33.  
  34. 00000000.res - C2 communications
  35. 00000000.pky - Public key used by the ransomware to encrypt the generated AES keys that are used to encrypt the user’s files
  36. 00000000.eky - Encryption key for the t.wnry file which stores the actual file encryption component used by the ransomware.
  37. It is encrypted using the public key that belongs to a private key embedded inside the ransomware.
  38.  
  39.  
  40. 8] creates mutex with name MsWinZonesCacheCounterMutexA and sets the security
  41. ACL to allow EVERYONE full access
  42.  
  43.  
  44. 9] tries to open 00000000.dky. if available, will import key into Crypto API object.
  45. presumably this would be decryption key from the authors of ransomware..
  46.  
  47.  
  48. 10] if cannot open *.dky file, will generate new RSA key pair of 2048-bits.
  49. Public key is exported as blob and saved to 00000000.pky
  50. Private key is exported as blob and encrypted with ransomware public key before being saved to 00000000.eky
  51.  
  52. The RSA public key used to encrypt the users RSA key pair is embedded inside the DLL.
  53.  
  54. unsigned char wc_key1[] =
  55. {
  56. 0x06, 0x02, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0x52, 0x53,
  57. 0x41, 0x31, 0x00, 0x08, 0x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, 0x17, 0xBD, 0xAF, 0x28, 0x00,
  75. 0x96, 0x20, 0x46, 0xA7, 0x2D, 0x62, 0x03, 0x0C, 0xD7, 0xD0,
  76. 0x75, 0xA0, 0x0B, 0x07, 0xEA, 0xD4, 0x1F, 0xCA, 0xE8, 0xD9,
  77. 0x4E, 0xDB, 0x38, 0xF2, 0x26, 0x75, 0xCB, 0x12, 0xA6, 0x88,
  78. 0x70, 0x9B, 0xE1, 0xEA, 0x32, 0xDC, 0xF8, 0x71, 0x72, 0x50,
  79. 0x41, 0xE6, 0x17, 0x81, 0x68, 0x27, 0x42, 0x8E, 0xDF, 0xE5,
  80. 0xDE, 0xA1, 0x72, 0xD9, 0x3B, 0xFB, 0xE5, 0x9D, 0x30, 0x11,
  81. 0x69, 0x92, 0xCD, 0x60, 0x2B, 0xE2, 0xD5, 0x46, 0x3C, 0x28,
  82. 0xCF, 0x9D, 0x30, 0x4A, 0xF7, 0xAD, 0xB9, 0xFB, 0x0F, 0x91,
  83. 0xFE, 0x2E, 0xBE, 0x18, 0xF1, 0xCE
  84. };
  85.  
  86. The AES-128 key generated for each file is derived from CryptGenRandom which
  87. is cryptographically secure and is not known to have any weakness.
  88.  
  89. The AES keys are encrypted using the users public key in *.pky.
  90. In order to decrypt, we need the users private key which is
  91. encrypted using a public key owned by the ransomware authors.
  92.  
  93. Presumably what authors do is decrypt the users private key in *.eky file
  94. using their private key and then send the user a *.dky file
  95. to decrypt files.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement