mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
#193 return found port number from HTTPProxyFetcher
This commit is contained in:
parent
a93ee86acb
commit
cfef765dac
@ -9,6 +9,7 @@ package net.azib.ipscan.fetchers;
|
||||
import net.azib.ipscan.config.ScannerConfig;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* HTTPProxyFetcher - detects HTTP proxy on port 3128 (or other requested port)
|
||||
@ -24,4 +25,9 @@ public class HTTPProxyFetcher extends PortTextFetcher {
|
||||
public String getId() {
|
||||
return "fetcher.httpProxy";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getResult(Matcher matcher, int port) {
|
||||
return port + ": " + super.getResult(matcher, port);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ public abstract class PortTextFetcher extends AbstractFetcher {
|
||||
public PortTextFetcher(ScannerConfig scannerConfig, int defaultPort, String textToSend, String matchingRegexp) {
|
||||
this.scannerConfig = scannerConfig;
|
||||
this.defaultPort = defaultPort;
|
||||
this.scanOpenPorts = scanOpenPorts;
|
||||
this.textToSend = getPreferences().get("textToSend", textToSend);
|
||||
this.matchingRegexp = Pattern.compile(getPreferences().get("matchingRegexp", matchingRegexp));
|
||||
this.extractGroup = getPreferences().getInt("extractGroup", 1);
|
||||
@ -72,7 +71,7 @@ public abstract class PortTextFetcher extends AbstractFetcher {
|
||||
// mark that additional info is available
|
||||
subject.setResultType(ResultType.WITH_PORTS);
|
||||
// return the required contents
|
||||
return matcher.group(extractGroup);
|
||||
return getResult(matcher, socket.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,6 +91,11 @@ public abstract class PortTextFetcher extends AbstractFetcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getResult(Matcher matcher, int port) {
|
||||
String result = matcher.group(extractGroup);
|
||||
return result.isEmpty() ? String.valueOf(port) : result;
|
||||
}
|
||||
|
||||
private Iterator<Integer> getPortIterator(ScanningSubject subject) {
|
||||
if (scanOpenPorts) {
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user