89 lines
2.4 KiB
PowerShell
89 lines
2.4 KiB
PowerShell
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
Write-Host "[*] Setting up RDP connection with saved credentials"
|
|
|
|
# RDP file path on desktop
|
|
$rdpFile = "C:\Users\User\Desktop\Remote-PC.rdp"
|
|
|
|
# RDP file content with credentials
|
|
$rdpContent = @"
|
|
screen mode id:i:2
|
|
use multimon:i:0
|
|
desktopwidth:i:1920
|
|
desktopheight:i:1080
|
|
session bpp:i:32
|
|
winposstr:s:0,3,0,0,800,600
|
|
compression:i:1
|
|
keyboardhook:i:2
|
|
audiocapturemode:i:0
|
|
videoplaybackmode:i:1
|
|
connection type:i:7
|
|
networkautodetect:i:1
|
|
bandwidthautodetect:i:1
|
|
displayconnectionbar:i:1
|
|
enableworkspacereconnect:i:0
|
|
disable wallpaper:i:0
|
|
allow font smoothing:i:0
|
|
allow desktop composition:i:0
|
|
disable full window drag:i:1
|
|
disable menu anims:i:1
|
|
disable themes:i:0
|
|
disable cursor setting:i:0
|
|
bitmapcachepersistenable:i:1
|
|
full address:s:192.168.88.21
|
|
audiomode:i:0
|
|
redirectprinters:i:1
|
|
redirectcomports:i:0
|
|
redirectsmartcards:i:1
|
|
redirectclipboard:i:1
|
|
redirectposdevices:i:0
|
|
autoreconnection enabled:i:1
|
|
authentication level:i:2
|
|
prompt for credentials:i:0
|
|
negotiate security layer:i:1
|
|
remoteapplicationmode:i:0
|
|
alternate shell:s:
|
|
shell working directory:s:
|
|
gatewayhostname:s:
|
|
gatewayusagemethod:i:4
|
|
gatewaycredentialssource:i:4
|
|
gatewayprofileusagemethod:i:0
|
|
promptcredentialonce:i:0
|
|
gatewaybrokeringtype:i:0
|
|
use redirection server name:i:0
|
|
rdgiskdcproxy:i:0
|
|
kdcproxyname:s:
|
|
drivestoredirect:s:
|
|
username:s:ChiaYing
|
|
domain:s:
|
|
"@
|
|
|
|
# Write RDP file
|
|
$rdpContent | Out-File -FilePath $rdpFile -Encoding UTF8
|
|
Write-Host "[*] RDP file created: $rdpFile"
|
|
|
|
# Add credential to Windows Credential Manager
|
|
Write-Host "[*] Adding credentials to Windows Credential Manager"
|
|
|
|
try {
|
|
# Use cmdkey to add credential
|
|
& cmdkey /generic:"TERMSRV/192.168.88.21" /user:"ChiaYing" /pass:"!ChiaYing"
|
|
Write-Host "[OK] Credentials saved to Credential Manager"
|
|
} catch {
|
|
Write-Host "[!] Failed to save credentials: $($_.Exception.Message)"
|
|
}
|
|
|
|
# Verify the RDP file was created
|
|
if (Test-Path $rdpFile) {
|
|
$fileInfo = Get-Item $rdpFile
|
|
Write-Host "[OK] RDP file ready: $($fileInfo.Name) ($($fileInfo.Length) bytes)"
|
|
Write-Host ""
|
|
Write-Host "Usage:"
|
|
Write-Host "1. Double-click 'Remote-PC.rdp' on desktop"
|
|
Write-Host "2. Connection should start automatically with saved credentials"
|
|
Write-Host "3. If prompted for password, enter: !ChiaYing"
|
|
} else {
|
|
Write-Host "[!] Failed to create RDP file"
|
|
exit 1
|
|
} |