Comment démarrer OWASP ZAP proxy avec Chrome webdriver et java?


Je télécharge aujourd'hui (13-05-2020) un nouveau ZAP OWASP. Je régénère le certificat CA racine. Je configure le proxy local en localhost: 8092

entrez la description de l'image ici

Après l'exécution d'un code java simple:

public static void main(String[] args) throws InterruptedException {

    Proxy proxy = new Proxy();
    proxy.setAutodetect(false);
    proxy.setHttpProxy("localhost:8092");
    proxy.setSslProxy("localhost:8092");

    final OperatingSystem currentOperatingSystem = OperatingSystem.getCurrentOperatingSystem();
    String pathWebdriver = String.format("src/test/resources/drivers/%s/googlechrome/%s/chromedriver%s", currentOperatingSystem.getOperatingSystemDir(),
            SystemArchitecture.getCurrentSystemArchitecture().getSystemArchitectureName(), currentOperatingSystem.getSuffixBinary());

    if (!new File(pathWebdriver).setExecutable(true)) {
        logger.error("ERROR when change setExecutable on " + pathWebdriver);
    }

    System.setProperty("webdriver.chrome.driver", pathWebdriver);
    final ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("--ignore-certificate-errors");

    chromeOptions.setCapability(CapabilityType.PROXY, proxy);
    chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
    chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);

    WebDriver driver = new ChromeDriver(chromeOptions);
    for (int i = 0; i < 6; i++) {
        //driver.get("http://www.google.com/ncr");

        // www.google.com work (OWASP ZAP list all requests) but not localhost
        driver.get("http://localhost:8080/ui");

    }
    driver.quit();
}

Le script Selenium fonctionne bien mais OWASP ZAP n'intercepte aucune requête.

entrez la description de l'image ici

Author: Stéphane GRILLON, 2020-05-13

1 answers

Vous devrez vous assurer d'inclure les détails du proxy SSL (à côté des détails HttpProxy), ex: proxy.setSslProxy("<proxy-host>:<proxy-port>");, ou plus précisément proxy.setSslProxy("localhost:8092"); pour votre code

Pour pouvoir proxy localhost dans les versions modernes de Chrome, vous devez supprimer le bouclage de la liste de contournement du proxy comme suit: --proxy-bypass-list=<-loopback>, ou dans votre code spécifique: chromeOptions.addArguments("--proxy-bypass-list=<-loopback>");

Vous pouvez également envisager d'ajouter: chromeOptions.addArguments("--ignore-certificate-errors");

 0
Author: kingthorin, 2020-05-15 09:39:28