Skip to content

Commit 8096a37

Browse files
committed
Major bug fix in --read-file option and minor code refactoring.
1 parent cb3d2ba commit 8096a37

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

plugins/generic/filesystem.py

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -48,41 +48,21 @@ def __init__(self):
4848

4949

5050
def __unbase64String(self, base64Str):
51-
unbase64Str = ""
52-
53-
if isinstance(base64Str, (list, tuple, set)):
54-
for chunk in base64Str:
55-
if isinstance(chunk, (list, tuple, set)):
56-
chunk = chunk[0]
57-
58-
unbase64Str += "%s\n" % chunk.decode("base64")
59-
else:
60-
unbase64Str = "%s\n" % base64Str.decode("base64")
51+
unbase64Str = "%s\n" % base64Str.decode("base64")
6152

6253
return unbase64Str
6354

6455

6556
def __unhexString(self, hexStr):
66-
unhexStr = ""
67-
68-
if ( len(hexStr) % 2 ) != 0:
57+
if len(hexStr) % 2 != 0:
6958
errMsg = "for some reasons sqlmap retrieved an odd-length "
7059
errMsg += "hexadecimal string which it is not able to convert "
7160
errMsg += "to raw string"
7261
logger.error(errMsg)
7362

7463
return hexStr
7564

76-
if isinstance(hexStr, (list, tuple, set)):
77-
for chunk in hexStr:
78-
if isinstance(chunk, (list, tuple, set)):
79-
chunk = chunk[0]
80-
81-
unhexStr += binascii.unhexlify(chunk)
82-
else:
83-
unhexStr = binascii.unhexlify(hexStr)
84-
85-
return unhexStr
65+
return binascii.unhexlify(hexStr)
8666

8767

8868
def __binDataToScr(self, binaryData, chunkName):
@@ -301,10 +281,20 @@ def readFile(self, rFile):
301281

302282
fileContent = self.stackedReadFile(rFile)
303283

304-
if fileContent == None:
284+
if fileContent in ( None, "" ):
305285
self.cleanup(onlyFileTbl=True)
306286

307287
return
288+
elif isinstance(fileContent, (list, tuple, set)):
289+
newFileContent = ""
290+
291+
for chunk in fileContent:
292+
if isinstance(chunk, (list, tuple, set)):
293+
chunk = chunk[0]
294+
295+
newFileContent += chunk
296+
297+
fileContent = newFileContent
308298

309299
if kb.dbms in ( "MySQL", "Microsoft SQL Server" ):
310300
fileContent = self.__unhexString(fileContent)

0 commit comments

Comments
 (0)