forked from p15670423/monkey
Documentation
This commit is contained in:
parent
1bd633a0b1
commit
a85d4e8775
|
@ -11,6 +11,11 @@ from random import randint
|
||||||
|
|
||||||
|
|
||||||
def get_host_subnets():
|
def get_host_subnets():
|
||||||
|
"""
|
||||||
|
Returns a list of subnets visible to host (omitting loopback and auto conf networks)
|
||||||
|
Each subnet item contains the host IP in that network + the subnet.
|
||||||
|
:return: List of dict, keys are "addr" and "subnet"
|
||||||
|
"""
|
||||||
ipv4_nets = [netifaces.ifaddresses(interface)[netifaces.AF_INET]
|
ipv4_nets = [netifaces.ifaddresses(interface)[netifaces.AF_INET]
|
||||||
for interface in netifaces.interfaces()
|
for interface in netifaces.interfaces()
|
||||||
if netifaces.AF_INET in netifaces.ifaddresses(interface)
|
if netifaces.AF_INET in netifaces.ifaddresses(interface)
|
||||||
|
@ -111,6 +116,11 @@ def get_free_tcp_port(min_range=1000, max_range=65535):
|
||||||
|
|
||||||
|
|
||||||
def check_internet_access(services):
|
def check_internet_access(services):
|
||||||
|
"""
|
||||||
|
Checks if any of the services are accessible, over ICMP
|
||||||
|
:param services: List of IPs/hostnames
|
||||||
|
:return: boolean depending on internet access
|
||||||
|
"""
|
||||||
ping_str = "-n 1" if sys.platform.startswith("win") else "-c 1"
|
ping_str = "-n 1" if sys.platform.startswith("win") else "-c 1"
|
||||||
for host in services:
|
for host in services:
|
||||||
if os.system("ping " + ping_str + " " + host) == 0:
|
if os.system("ping " + ping_str + " " + host) == 0:
|
||||||
|
@ -119,6 +129,11 @@ def check_internet_access(services):
|
||||||
|
|
||||||
|
|
||||||
def get_ips_from_interfaces():
|
def get_ips_from_interfaces():
|
||||||
|
"""
|
||||||
|
Returns a list of IPs accessible in the host in each network interface, in the subnet.
|
||||||
|
Limits to a single class C if the network is larger
|
||||||
|
:return: List of IPs, marked as strings.
|
||||||
|
"""
|
||||||
res = []
|
res = []
|
||||||
ifs = get_host_subnets()
|
ifs = get_host_subnets()
|
||||||
for net_interface in ifs:
|
for net_interface in ifs:
|
||||||
|
|
|
@ -47,12 +47,18 @@ class InfoCollector(object):
|
||||||
|
|
||||||
def get_hostname(self):
|
def get_hostname(self):
|
||||||
"""
|
"""
|
||||||
Adds the computer hostname to the system information.
|
Adds the fully qualified computer hostname to the system information.
|
||||||
:return:
|
:return: Nothing
|
||||||
"""
|
"""
|
||||||
self.info['hostname'] = socket.getfqdn()
|
self.info['hostname'] = socket.getfqdn()
|
||||||
|
|
||||||
def get_process_list(self):
|
def get_process_list(self):
|
||||||
|
"""
|
||||||
|
Adds process information from the host to the system information.
|
||||||
|
Currently lists process name, ID, parent ID, command line
|
||||||
|
and the full image path of each process.
|
||||||
|
:return: Nothing
|
||||||
|
"""
|
||||||
processes = {}
|
processes = {}
|
||||||
for process in psutil.process_iter():
|
for process in psutil.process_iter():
|
||||||
try:
|
try:
|
||||||
|
@ -78,7 +84,8 @@ class InfoCollector(object):
|
||||||
def get_network_info(self):
|
def get_network_info(self):
|
||||||
"""
|
"""
|
||||||
Adds network information from the host to the system information.
|
Adds network information from the host to the system information.
|
||||||
Currently returns a list of networks accessible from host, containing host ip and the subnet range.
|
Currently updates with a list of networks accessible from host,
|
||||||
|
containing host ip and the subnet range.
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.info['network_info'] = {'networks': get_host_subnets()}
|
self.info['network_info'] = {'networks': get_host_subnets()}
|
||||||
|
|
Loading…
Reference in New Issue