Commit 8d8ab91d authored by Gabriel Moreau's avatar Gabriel Moreau
Browse files

Clean code

parent 1ed532d1
......@@ -69,29 +69,40 @@ Function TweakViewTargetRelease { # RESINFO
# Suppress Kaspersky Endpoint software
# Uninstall
Function TweakUninstallKasperskyEndpoint { # RESINFO
Function _String2Hex {
Param (
[Parameter(Mandatory = $true)] [string]$Text
)
$CharArray=$Text.ToCharArray()
ForEach ($Char in $CharArray) {
$TextHex = $TextHex + " " + [System.String]::Format("{0:x2}", [System.Convert]::ToUInt32($Char))
}
Return $TextHex
}
Write-Output "Suppress software Kaspersky Endpoint protection..."
$Kes = Get-WmiObject win32_product | Where { $_.Name -like "*Kaspersky Endpoint Security*" }
If ($Kes.IdentifyingNumber) {
Write-Host "Uninstalling Kaspersky version $($Kes.Version) with GUID => $($Kes.IdentifyingNumber)"
# Remove Kaspersky Endpoint
$KesEndpoint = Get-WmiObject win32_product | Where { $_.Name -like "*Kaspersky Endpoint Security*" }
If ($KesEndpoint.IdentifyingNumber) {
Write-Host "Uninstalling Kaspersky version $($KesEndpoint.Version) with GUID => $($KesEndpoint.IdentifyingNumber)"
$PlainPassword=''
If ($($Global:SWMB_Custom.KesPassword)) {
# Batch - password defined in clear text
$PlainPassword = $($Global:SWMB_Custom.KesPassword)
} ElseIf (($($Global:SWMB_Custom.KesSecureString)) -And (Test-Path -LiteralPath "$($Global:SWMB_Custom.KesKeyFile)")) {
# Batch - encrypted (blurred) password
$Password = $($Global:SWMB_Custom.KesSecureString) | ConvertTo-SecureString -Key (Get-Content $($Global:SWMB_Custom.KesKeyFile))
$Credential = New-Object System.Management.Automation.PsCredential($($Global:SWMB_Custom.KesLogin),$Password)
$CryptPassword = $($Global:SWMB_Custom.KesSecureString) | ConvertTo-SecureString -Key (Get-Content $($Global:SWMB_Custom.KesKeyFile))
$Credential = New-Object System.Management.Automation.PsCredential($($Global:SWMB_Custom.KesLogin),$CryptPassword)
$PlainPassword = $Credential.GetNetworkCredential().Password
}
#Else {
# Interactive - ask password
#$PlainPassword = Read-Host -AsSecureString -Prompt "Give the Kaspersky endpoint password for $($($Global:SWMB_Custom.KesLogin))"
#}
# Uninstall
$MSIArguments = @(
"/x"
$Kes.IdentifyingNumber
$KesEndpoint.IdentifyingNumber
"KLLOGIN=$($($Global:SWMB_Custom.KesLogin))"
"KLPASSWD=$PlainPassword"
"/norestart"
......@@ -110,7 +121,7 @@ Function TweakUninstallKasperskyEndpoint { # RESINFO
Start-Process "msiexec.exe" -ArgumentList "/x $($KesAgent.IdentifyingNumber) /qn" -Wait -NoNewWindow
}
Else {
Write-Host "Kaspersky agent Security Center is not installed on this computer "
Write-Host "Kaspersky Agent Security Center is not installed on this computer "
}
}
......
......@@ -3,9 +3,15 @@ Do {
$KeyFile = Read-Host -Prompt "Key File"
} Until (Test-Path -LiteralPath "$KeyFile")
$EncryptedPass = Read-Host -Prompt "Encrypted blurred Password"
$EncryptedEndpointPass = Read-Host -Prompt "Encrypted blurred Endpoint Password"
$EncryptedAgentPass = Read-Host -Prompt "Encrypted blurred Agent Password"
$Password = $EncryptedPass | ConvertTo-SecureString -Key (Get-Content $KeyFile)
$Credential = New-Object System.Management.Automation.PsCredential('AsYouWant',$Password)
$PlainPassword = $Credential.GetNetworkCredential().Password
Write-Output "Password in clear text: $PlainPassword"
$EndpointPassword = $EncryptedEndpointPass | ConvertTo-SecureString -Key (Get-Content $KeyFile)
$EndpointCredential = New-Object System.Management.Automation.PsCredential('AsYouWant',$EndpointPassword)
$EndpointPlainPassword = $EndpointCredential.GetNetworkCredential().Password
Write-Output "Endpoint Password in clear text: $EndpointPlainPassword"
$AgentPassword = $EncryptedAgentPass | ConvertTo-SecureString -Key (Get-Content $KeyFile)
$AgentCredential = New-Object System.Management.Automation.PsCredential('AsYouWant',$AgentPassword)
$AgentPlainPassword = $AgentCredential.GetNetworkCredential().Password
Write-Output "Agent Password in clear text: $AgentPlainPassword"
$KesKeyFile = Read-Host -Prompt "Key File (please put .key extension)"
$KesPassword = Read-Host -AsSecureString -Prompt "Password to secure"
$KesAgentPassword = Read-Host -AsSecureString -Prompt "Network Agent Password to secure"
$KesPassword = Read-Host -AsSecureString -Prompt "Kaspersky Endpoint Password to secure"
$KesAgentPassword = Read-Host -AsSecureString -Prompt "Kaspersky Network Agent Password to secure"
if ($KesKeyFile) {
$Key = New-Object Byte[] 32 # create key AES 256-bit key (32 bytes)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment