Merge pull request #30 from withshubh/deepfix
Autofixes made using DeepSource
This commit is contained in:
commit
69b7e700dc
|
@ -0,0 +1,14 @@
|
||||||
|
version = 1
|
||||||
|
|
||||||
|
test_patterns = ["**/**_test.py"]
|
||||||
|
|
||||||
|
[[analyzers]]
|
||||||
|
name = "python"
|
||||||
|
enabled = true
|
||||||
|
dependency_file_paths = [
|
||||||
|
"monkey/monkey_island/requirements.txt",
|
||||||
|
"monkey/infection_monkey/requirements.txt"
|
||||||
|
]
|
||||||
|
|
||||||
|
[analyzers.meta]
|
||||||
|
runtime_version = "3.x.x"
|
|
@ -228,7 +228,6 @@ class ShellShockExploiter(HostExploiter):
|
||||||
Checks if which urls exist
|
Checks if which urls exist
|
||||||
:return: Sequence of URLs to try and attack
|
:return: Sequence of URLs to try and attack
|
||||||
"""
|
"""
|
||||||
import requests
|
|
||||||
attack_path = 'http://'
|
attack_path = 'http://'
|
||||||
if is_https:
|
if is_https:
|
||||||
attack_path = 'https://'
|
attack_path = 'https://'
|
||||||
|
|
|
@ -56,7 +56,7 @@ class WebRCE(HostExploiter):
|
||||||
Method that creates a dictionary of configuration values for exploit
|
Method that creates a dictionary of configuration values for exploit
|
||||||
:return: configuration dict
|
:return: configuration dict
|
||||||
"""
|
"""
|
||||||
exploit_config = dict()
|
exploit_config = {}
|
||||||
|
|
||||||
# dropper: If true monkey will use dropper parameter that will detach monkey's process and try to copy
|
# dropper: If true monkey will use dropper parameter that will detach monkey's process and try to copy
|
||||||
# it's file to the default destination path.
|
# it's file to the default destination path.
|
||||||
|
|
|
@ -113,7 +113,7 @@ class NetworkScanner(object):
|
||||||
:return: Victim or None if victim isn't alive
|
:return: Victim or None if victim isn't alive
|
||||||
"""
|
"""
|
||||||
LOG.debug("Scanning target address: %r", victim)
|
LOG.debug("Scanning target address: %r", victim)
|
||||||
if any([scanner.is_host_alive(victim) for scanner in self.scanners]):
|
if any(scanner.is_host_alive(victim) for scanner in self.scanners):
|
||||||
LOG.debug("Found potential target_ip: %r", victim)
|
LOG.debug("Found potential target_ip: %r", victim)
|
||||||
return victim
|
return victim
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -139,7 +139,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
|
||||||
timeout = int(round(timeout)) # clamp to integer, to avoid checking input
|
timeout = int(round(timeout)) # clamp to integer, to avoid checking input
|
||||||
sockets_to_try = possible_ports[:]
|
sockets_to_try = possible_ports[:]
|
||||||
connected_ports_sockets = []
|
connected_ports_sockets = []
|
||||||
while (timeout >= 0) and len(sockets_to_try):
|
while (timeout >= 0) and sockets_to_try:
|
||||||
sock_objects = [s[1] for s in sockets_to_try]
|
sock_objects = [s[1] for s in sockets_to_try]
|
||||||
|
|
||||||
_, writeable_sockets, _ = select.select(sock_objects, sock_objects, sock_objects, 0)
|
_, writeable_sockets, _ = select.select(sock_objects, sock_objects, sock_objects, 0)
|
||||||
|
|
|
@ -67,8 +67,8 @@ def _get_windows_cred(pypykatz_cred: PypykatzCredential):
|
||||||
|
|
||||||
|
|
||||||
def _hash_to_string(hash_: Any):
|
def _hash_to_string(hash_: Any):
|
||||||
if type(hash_) == str:
|
if type(hash_) is str:
|
||||||
return hash_
|
return hash_
|
||||||
if type(hash_) == bytes:
|
if type(hash_) is bytes:
|
||||||
return binascii.hexlify(bytearray(hash_)).decode()
|
return binascii.hexlify(bytearray(hash_)).decode()
|
||||||
raise Exception(f"Can't convert hash_ to string, unsupported hash_ type {type(hash_)}")
|
raise Exception(f"Can't convert hash_ to string, unsupported hash_ type {type(hash_)}")
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
from infection_monkey.utils.plugins.pluginTests.PluginTestClass import \
|
|
||||||
TestPlugin # noqa: F401
|
|
||||||
|
|
||||||
|
|
||||||
class SomeDummyPlugin:
|
class SomeDummyPlugin:
|
||||||
|
|
|
@ -87,20 +87,18 @@ class Monkey(flask_restful.Resource):
|
||||||
parent = monkey_json.get('parent')
|
parent = monkey_json.get('parent')
|
||||||
parent_to_add = (monkey_json.get('guid'), None) # default values in case of manual run
|
parent_to_add = (monkey_json.get('guid'), None) # default values in case of manual run
|
||||||
if parent and parent != monkey_json.get('guid'): # current parent is known
|
if parent and parent != monkey_json.get('guid'): # current parent is known
|
||||||
exploit_telem = [x for x in
|
exploit_telem = list(mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
|
||||||
mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
|
|
||||||
'data.result': {'$eq': True},
|
'data.result': {'$eq': True},
|
||||||
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']},
|
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']},
|
||||||
'monkey_guid': {'$eq': parent}})]
|
'monkey_guid': {'$eq': parent}}))
|
||||||
if 1 == len(exploit_telem):
|
if 1 == len(exploit_telem):
|
||||||
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))
|
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))
|
||||||
else:
|
else:
|
||||||
parent_to_add = (parent, None)
|
parent_to_add = (parent, None)
|
||||||
elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json:
|
elif (not parent or parent == monkey_json.get('guid')) and 'ip_addresses' in monkey_json:
|
||||||
exploit_telem = [x for x in
|
exploit_telem = list(mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
|
||||||
mongo.db.telemetry.find({'telem_category': {'$eq': 'exploit'},
|
|
||||||
'data.result': {'$eq': True},
|
'data.result': {'$eq': True},
|
||||||
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}})]
|
'data.machine.ip_addr': {'$in': monkey_json['ip_addresses']}}))
|
||||||
|
|
||||||
if 1 == len(exploit_telem):
|
if 1 == len(exploit_telem):
|
||||||
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))
|
parent_to_add = (exploit_telem[0].get('monkey_guid'), exploit_telem[0].get('data').get('exploiter'))
|
||||||
|
|
|
@ -63,7 +63,7 @@ class DisplayedEdgeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def services_to_displayed_services(services, for_report=False):
|
def services_to_displayed_services(services, for_report=False):
|
||||||
if for_report:
|
if for_report:
|
||||||
return [x for x in services]
|
return list(services)
|
||||||
else:
|
else:
|
||||||
return [x + ": " + (services[x]['name'] if 'name' in services[x] else 'unknown') for x in services]
|
return [x + ": " + (services[x]['name'] if 'name' in services[x] else 'unknown') for x in services]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from monkey_island.cc.database import mongo
|
from monkey_island.cc.database import mongo
|
||||||
from monkey_island.cc.models import Monkey
|
from monkey_island.cc.models import Monkey
|
||||||
from monkey_island.cc.services.edge.edge import EdgeService
|
|
||||||
from monkey_island.cc.services.node import NodeService
|
from monkey_island.cc.services.node import NodeService
|
||||||
from monkey_island.cc.services.telemetry.processing.utils import \
|
from monkey_island.cc.services.telemetry.processing.utils import \
|
||||||
get_edge_by_scan_or_exploit_telemetry
|
get_edge_by_scan_or_exploit_telemetry
|
||||||
|
|
Loading…
Reference in New Issue