Wpis z mikrobloga

#powershell #bezpieczenstwo #windows #it #security
NIe ma tutaj jakiegoś expoita czy wirusa?

# Run SSCM remove
# $ccmpath is path to SCCM Agent's own uninstall routine.
$CCMpath = 'C:\Windows\ccmsetup\ccmsetup.exe'
# And if it exists we will remove it, or else we will silently fail.
if (Test-Path $CCMpath) {

Start-Process -FilePath $CCMpath -Args "/uninstall" -Wait -NoNewWindow
# wait for exit

$CCMProcess = Get-Process ccmsetup -ErrorAction SilentlyContinue

try{
$CCMProcess.WaitForExit()
}catch{


}
}

# Stop Services
Stop-Service -Name ccmsetup -Force -ErrorAction SilentlyContinue
Stop-Service -Name CcmExec -Force -ErrorAction SilentlyContinue
Stop-Service -Name smstsmgr -Force -ErrorAction SilentlyContinue
Stop-Service -Name CmRcService -Force -ErrorAction SilentlyContinue

# wait for services to exit
$CCMProcess = Get-Process ccmexec -ErrorAction SilentlyContinue
try{

$CCMProcess.WaitForExit()

}catch{

}


# Remove WMI Namespaces
Get-WmiObject -Query "SELECT * FROM __Namespace WHERE Name='ccm'" -Namespace root | Remove-WmiObject
Get-WmiObject -Query "SELECT * FROM _Namespace WHERE Name='sms'" -Namespace root\cimv2 | Remove-WmiObject

# Remove Services from Registry
# Set $CurrentPath to services registry keys
$CurrentPath = “HKLM:\SYSTEM\CurrentControlSet\Services”
Remove-Item -Path $CurrentPath\CCMSetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\CcmExec -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\smstsmgr -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\CmRcService -Force -Recurse -ErrorAction SilentlyContinue

# Remove SCCM Client from Registry
# Update $CurrentPath to HKLM/Software/Microsoft
$CurrentPath = “HKLM:\SOFTWARE\Microsoft”
Remove-Item -Path $CurrentPath\CCM -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\CCMSetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\SMS -Force -Recurse -ErrorAction SilentlyContinue

# Reset MDM Authority
# CurrentPath should still be correct, we are removing this key: HKEY
LOCAL_MACHINE\SOFTWARE\Microsoft\DeviceManageabilityCSP
Remove-Item -Path $CurrentPath\DeviceManageabilityCSP -Force -Recurse -ErrorAction SilentlyContinue

# Remove Folders and Files
# Tidy up garbage in Windows folder
$CurrentPath = $env:WinDir
Remove-Item -Path $CurrentPath\CCM -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\ccmsetup -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\ccmcache -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\SMSCFG.ini -Force -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\SMS*.mif -Force -ErrorAction SilentlyContinue
Remove-Item -Path $CurrentPath\SMS*.mif -Force -ErrorAction SilentlyContinue
  • 9
@Koliat: dzięki tam sprawdzałem inne scrypty ale fortigate blokował dostęp a znalazłem coś takiego i ładnie usuneło foldery w lapku odciętym od sieci jeszcze na 2 - 3 sprawdze i będzie "wajcha w dół na wszystkich" ( ͡° ͜ʖ ͡°)
@Koliat: takie pytanie
czemu

Remove-Item -Path C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft System Center -Force -Recurse -ErrorAction SilentlyContinue

Nie kasuję z pasku startu System Center?
via Wykop Mobilny (Android)
  • 1
@etc_daemon: Pasek startu? Pewnie gdzieś indziej sa te skróty, jest kilka lokalizacji z tego co kojarzę. Tak jak wejdziesz w ten katalog to widzisz dużo więcej skrótów w starcie, a w tym programdata jest ich jednak mniej niż widzisz. Po restarcie też nieusuniete?
Po restarcie też nieusuniete?


@Koliat: niestety nie

Remove-Item : A positional parameter cannot be found that accepts argument 'Menu\Programs\Microsoft'.
At line:1 char:12
+ Remove-Item <<<< -Path C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft System Center\Configuration Ma
nager -Force
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand