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

Function dataToOutFile

lib/core/common.py:1090–1125  ·  view source on GitHub ↗

Saves data to filename >>> pushValue(conf.get("filePath")) >>> conf.filePath = tempfile.gettempdir() >>> "_etc_passwd" in dataToOutFile("/etc/passwd", b":::*") True >>> conf.filePath = popValue()

(filename, data)

Source from the content-addressed store, hash-verified

1088 logger.error(errMsg)
1089
1090def dataToOutFile(filename, data):
1091 """
1092 Saves data to filename
1093
1094 >>> pushValue(conf.get("filePath"))
1095 >>> conf.filePath = tempfile.gettempdir()
1096 >>> "_etc_passwd" in dataToOutFile("/etc/passwd", b":::*")
1097 True
1098 >>> conf.filePath = popValue()
1099 """
1100
1101 retVal = None
1102
1103 if data:
1104 while True:
1105 retVal = os.path.join(conf.filePath, filePathToSafeString(filename))
1106
1107 try:
1108 with open(retVal, "w+b") as f: # has to stay as non-codecs because data is raw ASCII encoded data
1109 f.write(getBytes(data))
1110 except UnicodeEncodeError as ex:
1111 _ = normalizeUnicode(filename)
1112 if filename != _:
1113 filename = _
1114 else:
1115 errMsg = "couldn't write to the "
1116 errMsg += "output file ('%s')" % getSafeExString(ex)
1117 raise SqlmapGenericException(errMsg)
1118 except IOError as ex:
1119 errMsg = "something went wrong while trying to write "
1120 errMsg += "to the output file ('%s')" % getSafeExString(ex)
1121 raise SqlmapGenericException(errMsg)
1122 else:
1123 break
1124
1125 return retVal
1126
1127def readInput(message, default=None, checkBatch=True, boolean=False):
1128 """

Callers 2

readFileMethod · 0.90
readFileMethod · 0.90

Calls 6

getBytesFunction · 0.90
filePathToSafeStringFunction · 0.85
normalizeUnicodeFunction · 0.85
getSafeExStringFunction · 0.70
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…