2016-08-18 6 views
0

Ich versuche Active Scan mit ZAP-Proxy zu tun. Der Code sieht wie folgt aus:Wie scannen (ascan) mehrere URLs

// /spider/action/scan/ and wait till it finishes 
int scanId = StartScanning(clientApi, API_KEY, "https://contosco.com/Home.aspx"); 
PollTheSpiderTillCompletion(clientApi, scanId); 

// /ascan/action/scan/ and wait till it finishes 
int activeScanId = StartActiveScanning(clientApi, API_KEY, "https://contosco.com/Home.aspx"); 
PollTheActiveScannerTillCompletion(clientApi, activeScanId); 

Die Spinne durchläuft alle URLs in der Anwendung ordnungsgemäß. Der aktive Scan trifft jedoch nur die erste URL und stoppt. Gibt es eine Möglichkeit, alle URLs aktiv zu scannen (oder sollte ich zuerst den Spider-Report bekommen und dann durch den Spider Report iterieren und jede einzelne URL aus dem Spider-Report abfragen)?

Voll Quelle:

private static int StartScanning(ClientApi api, string apiKey, string url) 
{ 
    var apiResponse = api.spider.scan(apiKey, url, ""); 
    string scanid = ((ApiResponseElement)apiResponse).Value; 
    return int.Parse(scanid); 
} 

private static int StartActiveScanning(ClientApi api, string apiKey, string url) 
{ 
    var apiResponse = api.ascan.scan(apiKey, url, "true", "", "", "", ""); 
    string activeScanId = ((ApiResponseElement)apiResponse).Value; 
    return int.Parse(activeScanId); 
} 

private static void PollTheSpiderTillCompletion(ClientApi api, int scanid) 
{ 
    int spiderProgress; 
    while (true) 
    { 
    Thread.Sleep(1000); 
    spiderProgress = int.Parse(((ApiResponseElement)api.spider.status(Convert.ToString(scanid))).Value); 
    if (spiderProgress >= 100) 
     break; 
    } 

    Thread.Sleep(10000); 
} 

private static void PollTheActiveScannerTillCompletion(ClientApi api, int activeScanId) 
{ 
    int activeScannerprogress; 
    while (true) 
    { 
    Thread.Sleep(5000); 
    activeScannerprogress = int.Parse(((ApiResponseElement)api.ascan.status(Convert.ToString(activeScanId))).Value); 
    if (activeScannerprogress >= 100) 
     break; 
    } 
} 

Antwort

0

Welche Client-Bibliothek verwenden Sie?

Sie sollten warten, bis die Spinne abgeschlossen ist, aber "PollTheSpiderTillCompletion" bedeutet, dass passiert.

In der zugrunde liegenden ZAP-API müssen Sie angeben, ob der aktive Scanner auf die untergeordneten Seiten rekursiv sein soll oder nicht. Ich vermute, dass Ihr Code das nicht tut, aber ich erkenne diese API nicht, also weiß ich nicht, ob sie funktioniert.

+0

Ich benutze die .NET API (obwohl das wirklich egal ist :)) Ich habe die recurse auf wahr gesetzt. Ich denke, ich habe das Problem gelöst - die Ascan Recurse-URL war https://contosco.com/Home.aspx (Root-URL für Spider) und sollte https://contosco.com (nur der Domain-Root) sein. –

+0

Froh, dass es jetzt sortiert ist :) –