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)
| 1088 | logger.error(errMsg) |
| 1089 | |
| 1090 | def 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 | |
| 1127 | def readInput(message, default=None, checkBatch=True, boolean=False): |
| 1128 | """ |
no test coverage detected
searching dependent graphs…