|
25 | 25 | from lib.core.enums import EXPECTED |
26 | 26 | from lib.core.enums import PAYLOAD |
27 | 27 | from lib.core.exception import SqlmapUndefinedMethod |
| 28 | +from lib.core.settings import UNICODE_ENCODING |
28 | 29 | from lib.request import inject |
29 | 30 |
|
30 | 31 | class Filesystem: |
@@ -112,7 +113,7 @@ def fileEncode(self, fileName, encoding, single): |
112 | 113 | """ |
113 | 114 |
|
114 | 115 | retVal = [] |
115 | | - with codecs.open(fileName, "rb") as f: |
| 116 | + with codecs.open(fileName, "rb", UNICODE_ENCODING) as f: |
116 | 117 | content = f.read().encode(encoding).replace("\n", "") |
117 | 118 |
|
118 | 119 | if not single: |
@@ -230,19 +231,24 @@ def readFile(self, remoteFiles): |
230 | 231 |
|
231 | 232 | if fileContent is not None: |
232 | 233 | fileContent = decodeHexValue(fileContent) |
233 | | - localFilePath = dataToOutFile(remoteFile, fileContent) |
234 | 234 |
|
235 | | - if not Backend.isDbms(DBMS.PGSQL): |
236 | | - self.cleanup(onlyFileTbl=True) |
| 235 | + if fileContent: |
| 236 | + localFilePath = dataToOutFile(remoteFile, fileContent) |
237 | 237 |
|
238 | | - sameFile = self.askCheckReadFile(localFilePath, remoteFile) |
| 238 | + if not Backend.isDbms(DBMS.PGSQL): |
| 239 | + self.cleanup(onlyFileTbl=True) |
239 | 240 |
|
240 | | - if sameFile is True: |
241 | | - localFilePath += " (same file)" |
242 | | - elif sameFile is False: |
243 | | - localFilePath += " (size differs from remote file)" |
| 241 | + sameFile = self.askCheckReadFile(localFilePath, remoteFile) |
244 | 242 |
|
245 | | - localFilePaths.append(localFilePath) |
| 243 | + if sameFile is True: |
| 244 | + localFilePath += " (same file)" |
| 245 | + elif sameFile is False: |
| 246 | + localFilePath += " (size differs from remote file)" |
| 247 | + |
| 248 | + localFilePaths.append(localFilePath) |
| 249 | + else: |
| 250 | + errMsg = "no data retrieved" |
| 251 | + logger.error(errMsg) |
246 | 252 |
|
247 | 253 | return localFilePaths |
248 | 254 |
|
|
0 commit comments