Skip to content

Instantly share code, notes, and snippets.

@thiagoeh
Last active June 11, 2019 16:07
Show Gist options
  • Select an option

  • Save thiagoeh/c845aef6e3c3372dcac29eaa876401fc to your computer and use it in GitHub Desktop.

Select an option

Save thiagoeh/c845aef6e3c3372dcac29eaa876401fc to your computer and use it in GitHub Desktop.
# Direct connection
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/thiagoeh/c845aef6e3c3372dcac29eaa876401fc/raw'))"
# With proxy
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/thiagoeh/c845aef6e3c3372dcac29eaa876401fc/raw'))"
Write-Output "Duplicating default RDP listener"
Copy-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Destination "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-3007-Tcp" -Recurse
Write-Output "Setting port value 3007 for the new listener"
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-3007-Tcp" -Name PortNumber -Value 3007
Write-Output "Opening-up TCP 3007 in the firewall"
New-NetFirewallRule -DisplayName "Inbound TCP 3007" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment