(suppressOutput=False)
| 1470 | return kb.nullConnection in getPublicTypeMembers(NULLCONNECTION, True) |
| 1471 | |
| 1472 | def checkConnection(suppressOutput=False): |
| 1473 | threadData = getCurrentThreadData() |
| 1474 | |
| 1475 | if not re.search(r"\A\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\Z", conf.hostname): |
| 1476 | if not any((conf.proxy, conf.tor, conf.dummy, conf.offline)): |
| 1477 | try: |
| 1478 | debugMsg = "resolving hostname '%s'" % conf.hostname |
| 1479 | logger.debug(debugMsg) |
| 1480 | socket.getaddrinfo(conf.hostname, None) |
| 1481 | except socket.gaierror: |
| 1482 | errMsg = "host '%s' does not exist" % conf.hostname |
| 1483 | raise SqlmapConnectionException(errMsg) |
| 1484 | except socket.error as ex: |
| 1485 | errMsg = "problem occurred while " |
| 1486 | errMsg += "resolving a host name '%s' ('%s')" % (conf.hostname, getSafeExString(ex)) |
| 1487 | raise SqlmapConnectionException(errMsg) |
| 1488 | except UnicodeError as ex: |
| 1489 | errMsg = "problem occurred while " |
| 1490 | errMsg += "handling a host name '%s' ('%s')" % (conf.hostname, getSafeExString(ex)) |
| 1491 | raise SqlmapDataException(errMsg) |
| 1492 | |
| 1493 | if not suppressOutput and not conf.dummy and not conf.offline: |
| 1494 | infoMsg = "testing connection to the target URL" |
| 1495 | logger.info(infoMsg) |
| 1496 | |
| 1497 | try: |
| 1498 | kb.originalPageTime = time.time() |
| 1499 | page, headers, _ = Request.queryPage(content=True, noteResponseTime=False) |
| 1500 | |
| 1501 | rawResponse = "%s%s" % (listToStrValue(headers.headers if headers else ""), page) |
| 1502 | |
| 1503 | if conf.string: |
| 1504 | infoMsg = "testing if the provided string is within the " |
| 1505 | infoMsg += "target URL page content" |
| 1506 | logger.info(infoMsg) |
| 1507 | |
| 1508 | if conf.string not in rawResponse: |
| 1509 | warnMsg = "you provided '%s' as the string to " % conf.string |
| 1510 | warnMsg += "match, but such a string is not within the target " |
| 1511 | warnMsg += "URL raw response, sqlmap will carry on anyway" |
| 1512 | logger.warning(warnMsg) |
| 1513 | |
| 1514 | if conf.regexp: |
| 1515 | infoMsg = "testing if the provided regular expression matches within " |
| 1516 | infoMsg += "the target URL page content" |
| 1517 | logger.info(infoMsg) |
| 1518 | |
| 1519 | if not re.search(conf.regexp, rawResponse, re.I | re.M): |
| 1520 | warnMsg = "you provided '%s' as the regular expression " % conf.regexp |
| 1521 | warnMsg += "which does not have any match within the target URL raw response. sqlmap " |
| 1522 | warnMsg += "will carry on anyway" |
| 1523 | logger.warning(warnMsg) |
| 1524 | |
| 1525 | kb.errorIsNone = False |
| 1526 | |
| 1527 | if any(_ in (kb.serverHeader or "") for _ in PRECONNECT_INCOMPATIBLE_SERVERS): |
| 1528 | singleTimeWarnMessage("turning off pre-connect mechanism because of incompatible server ('%s')" % kb.serverHeader) |
| 1529 | conf.disablePrecon = True |
no test coverage detected
searching dependent graphs…