forked from p34709852/monkey
Fixed CR comments and implemented test for proxy attack techniques
This commit is contained in:
parent
930ff08149
commit
35c496812f
|
@ -68,19 +68,17 @@ class Monkey(Document):
|
||||||
os = "windows"
|
os = "windows"
|
||||||
return os
|
return os
|
||||||
|
|
||||||
|
def get_network_info(self):
|
||||||
|
"""
|
||||||
|
Formats network info from monkey's model
|
||||||
|
:return: dictionary with an array of IP's and a hostname
|
||||||
|
"""
|
||||||
|
return {'ips': self.ip_addresses, 'hostname': self.hostname}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_tunneled_monkeys():
|
def get_tunneled_monkeys():
|
||||||
return Monkey.objects(tunnel__exists=True)
|
return Monkey.objects(tunnel__exists=True)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_network_info(monkey):
|
|
||||||
"""
|
|
||||||
Formats network info from monkey's model
|
|
||||||
:param monkey: monkey model
|
|
||||||
:return: dictionary with an array of IP's and a hostname
|
|
||||||
"""
|
|
||||||
return {'ips': monkey.ip_addresses, 'hostname': monkey.hostname}
|
|
||||||
|
|
||||||
|
|
||||||
class MonkeyNotFoundError(Exception):
|
class MonkeyNotFoundError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -9,11 +9,11 @@ from monkey_ttl import MonkeyTtl
|
||||||
|
|
||||||
class TestMonkey(IslandTestCase):
|
class TestMonkey(IslandTestCase):
|
||||||
"""
|
"""
|
||||||
Make sure to set server environment to `testing` in server.json! Otherwise this will mess up your mongo instance and
|
Make sure to set server environment to `testing` in server_config.json! Otherwise this will mess up your mongo instance and
|
||||||
won't work.
|
won't work.
|
||||||
|
|
||||||
Also, the working directory needs to be the working directory from which you usually run the island so the
|
Also, the working directory needs to be the working directory from which you usually run the island so the
|
||||||
server.json file is found and loaded.
|
server_config.json file is found and loaded.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_is_dead(self):
|
def test_is_dead(self):
|
||||||
|
@ -77,3 +77,25 @@ class TestMonkey(IslandTestCase):
|
||||||
self.assertEquals(1, len(filter(lambda m: m.get_os() == "windows", Monkey.objects())))
|
self.assertEquals(1, len(filter(lambda m: m.get_os() == "windows", Monkey.objects())))
|
||||||
self.assertEquals(1, len(filter(lambda m: m.get_os() == "linux", Monkey.objects())))
|
self.assertEquals(1, len(filter(lambda m: m.get_os() == "linux", Monkey.objects())))
|
||||||
self.assertEquals(1, len(filter(lambda m: m.get_os() == "unknown", Monkey.objects())))
|
self.assertEquals(1, len(filter(lambda m: m.get_os() == "unknown", Monkey.objects())))
|
||||||
|
|
||||||
|
def test_get_tunneled_monkeys(self):
|
||||||
|
self.fail_if_not_testing_env()
|
||||||
|
self.clean_monkey_db()
|
||||||
|
|
||||||
|
linux_monkey = Monkey(guid=str(uuid.uuid4()),
|
||||||
|
description="Linux shay-Virtual-Machine")
|
||||||
|
windows_monkey = Monkey(guid=str(uuid.uuid4()),
|
||||||
|
description="Windows bla bla bla",
|
||||||
|
tunneling=linux_monkey)
|
||||||
|
unknown_monkey = Monkey(guid=str(uuid.uuid4()),
|
||||||
|
description="bla bla bla",
|
||||||
|
tunneling=windows_monkey)
|
||||||
|
linux_monkey.save()
|
||||||
|
windows_monkey.save()
|
||||||
|
unknown_monkey.save()
|
||||||
|
tunneled_monkeys = Monkey.get_tunneled_monkeys()
|
||||||
|
test = bool(windows_monkey in tunneled_monkeys
|
||||||
|
and unknown_monkey in tunneled_monkeys
|
||||||
|
and linux_monkey not in tunneled_monkeys
|
||||||
|
and len(tunneled_monkeys) == 2)
|
||||||
|
self.assertTrue(test, "Tunneling test")
|
||||||
|
|
|
@ -15,11 +15,8 @@ class T1090(AttackTechnique):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_report_data():
|
def get_report_data():
|
||||||
monkeys = Monkey.get_tunneled_monkeys()
|
monkeys = Monkey.get_tunneled_monkeys()
|
||||||
monkeys = [Monkey.get_network_info(monkey) for monkey in monkeys]
|
monkeys = [monkey.get_network_info() for monkey in monkeys]
|
||||||
if monkeys:
|
status = ScanStatus.USED.value if monkeys else ScanStatus.UNSCANNED.value
|
||||||
status = ScanStatus.USED.value
|
|
||||||
else:
|
|
||||||
status = ScanStatus.UNSCANNED.value
|
|
||||||
data = T1090.get_base_data_by_status(status)
|
data = T1090.get_base_data_by_status(status)
|
||||||
data.update({'proxies': monkeys})
|
data.update({'proxies': monkeys})
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -23,13 +23,10 @@ class T1188(AttackTechnique):
|
||||||
proxy_count += 1
|
proxy_count += 1
|
||||||
proxy = proxy.tunnel
|
proxy = proxy.tunnel
|
||||||
if proxy_count > 1:
|
if proxy_count > 1:
|
||||||
hops.append({'from': Monkey.get_network_info(initial),
|
hops.append({'from': initial.get_network_info(),
|
||||||
'to': Monkey.get_network_info(proxy),
|
'to': proxy.get_network_info(),
|
||||||
'count': proxy_count})
|
'count': proxy_count})
|
||||||
if hops:
|
status = ScanStatus.USED.value if hops else ScanStatus.UNSCANNED.value
|
||||||
status = ScanStatus.USED.value
|
|
||||||
else:
|
|
||||||
status = ScanStatus.UNSCANNED.value
|
|
||||||
data = T1188.get_base_data_by_status(status)
|
data = T1188.get_base_data_by_status(status)
|
||||||
data.update({'hops': hops})
|
data.update({'hops': hops})
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -17,6 +17,7 @@ export function renderMachineFromSystemData(data) {
|
||||||
machineStr += ipInfo + ", ";
|
machineStr += ipInfo + ", ";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// Replaces " ," with " )" to finish a list of IP's
|
||||||
return machineStr.slice(0, -2) + " )"
|
return machineStr.slice(0, -2) + " )"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ class T1090 extends React.Component {
|
||||||
|
|
||||||
static getProxyColumns() {
|
static getProxyColumns() {
|
||||||
return ([{
|
return ([{
|
||||||
Header: "Proxies were used to communicate with:",
|
|
||||||
columns: [
|
columns: [
|
||||||
{Header: 'Machines',
|
{Header: 'Machines',
|
||||||
id: 'machine',
|
id: 'machine',
|
||||||
|
@ -26,12 +25,15 @@ class T1090 extends React.Component {
|
||||||
<div>{this.props.data.message}</div>
|
<div>{this.props.data.message}</div>
|
||||||
<br/>
|
<br/>
|
||||||
{this.props.data.status === scanStatus.USED ?
|
{this.props.data.status === scanStatus.USED ?
|
||||||
|
<div>
|
||||||
|
<p>Proxies were used to communicate with:</p>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
columns={T1090.getProxyColumns()}
|
columns={T1090.getProxyColumns()}
|
||||||
data={this.props.data.proxies}
|
data={this.props.data.proxies}
|
||||||
showPagination={false}
|
showPagination={false}
|
||||||
defaultPageSize={this.props.data.proxies.length}
|
defaultPageSize={this.props.data.proxies.length}
|
||||||
/> : ""}
|
/>
|
||||||
|
</div>: ""}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class T1188 extends React.Component {
|
||||||
|
|
||||||
static getHopColumns() {
|
static getHopColumns() {
|
||||||
return ([{
|
return ([{
|
||||||
Header: "Communications trough multi-hop proxies",
|
Header: "Communications through multi-hop proxies",
|
||||||
columns: [
|
columns: [
|
||||||
{Header: 'From',
|
{Header: 'From',
|
||||||
id: 'from',
|
id: 'from',
|
||||||
|
|
Loading…
Reference in New Issue