I am trying to execute the code but not able to run the same - Can I know the solution for the same?
public class AjaxSpider {
private static final int ZAP_PORT = 8080;
private static final String ZAP_API_KEY = null;
private static final String ZAP_ADDRESS = "localhost";
private static final String TARGET = "
https://public-firing-range.appspot.com";
public static void main(String[] args) {
// Create the ZAP Client
ClientApi api = new ClientApi(ZAP_ADDRESS, ZAP_PORT, ZAP_API_KEY);
try {
// Start spidering the target
System.out.println("Ajax Spider target : " + TARGET);
ApiResponse
resp = api.ajaxSpider.scan(TARGET, null, null, null);
String status;
long startTime = System.currentTimeMillis();
long timeout = TimeUnit.MINUTES.toMillis(2); // Two minutes in milli seconds
// Loop until the ajax spider has finished or the timeout has exceeded
while (true) {
Thread.sleep(2000);
status = (((ApiResponseElement) api.ajaxSpider.status()).getValue());
System.out.println("Spider status : " + status);
if (!("stopped".equals(status)) || (System.currentTimeMillis() - startTime) < timeout) {
break;
}
}
System.out.println("Ajax Spider completed");
// Perform additional operations with the Ajax Spider results
List<ApiResponse> ajaxSpiderResponse = ((ApiResponseList) api.ajaxSpider.results("0", "10")).getItems();
// TODO: Start scanning(passive/active scan) the application to find vulnerabilities
} catch (Exception e) {
System.out.println("Exception : " + e.getMessage());
e.printStackTrace();
}
}
}