From 3822c1e934db29c57c7cedaaf1e49f5bc4aca20d Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 1 Oct 2020 15:40:08 +0200 Subject: [PATCH] Fix remote exploit - fixes the exploit so that 0.6.2 can be used in tests --- src/messagetypes/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/messagetypes/__init__.py b/src/messagetypes/__init__.py index c3911dfd..e116fa79 100644 --- a/src/messagetypes/__init__.py +++ b/src/messagetypes/__init__.py @@ -3,8 +3,10 @@ from os import path, listdir from string import lower from debug import logger +import messagetypes import paths + class MsgBase(object): def encode(self): self.data = {"": lower(type(self).__name__)} @@ -12,8 +14,8 @@ class MsgBase(object): def constructObject(data): try: - classBase = eval(data[""] + "." + data[""].title()) - except NameError: + classBase = getattr(getattr(messagetypes, data[""]), data[""].title()) + except (NameError, AttributeError): logger.error("Don't know how to handle message type: \"%s\"", data[""]) return None try: @@ -39,7 +41,7 @@ else: if splitted[1] != ".py": continue try: - import_module("." + splitted[0], "messagetypes") + import_module(".{}".format(splitted[0]), "messagetypes") except ImportError: logger.error("Error importing %s", mod, exc_info=True) else: