Added internet access check

Shown in the monkey properties in the island
This commit is contained in:
itsikkes 2016-06-28 11:13:24 +03:00
parent d437015e1b
commit 84496dd3f5
4 changed files with 13 additions and 1 deletions

View File

@ -137,6 +137,8 @@ class Configuration(object):
retry_failed_explotation = True
internet_services = ["www.guardicore.com", "www.google.com"]
###########################
# scanners config
###########################

View File

@ -3,7 +3,7 @@ import logging
import requests
import platform
import monkeyfs
from network.info import local_ips
from network.info import local_ips, check_internet_access
from socket import gethostname
from config import WormConfiguration, GUID
from transport.tcp import TcpProxy
@ -38,6 +38,7 @@ class ControlClient(object):
'hostname': hostname,
'ip_addresses': local_ips(),
'description': " ".join(platform.uname()),
'internet_access': check_internet_access(WormConfiguration.internet_services),
'config': WormConfiguration.as_dict(),
'parent': parent}

View File

@ -1,3 +1,4 @@
import os
import sys
import socket
import struct
@ -58,3 +59,10 @@ def get_free_tcp_port(min_range=1000, max_range=65535):
return port
return None
def check_internet_access(services):
ping_str = "-n 1" if sys.platform.startswith("win") else "-c 1"
for host in services:
if os.system("ping " + ping_str + " " + host) == 0:
return True
return False

View File

@ -269,6 +269,7 @@ function buildMonkeyDescription(monkey) {
var html =
"<label>Name:</label> " + monkey.hostname + "</br>" +
"<label>Description:</label> " + monkey.description + "</br>" +
"<label>Internet Access:</label> " + monkey.internet_access + "</br>" +
"<label>IP Address:</label></br>"
for (var i = 0; i < monkey.ip_addresses.length; i++) {