jborean93 / pypsrp

PowerShell Remoting Protocol for Python
MIT License
328 stars 49 forks source link

Intermittent connection failures #169

Closed cidrbl0ck closed 1 year ago

cidrbl0ck commented 1 year ago

this is directly related to the Issue I opened a day ago. Turns out, an ad-hoc from the AAP Controller was successful. However 5 minutes later another using the same win_ping module failed:

cccc | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via PSRP: HTTPConnectionPool(host='10.100.22.129', port=5985): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f036978e040>, 'Connection to 10.100.22.129 timed out. (connect timeout=30)'))",
    "unreachable": true
}

Now what's weird is that I can wait 1 minute or 10, the next attempt might fail or it might succeed. It's entirely random, and I have no idea why. The target host (Win Server 2019) tests consistently successful with something low level like a telnet to port 5985. I am not using an HTTPS listener, no TLS/SSL or certificate business. Just Basic auth, no encryption and local Windows firewall rule is open with limited scope to the AAP subnet.

I've had no lucky Googling, and I hate to open another Issue but Im not sure where to turn. The Execution Environment I built with all the latest versions of the dependencies for PSRP, and the community.windows collection.

Anyway I'm hoping there's some magic tweak because of a random thing MS did with 2019+ that might affect wsman connections. I found a fat zilch in the event logs even with the psdiagnostic module.