Define a configuration parameter if we are running in multiple target mode.
()
| 216 | queries[node.attrib['value']] = iterate(node) |
| 217 | |
| 218 | def _setMultipleTargets(): |
| 219 | """ |
| 220 | Define a configuration parameter if we are running in multiple target |
| 221 | mode. |
| 222 | """ |
| 223 | |
| 224 | initialTargetsCount = len(kb.targets) |
| 225 | seen = set() |
| 226 | |
| 227 | if not conf.logFile: |
| 228 | return |
| 229 | |
| 230 | debugMsg = "parsing targets list from '%s'" % conf.logFile |
| 231 | logger.debug(debugMsg) |
| 232 | |
| 233 | if not os.path.exists(conf.logFile): |
| 234 | errMsg = "the specified list of targets does not exist" |
| 235 | raise SqlmapFilePathException(errMsg) |
| 236 | |
| 237 | if checkFile(conf.logFile, False): |
| 238 | for target in parseRequestFile(conf.logFile): |
| 239 | url, _, data, _, _ = target |
| 240 | key = re.sub(r"(\w+=)[^%s ]*" % (conf.paramDel or DEFAULT_GET_POST_DELIMITER), r"\g<1>", "%s %s" % (url, data)) |
| 241 | if key not in seen: |
| 242 | kb.targets.add(target) |
| 243 | seen.add(key) |
| 244 | |
| 245 | elif os.path.isdir(conf.logFile): |
| 246 | files = os.listdir(conf.logFile) |
| 247 | files.sort() |
| 248 | |
| 249 | for reqFile in files: |
| 250 | if not re.search(r"([\d]+)\-request", reqFile): |
| 251 | continue |
| 252 | |
| 253 | for target in parseRequestFile(os.path.join(conf.logFile, reqFile)): |
| 254 | url, _, data, _, _ = target |
| 255 | key = re.sub(r"(\w+=)[^%s ]*" % (conf.paramDel or DEFAULT_GET_POST_DELIMITER), r"\g<1>", "%s %s" % (url, data)) |
| 256 | if key not in seen: |
| 257 | kb.targets.add(target) |
| 258 | seen.add(key) |
| 259 | |
| 260 | else: |
| 261 | errMsg = "the specified list of targets is not a file " |
| 262 | errMsg += "nor a directory" |
| 263 | raise SqlmapFilePathException(errMsg) |
| 264 | |
| 265 | updatedTargetsCount = len(kb.targets) |
| 266 | |
| 267 | if updatedTargetsCount > initialTargetsCount: |
| 268 | infoMsg = "sqlmap parsed %d " % (updatedTargetsCount - initialTargetsCount) |
| 269 | infoMsg += "(parameter unique) requests from the " |
| 270 | infoMsg += "targets list ready to be tested" |
| 271 | logger.info(infoMsg) |
| 272 | |
| 273 | def _adjustLoggingFormatter(): |
| 274 | """ |
no test coverage detected
searching dependent graphs…