Last active
August 11, 2022 07:27
-
-
Save koss822/958c6344f29ee5d360abaceb16576e7c to your computer and use it in GitHub Desktop.
Detect active RDP connection in Python
This file contains 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
from subprocess import check_output, STDOUT, CREATE_NO_WINDOW | |
def rdp_connected(self, ttl_hash=None): | |
output = check_output('qwinsta', stderr=STDOUT, | |
creationflags=CREATE_NO_WINDOW).decode('latin1') | |
for line in output.split('\r\n'): | |
if 'rdp-tcp#' in line and 'Active' in line: | |
log.info(line) | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment