@Override
public void run() {
stopAttack = false;
try {
SiteNode startNode = null;
String urlString = url.toString();
if (startNode == null) {
startNode = this.accessNode(this.url);
}
if (startNode == null) {
logger.debug("Failed to access URL " + urlString);
extension.notifyProgress(Progress.failed);
return;
}
if (stopAttack) {
logger.debug("Attack stopped manually");
extension.notifyProgress(Progress.stopped);
return;
}
ExtensionSpider extSpider = (ExtensionSpider) Control.getSingleton().getExtensionLoader().getExtension(ExtensionSpider.NAME);
if (extSpider == null) {
logger.error("No spider");
extension.notifyProgress(Progress.failed);
return;
} else {
extension.notifyProgress(Progress.spider);
extSpider.startScan(startNode);
}
// Give some time to the spider to finish to setup and start itself.
sleep(1500);
try {
// Wait for the spider to complete
while (extSpider.isScanning(startNode, true)) {
sleep (500);
if (this.stopAttack) {
extSpider.stopScan(startNode);
break;
}
}
} catch (InterruptedException e) {
// Ignore
}
if (stopAttack) {
logger.debug("Attack stopped manually");
extension.notifyProgress(Progress.stopped);
return;
}
// Pause before the spider seems to help
sleep(2000);
if (stopAttack) {
logger.debug("Attack stopped manually");
extension.notifyProgress(Progress.stopped);
return;
}
if (startNode.isLeaf() && !((SiteNode)startNode.getParent()).isRoot()
&& !((SiteNode)startNode.getParent().getParent()).isRoot()) {
// Start node is a leaf and isnt root or a top level app (eg www.example.com/app1)
// Go up a level
startNode = (SiteNode)startNode.getParent();
}
ExtensionActiveScan extAscan = (ExtensionActiveScan) Control.getSingleton().getExtensionLoader().getExtension(ExtensionActiveScan.NAME);
if (extAscan == null) {
logger.error("No active scanner");