|
108 | 108 | from lib.techniques.union.test import unionTest |
109 | 109 | from lib.techniques.union.use import configUnion |
110 | 110 | from thirdparty import six |
| 111 | +from thirdparty.identywaf import identYwaf |
111 | 112 | from thirdparty.six.moves import http_client as _http_client |
112 | 113 |
|
113 | 114 | def checkSqlInjection(place, parameter, value): |
@@ -1402,116 +1403,51 @@ def checkWaf(): |
1402 | 1403 | kb.resendPostOnRedirect = popValue() |
1403 | 1404 | kb.redirectChoice = popValue() |
1404 | 1405 |
|
| 1406 | + # TODO: today |
1405 | 1407 | if retVal: |
1406 | | - warnMsg = "heuristics detected that the target " |
1407 | | - warnMsg += "is protected by some kind of WAF/IPS" |
1408 | | - logger.critical(warnMsg) |
1409 | | - |
1410 | | - if not conf.identifyWaf: |
1411 | | - message = "do you want sqlmap to try to detect backend " |
1412 | | - message += "WAF/IPS? [y/N] " |
1413 | | - |
1414 | | - if readInput(message, default='N', boolean=True): |
1415 | | - conf.identifyWaf = True |
1416 | | - |
1417 | | - if conf.timeout == defaults.timeout: |
1418 | | - logger.warning("dropping timeout to %d seconds (i.e. '--timeout=%d')" % (IDS_WAF_CHECK_TIMEOUT, IDS_WAF_CHECK_TIMEOUT)) |
1419 | | - conf.timeout = IDS_WAF_CHECK_TIMEOUT |
1420 | | - |
1421 | | - hashDBWrite(HASHDB_KEYS.CHECK_WAF_RESULT, retVal, True) |
1422 | | - |
1423 | | - return retVal |
1424 | | - |
1425 | | -@stackedmethod |
1426 | | -def identifyWaf(): |
1427 | | - if not conf.identifyWaf: |
1428 | | - return None |
1429 | | - |
1430 | | - if not kb.wafFunctions: |
1431 | | - setWafFunctions() |
1432 | | - |
1433 | | - kb.testMode = True |
1434 | | - |
1435 | | - infoMsg = "using WAF scripts to detect " |
1436 | | - infoMsg += "backend WAF/IPS protection" |
1437 | | - logger.info(infoMsg) |
1438 | | - |
1439 | | - @cachedmethod |
1440 | | - def _(*args, **kwargs): |
1441 | | - page, headers, code = None, None, None |
1442 | | - try: |
1443 | | - pushValue(kb.redirectChoice) |
1444 | | - pushValue(kb.resendPostOnRedirect) |
1445 | | - |
1446 | | - kb.redirectChoice = REDIRECTION.YES |
1447 | | - kb.resendPostOnRedirect = True |
1448 | | - |
1449 | | - if kwargs.get("get"): |
1450 | | - kwargs["get"] = urlencode(kwargs["get"]) |
1451 | | - kwargs["raise404"] = False |
1452 | | - kwargs["silent"] = True |
1453 | | - kwargs["finalCode"] = True |
1454 | | - |
1455 | | - page, headers, code = Request.getPage(*args, **kwargs) |
1456 | | - except Exception: |
1457 | | - pass |
1458 | | - finally: |
1459 | | - kb.resendPostOnRedirect = popValue() |
1460 | | - kb.redirectChoice = popValue() |
| 1408 | + pass |
| 1409 | + # identYwaf |
| 1410 | + #if conf.timeout == defaults.timeout: |
| 1411 | + #logger.warning("dropping timeout to %d seconds (i.e. '--timeout=%d')" % (IDS_WAF_CHECK_TIMEOUT, IDS_WAF_CHECK_TIMEOUT)) |
| 1412 | + #conf.timeout = IDS_WAF_CHECK_TIMEOUT |
1461 | 1413 |
|
1462 | | - return page or "", headers or {}, code |
| 1414 | + # identYwaf |
1463 | 1415 |
|
1464 | | - retVal = [] |
| 1416 | + #def _(*args, **kwargs): |
| 1417 | + #page, headers, code = None, None, None |
| 1418 | + #try: |
| 1419 | + #pushValue(kb.redirectChoice) |
| 1420 | + #pushValue(kb.resendPostOnRedirect) |
1465 | 1421 |
|
1466 | | - for function, product in kb.wafFunctions: |
1467 | | - if retVal and "unknown" in product.lower(): |
1468 | | - continue |
| 1422 | + #kb.redirectChoice = REDIRECTION.YES |
| 1423 | + #kb.resendPostOnRedirect = True |
1469 | 1424 |
|
1470 | | - try: |
1471 | | - logger.debug("checking for WAF/IPS product '%s'" % product) |
1472 | | - found = function(_) |
1473 | | - except Exception as ex: |
1474 | | - errMsg = "exception occurred while running " |
1475 | | - errMsg += "WAF script for '%s' ('%s')" % (product, getSafeExString(ex)) |
1476 | | - logger.critical(errMsg) |
| 1425 | + #if kwargs.get("get"): |
| 1426 | + #kwargs["get"] = urlencode(kwargs["get"]) |
| 1427 | + #kwargs["raise404"] = False |
| 1428 | + #kwargs["silent"] = True |
| 1429 | + #kwargs["finalCode"] = True |
1477 | 1430 |
|
1478 | | - found = False |
| 1431 | + #page, headers, code = Request.getPage(*args, **kwargs) |
| 1432 | + #except Exception: |
| 1433 | + #pass |
| 1434 | + #finally: |
| 1435 | + #kb.resendPostOnRedirect = popValue() |
| 1436 | + #kb.redirectChoice = popValue() |
1479 | 1437 |
|
1480 | | - if found: |
1481 | | - errMsg = "WAF/IPS identified as '%s'" % product |
1482 | | - logger.critical(errMsg) |
1483 | 1438 |
|
1484 | | - retVal.append(product) |
| 1439 | + #message = "are you sure that you want to " |
| 1440 | + #message += "continue with further target testing? [y/N] " |
| 1441 | + #choice = readInput(message, default='N', boolean=True) |
1485 | 1442 |
|
1486 | | - if retVal: |
1487 | | - if kb.wafSpecificResponse and "You don't have permission to access" not in kb.wafSpecificResponse and len(retVal) == 1 and "unknown" in retVal[0].lower(): |
1488 | | - handle, filename = tempfile.mkstemp(prefix=MKSTEMP_PREFIX.SPECIFIC_RESPONSE) |
1489 | | - os.close(handle) |
1490 | | - with openFile(filename, "w+b") as f: |
1491 | | - f.write(kb.wafSpecificResponse) |
1492 | | - |
1493 | | - message = "WAF/IPS specific response can be found in '%s'. " % filename |
1494 | | - message += "If you know the details on used protection please " |
1495 | | - message += "report it along with specific response " |
1496 | | - message += "to '%s'" % DEV_EMAIL_ADDRESS |
1497 | | - logger.warn(message) |
1498 | | - |
1499 | | - message = "are you sure that you want to " |
1500 | | - message += "continue with further target testing? [y/N] " |
1501 | | - choice = readInput(message, default='N', boolean=True) |
1502 | | - |
1503 | | - if not conf.tamper: |
1504 | | - warnMsg = "please consider usage of tamper scripts (option '--tamper')" |
1505 | | - singleTimeWarnMessage(warnMsg) |
| 1443 | + #if not conf.tamper: |
| 1444 | + #warnMsg = "please consider usage of tamper scripts (option '--tamper')" |
| 1445 | + #singleTimeWarnMessage(warnMsg) |
1506 | 1446 |
|
1507 | | - if not choice: |
1508 | | - raise SqlmapUserQuitException |
1509 | | - else: |
1510 | | - warnMsg = "WAF/IPS product hasn't been identified" |
1511 | | - logger.warn(warnMsg) |
| 1447 | + #if not choice: |
| 1448 | + #raise SqlmapUserQuitException |
1512 | 1449 |
|
1513 | | - kb.testType = None |
1514 | | - kb.testMode = False |
| 1450 | + hashDBWrite(HASHDB_KEYS.CHECK_WAF_RESULT, retVal, True) |
1515 | 1451 |
|
1516 | 1452 | return retVal |
1517 | 1453 |
|
@@ -1666,6 +1602,3 @@ def checkInternet(): |
1666 | 1602 |
|
1667 | 1603 | def setVerbosity(): # Cross-referenced function |
1668 | 1604 | raise NotImplementedError |
1669 | | - |
1670 | | -def setWafFunctions(): # Cross-referenced function |
1671 | | - raise NotImplementedError |
0 commit comments