Guest User

Untitled

a guest
Jan 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <#
  2. Version: 1.0
  3. Author: Oliver Kieselbach
  4. Script: Get-DecryptInfoFromSideCarLogFiles.ps1
  5.  
  6. Description:
  7. run as Admin on a device where you are AADJ and Intune enrolled to successfully decrypt
  8. the log message containing decryption info for Intune Win32 apps (.intunewin)
  9.  
  10. Release notes:
  11. Version 1.0: Original published version.
  12.  
  13. The script is provided "AS IS" with no warranties.
  14. #>
  15.  
  16. function Decrypt($base64string)
  17. {
  18. [System.Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
  19.  
  20. $content = [Convert]::FromBase64String($base64string)
  21. $envelopedCms = New-Object Security.Cryptography.Pkcs.EnvelopedCms
  22. $certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
  23. $envelopedCms.Decode($content)
  24. $envelopedCms.Decrypt($certCollection)
  25.  
  26. $utf8content = [text.encoding]::UTF8.getstring($envelopedCms.ContentInfo.Content)
  27.  
  28. return $utf8content
  29. }
  30.  
  31. $agentLogPath = Join-Path $env:ProgramData "Microsoft\IntuneManagementExtension\Logs\IntuneManagementExtension.log"
  32. $stringToSearch = "<![LOG[Get content info from service,ret = {"
  33.  
  34. Get-Content $agentLogPath | ForEach-Object {
  35. if ($nextLine) {
  36. $reply = "{$($_.ToString().TrimStart())}" | ConvertFrom-Json
  37.  
  38. $responsePayload = ($reply.ResponsePayload | ConvertFrom-Json)
  39. $contentInfo = ($responsePayload.ContentInfo | ConvertFrom-Json)
  40. $decryptInfo = Decrypt(([xml]$responsePayload.DecryptInfo).EncryptedMessage.EncryptedContent) | ConvertFrom-Json
  41.  
  42. "URL: $($contentInfo.UploadLocation)"
  43. "Key: $($decryptInfo.EncryptionKey)"
  44. "IV: $($decryptInfo.IV)"
  45.  
  46. # optional call:
  47. # .\IntuneWinAppUtilDecoder.exe `"$($contentInfo.UploadLocation)`" /key:$($decryptInfo.EncryptionKey) /iv:$($decryptInfo.IV)
  48.  
  49. $nextLine = $false
  50. }
  51. if ($_.ToString().StartsWith($stringToSearch) -eq $true) {
  52. $nextLine = $true
  53. }
  54. }
Add Comment
Please, Sign In to add comment