ivan-sincek / powershell-reverse-tcp

PowerShell scripts for communicating with a remote host.
MIT License
297 stars 65 forks source link

Connection Hangs Up if Command Needs Confirmation #2

Closed florianendrich closed 3 years ago

florianendrich commented 3 years ago

Hei, thanks for your work.

I noticed a bug, you can reproduce it by getting powershell to ask for confirmation

Remove-VpnConnection -Name '<ConnectionName>'

The PowherShell now ask for a Confirmation

Deleting VPN connection <ConnectionName>. Do you want to continue?

which is not showing up on remote host, instead it just hangs.

ivan-sincek commented 3 years ago

Hi,

Thank you for submitting the bug, I will look into it and let you know once I find the solution.

Shells are based on Invoke-Expression command and not on process pipes so that might be the reason why it hangs - i.e. there are no direct pipes from socket to PowerShell process.

Best regards, Ivan.

ivan-sincek commented 3 years ago

Hi,

This is my test scenario:

Add-VpnConnection -Name "Test" -ServerAddress "10.1.1.1" -TunnelType "Pptp" -EncryptionLevel "Required" -AuthenticationMethod MSChapv2 -UseWinlogonCredential -SplitTunneling -AllUserConnection -RememberCredential -PassThru

Get-VpnConnection -AllUserConnection

Remove-VpnConnection -Name "Test" -AllUserConnection -Force -PassThru

Use -Force switch with Remove-VpnConnection. Have more info here.

Also, please have a look at this and this -Confirm switch.

Best regards, Ivan.

florianendrich commented 3 years ago

Hei,

yes this Workarround works, would be nice to not hang the connection though. Maybe working with a timeout would be an option.

I can live with that, but taking care of this behavior would make your script more convient to use.

Best regards and thanks for the effort.

ivan-sincek commented 3 years ago

Hi,

Thank you for your feedback. Maybe in the future I will make one with process pipes so no output will hang.

I will close this issue now.

Best regards, Ivan.