forked from p15670423/monkey
String vs byte stream mixup bugs fixed
This commit is contained in:
parent
9bcaf8b512
commit
ea40620373
|
@ -160,12 +160,9 @@ class SingleIpRange(NetworkRange):
|
|||
# The most common use case is to enter ip/range into "Scan IP/subnet list"
|
||||
domain_name = ''
|
||||
|
||||
# Make sure to have unicode string
|
||||
user_input = string.decode('utf-8', 'ignore')
|
||||
|
||||
# Try casting user's input as IP
|
||||
try:
|
||||
ip = ipaddress.ip_address(user_input).exploded
|
||||
ip = ipaddress.ip_address(string).exploded
|
||||
except ValueError:
|
||||
# Exception means that it's a domain name
|
||||
try:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from .infection_monkey.main import main
|
||||
from infection_monkey.main import main
|
||||
|
||||
if "__main__" == __name__:
|
||||
main()
|
||||
|
|
|
@ -4,11 +4,11 @@ import os
|
|||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from six.moves import xrange
|
||||
|
||||
import infection_monkey.tunnel as tunnel
|
||||
from infection_monkey.utils.monkey_dir import create_monkey_dir, get_monkey_dir_path, remove_monkey_dir
|
||||
from infection_monkey.utils.monkey_log_path import get_monkey_log_path
|
||||
from infection_monkey.utils.environment import is_windows_os
|
||||
from infection_monkey.config import WormConfiguration
|
||||
from infection_monkey.control import ControlClient
|
||||
from infection_monkey.model import DELAY_DELETE_CMD
|
||||
|
@ -105,7 +105,7 @@ class InfectionMonkey(object):
|
|||
ControlClient.wakeup(parent=self._parent)
|
||||
ControlClient.load_control_config()
|
||||
|
||||
if utils.is_windows_os():
|
||||
if is_windows_os():
|
||||
T1106Telem(ScanStatus.USED, UsageEnum.SINGLETON_WINAPI).send()
|
||||
|
||||
if not WormConfiguration.alive:
|
||||
|
@ -258,7 +258,7 @@ class InfectionMonkey(object):
|
|||
try:
|
||||
status = None
|
||||
if "win32" == sys.platform:
|
||||
from _subprocess import SW_HIDE, STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
|
||||
from subprocess import SW_HIDE, STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags = CREATE_NEW_CONSOLE | STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = SW_HIDE
|
||||
|
|
|
@ -19,7 +19,7 @@ class VirtualFile(BytesIO):
|
|||
if name in VirtualFile._vfs:
|
||||
super(VirtualFile, self).__init__(self._vfs[name])
|
||||
else:
|
||||
super(VirtualFile, self).__init__('')
|
||||
super(VirtualFile, self).__init__()
|
||||
|
||||
def flush(self):
|
||||
super(VirtualFile, self).flush()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import sys
|
||||
import socket
|
||||
import struct
|
||||
|
@ -13,6 +12,7 @@ import requests
|
|||
from requests import ConnectionError
|
||||
|
||||
from common.network.network_range import CidrRange
|
||||
from infection_monkey.utils.environment import is_windows_os
|
||||
|
||||
|
||||
# Timeout for monkey connections
|
||||
|
@ -39,11 +39,11 @@ def get_host_subnets():
|
|||
if 'broadcast' in network:
|
||||
network.pop('broadcast')
|
||||
for attr in network:
|
||||
network[attr] = network[attr].encode('utf-8').strip()
|
||||
network[attr] = network[attr]
|
||||
return ipv4_nets
|
||||
|
||||
|
||||
if sys.platform == "win32":
|
||||
if is_windows_os():
|
||||
|
||||
def local_ips():
|
||||
local_hostname = socket.gethostname()
|
||||
|
@ -159,7 +159,7 @@ def get_interfaces_ranges():
|
|||
return res
|
||||
|
||||
|
||||
if sys.platform == "win32":
|
||||
if is_windows_os():
|
||||
def get_ip_for_connection(target_ip):
|
||||
return None
|
||||
else:
|
||||
|
|
|
@ -161,7 +161,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
|
|||
if get_banner and (len(connected_ports_sockets) != 0):
|
||||
readable_sockets, _, _ = select.select([s[1] for s in connected_ports_sockets], [], [], 0)
|
||||
# read first BANNER_READ bytes
|
||||
banners = [sock.recv(BANNER_READ) if sock in readable_sockets else ""
|
||||
banners = [sock.recv(BANNER_READ).decode() if sock in readable_sockets else ""
|
||||
for port, sock in connected_ports_sockets]
|
||||
pass
|
||||
# try to cleanup
|
||||
|
|
|
@ -2,14 +2,15 @@ import os
|
|||
import logging
|
||||
import sys
|
||||
|
||||
sys.coinit_flags = 0 # needed for proper destruction of the wmi python module
|
||||
|
||||
import infection_monkey.config
|
||||
from infection_monkey.system_info.mimikatz_collector import MimikatzCollector
|
||||
from infection_monkey.system_info import InfoCollector
|
||||
from infection_monkey.system_info.wmi_consts import WMI_CLASSES
|
||||
from common.utils.wmi_utils import WMIUtils
|
||||
|
||||
|
||||
sys.coinit_flags = 0 # needed for proper destruction of the wmi python module
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG.info('started windows info collector')
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class WindowsSystemSingleton(_SystemSingleton):
|
|||
|
||||
handle = ctypes.windll.kernel32.CreateMutexA(None,
|
||||
ctypes.c_bool(True),
|
||||
ctypes.c_char_p(self._mutex_name))
|
||||
ctypes.c_char_p(self._mutex_name.encode()))
|
||||
last_error = ctypes.windll.kernel32.GetLastError()
|
||||
|
||||
if not handle:
|
||||
|
|
|
@ -33,7 +33,7 @@ class BaseTelem(object, metaclass=abc.ABCMeta):
|
|||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_data(self):
|
||||
def get_data(self) -> dict:
|
||||
"""
|
||||
:return: Data of telemetry (should be dict)
|
||||
"""
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from .monkey_island.cc.main import main
|
||||
from monkey_island.cc.main import main
|
||||
|
||||
if "__main__" == __name__:
|
||||
main()
|
||||
|
|
|
@ -35,7 +35,7 @@ class Encryptor:
|
|||
return message + (self._BLOCK_SIZE - (len(message) % self._BLOCK_SIZE)) * chr(
|
||||
self._BLOCK_SIZE - (len(message) % self._BLOCK_SIZE))
|
||||
|
||||
def _unpad(self, message):
|
||||
def _unpad(self, message: str):
|
||||
return message[0:-ord(message[len(message) - 1])]
|
||||
|
||||
def enc(self, message):
|
||||
|
@ -47,7 +47,7 @@ class Encryptor:
|
|||
enc_message = base64.b64decode(enc_message)
|
||||
cipher_iv = enc_message[0:AES.block_size]
|
||||
cipher = AES.new(self._cipher_key, AES.MODE_CBC, cipher_iv)
|
||||
return self._unpad(cipher.decrypt(enc_message[AES.block_size:]))
|
||||
return self._unpad(cipher.decrypt(enc_message[AES.block_size:]).decode())
|
||||
|
||||
|
||||
encryptor = Encryptor()
|
||||
|
|
|
@ -34,7 +34,7 @@ class LogService:
|
|||
@staticmethod
|
||||
def add_log(monkey_id, log_data, timestamp=datetime.now()):
|
||||
LogService.remove_logs_by_monkey_id(monkey_id)
|
||||
file_id = database.gridfs.put(log_data)
|
||||
file_id = database.gridfs.put(log_data, encoding='utf-8')
|
||||
return mongo.db.log.insert(
|
||||
{
|
||||
'monkey_id': monkey_id,
|
||||
|
|
|
@ -52,7 +52,7 @@ class NodeService:
|
|||
exploit["origin"] = NodeService.get_monkey_label(NodeService.get_monkey_by_id(edge["from"]))
|
||||
exploits.append(exploit)
|
||||
|
||||
exploits.sort(cmp=NodeService._cmp_exploits_by_timestamp)
|
||||
exploits.sort(key=NodeService._cmp_exploits_by_timestamp)
|
||||
|
||||
new_node["exploits"] = exploits
|
||||
new_node["accessible_from_nodes"] = accessible_from_nodes
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,16 +33,16 @@
|
|||
"babel-preset-stage-0": "^6.5.0",
|
||||
"bower-webpack-plugin": "^0.1.9",
|
||||
"chai": "^4.2.0",
|
||||
"copyfiles": "^2.1.0",
|
||||
"css-loader": "^1.0.0",
|
||||
"eslint": "^5.6.1",
|
||||
"eslint-loader": "^2.1.1",
|
||||
"eslint-plugin-react": "^7.11.1",
|
||||
"copyfiles": "^2.1.1",
|
||||
"css-loader": "^1.0.1",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-loader": "^2.2.1",
|
||||
"eslint-plugin-react": "^7.14.3",
|
||||
"file-loader": "^1.1.11",
|
||||
"glob": "^7.1.3",
|
||||
"glob": "^7.1.4",
|
||||
"html-loader": "^0.5.5",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"karma": "^3.0.0",
|
||||
"karma": "^3.1.4",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-coverage": "^1.1.2",
|
||||
"karma-mocha": "^1.0.0",
|
||||
|
@ -56,55 +56,55 @@
|
|||
"phantomjs-prebuilt": "^2.1.16",
|
||||
"react-addons-test-utils": "^15.6.2",
|
||||
"react-event-timeline": "^1.6.3",
|
||||
"react-hot-loader": "^4.3.11",
|
||||
"rimraf": "^2.6.2",
|
||||
"react-hot-loader": "^4.12.13",
|
||||
"rimraf": "^2.7.1",
|
||||
"style-loader": "^0.22.1",
|
||||
"url-loader": "^1.1.2",
|
||||
"webpack": "^4.20.2",
|
||||
"webpack-cli": "^3.1.2",
|
||||
"webpack-dev-server": "^3.1.9"
|
||||
"webpack": "^4.40.2",
|
||||
"webpack-cli": "^3.3.9",
|
||||
"webpack-dev-server": "^3.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/core": "^10.0.10",
|
||||
"@kunukn/react-collapse": "^1.0.5",
|
||||
"@emotion/core": "^10.0.17",
|
||||
"@kunukn/react-collapse": "^1.2.7",
|
||||
"bootstrap": "3.4.1",
|
||||
"classnames": "^2.2.6",
|
||||
"core-js": "^2.5.7",
|
||||
"core-js": "^2.6.9",
|
||||
"d3": "^5.11.0",
|
||||
"downloadjs": "^1.4.7",
|
||||
"fetch": "^1.1.0",
|
||||
"file-saver": "^2.0.2",
|
||||
"filepond": "^4.2.0",
|
||||
"js-file-download": "^0.4.4",
|
||||
"filepond": "^4.7.1",
|
||||
"js-file-download": "^0.4.8",
|
||||
"json-loader": "^0.5.7",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"moment": "^2.22.2",
|
||||
"moment": "^2.24.0",
|
||||
"node-sass": "^4.11.0",
|
||||
"normalize.css": "^8.0.0",
|
||||
"npm": "^6.4.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"rc-progress": "^2.2.6",
|
||||
"react": "^16.5.2",
|
||||
"npm": "^6.11.3",
|
||||
"pluralize": "^7.0.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"rc-progress": "^2.5.2",
|
||||
"react": "^16.9.0",
|
||||
"react-bootstrap": "^0.32.4",
|
||||
"react-copy-to-clipboard": "^5.0.1",
|
||||
"react-data-components": "^1.2.0",
|
||||
"react-desktop-notification": "^1.0.9",
|
||||
"react-dimensions": "^1.3.0",
|
||||
"react-dom": "^16.5.2",
|
||||
"react-dom": "^16.9.0",
|
||||
"react-fa": "^5.0.0",
|
||||
"react-filepond": "^7.0.1",
|
||||
"react-graph-vis": "^1.0.2",
|
||||
"react-json-tree": "^0.11.0",
|
||||
"react-jsonschema-form": "^1.0.5",
|
||||
"react-json-tree": "^0.11.2",
|
||||
"react-jsonschema-form": "^1.8.0",
|
||||
"react-redux": "^5.1.1",
|
||||
"react-router-dom": "^4.3.1",
|
||||
"react-spinners": "^0.5.4",
|
||||
"react-table": "^6.8.6",
|
||||
"react-spinners": "^0.5.13",
|
||||
"react-table": "^6.10.3",
|
||||
"react-toggle": "^4.0.1",
|
||||
"react-tooltip-lite": "^1.9.1",
|
||||
"redux": "^4.0.0",
|
||||
"sass-loader": "^7.1.0",
|
||||
"sha3": "^2.0.0",
|
||||
"pluralize": "^7.0.0"
|
||||
"react-tooltip-lite": "^1.10.0",
|
||||
"redux": "^4.0.4",
|
||||
"sass-loader": "^7.3.1",
|
||||
"sha3": "^2.0.7"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue