Last active
August 29, 2015 14:04
-
-
Save nicola/63bb6868cfcd7bab81f6 to your computer and use it in GitHub Desktop.
Find open FirefoxOS connection open and listening for remote debugging
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
import psutil | |
def get_connections(p): | |
try: | |
return p.get_connections() | |
except: | |
return [] | |
def is_listening(c): | |
return c.status == "LISTEN" and c.laddr[1] != 2828 | |
def find_ports(p): | |
return [c.laddr[1] for c in get_connections(p) if is_listening(c)] | |
def discover_rdp_ports(): | |
firefox = [] | |
firefoxos = [] | |
for p in psutil.process_iter(): | |
name = p.name() | |
if name == 'b2g-bin' or name == 'b2g': | |
firefoxos = firefoxos + find_ports(p) | |
elif name == 'firefox' or name == 'firefox-bin': | |
firefox = firefox + find_ports(p) | |
return {'firefox': firefox, 'firefoxos': firefoxos} | |
if __name__ == '__main__': | |
print discover_rdp_ports() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment