diff --git a/lib/core/common.py b/lib/core/common.py index ca63be94e..8708f47c5 100755 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -872,7 +872,7 @@ def dataToOutFile(filename, data): retVal = os.path.join(conf.filePath, filePathToSafeString(filename)) try: - with openFile(retVal, "wb") as f: + with open(retVal, "w+b") as f: f.write(data) except IOError, ex: errMsg = "something went wrong while trying to write " @@ -3714,7 +3714,7 @@ def applyFunctionRecursively(value, function): return retVal -def decodeHexValue(value): +def decodeHexValue(value, raw=False): """ Returns value decoded from DBMS specific hexadecimal representation @@ -3729,7 +3729,7 @@ def decodeHexValue(value): if value and isinstance(value, basestring) and len(value) % 2 == 0: retVal = hexdecode(retVal) - if not kb.binaryField: + if not kb.binaryField and not raw: if Backend.isDbms(DBMS.MSSQL) and value.startswith("0x"): try: retVal = retVal.decode("utf-16-le") diff --git a/plugins/generic/filesystem.py b/plugins/generic/filesystem.py index b069eabfe..0ff2a4a2c 100644 --- a/plugins/generic/filesystem.py +++ b/plugins/generic/filesystem.py @@ -232,7 +232,7 @@ class Filesystem: fileContent = newFileContent if fileContent is not None: - fileContent = decodeHexValue(fileContent) + fileContent = decodeHexValue(fileContent, True) if fileContent: localFilePath = dataToOutFile(remoteFile, fileContent)