27 lines
720 B
Plaintext
27 lines
720 B
Plaintext
#
|
|
# ID: 1f338f
|
|
# Nazwa: Python-PowerShell Socket Connection
|
|
# Opis: PowerShell
|
|
# Publiczny: 0
|
|
# Data utworzenia/ostatniej edycji (UTC): 2023-10-18 21:15:54
|
|
#
|
|
|
|
$socketHost = "127.0.0.1"
|
|
|
|
$socketPort = "53588"
|
|
|
|
|
|
|
|
$tcpConnection = New-Object System.Net.Sockets.TcpClient($socketHost, $socketPort)
|
|
|
|
$tcpStream = $tcpConnection.GetStream()
|
|
|
|
$reader = New-Object System.IO.StreamReader($tcpStream)
|
|
|
|
|
|
|
|
while ($tcpConnection.Connected) {
|
|
|
|
while ($tcpStream.DataAvailable -or $reader.Peek() -ne -1 ) {
|
|
|
|
$response = $reader.ReadLine()
|
|
|
|
Write-Output "Received:"
|
|
|
|
Write-Output "$response"
|
|
|
|
}
|
|
|
|
|
|
|
|
start-sleep -Milliseconds 500
|
|
|
|
}
|
|
|
|
|
|
|
|
$reader.Close()
|
|
|
|
$tcpConnection.Close() |