allow network scans for non-standard http/https ports

pull/402/head
Michael Peter Christen 4 years ago
parent 022fb15670
commit 5a7f12a9c1

@ -60,10 +60,10 @@
</dd>
<dt>Service Type</dt>
<dd>
<input type="checkbox" name="scanftp" checked="checked" />ftp
<input type="checkbox" name="scansmb" checked="checked" />smb
<input type="checkbox" name="scanhttp" />http
<input type="checkbox" name="scanhttps" />https
<input type="checkbox" name="scanftp" checked="checked" />ftp&nbsp;
<input type="checkbox" name="scansmb" checked="checked" />smb&nbsp;
<input type="checkbox" name="scanhttp" />http&nbsp;<input type="number" name="scanhttpport" value="80" size="5" min="0" max="65535" />&nbsp;
<input type="checkbox" name="scanhttps" />https&nbsp;<input type="number" name="scanhttpsport" value="443" size="5" min="0" max="65535" />
</dd>
<dt>Scheduler</dt>

@ -49,8 +49,7 @@ import net.yacy.search.schema.CollectionSchema;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
public class CrawlStartScanner_p
{
public class CrawlStartScanner_p {
private final static int CONCURRENT_RUNNER = 200;
@ -99,22 +98,22 @@ public class CrawlStartScanner_p
hostSet.add(ip.getHostAddress());
}
} else {
final Set<InetAddress> myPublicIPs = new HashSet<InetAddress>();
myPublicIPs.addAll(Domains.myPublicIPv4());
myPublicIPs.addAll(Domains.myPublicIPv6());
for(final InetAddress myPublicIP: myPublicIPs) {
final Set<InetAddress> myPublicIPs = new HashSet<InetAddress>();
myPublicIPs.addAll(Domains.myPublicIPv4());
myPublicIPs.addAll(Domains.myPublicIPv6());
for(final InetAddress myPublicIP: myPublicIPs) {
if (Domains.isThisHostIP(myPublicIP)) {
final Set<String> myIPs = sb.peers.mySeed().getIPs();
for(final String myIP: myIPs) {
final Set<String> myIPs = sb.peers.mySeed().getIPs();
for(final String myIP: myIPs) {
ip = Domains.dnsResolve(myIP);
if(ip != null) {
hostSet.add(ip.getHostAddress());
hostSet.add(ip.getHostAddress());
}
}
}
} else {
hostSet.add(myPublicIP.getHostAddress());
}
}
}
}
}
String hos = ""; for (String s: hostSet) hos += s + "\n";
@ -151,7 +150,9 @@ public class CrawlStartScanner_p
final Scanner scanner = new Scanner(CONCURRENT_RUNNER, timeout);
boolean scanhttp = "on".equals(post.get("scanhttp", ""));
int scanhttpport = post.getInt("scanhttpport", 80);
boolean scanhttps = "on".equals(post.get("scanhttps", ""));
int scanhttpsport = post.getInt("scanhttpsport", 443);
boolean scanftp = "on".equals(post.get("scanftp", ""));
boolean scansmb = "on".equals(post.get("scansmb", ""));
@ -187,11 +188,11 @@ public class CrawlStartScanner_p
if (ip != null) scanbase.add(ip);
}
}
scanner.addProtocols(Scanner.genlist(scanbase, subnet), scanhttp, scanhttps, scanftp, scansmb);
scanner.addProtocols(Scanner.genlist(scanbase, subnet), scanhttp, scanhttpport, scanhttps, scanhttpsport, scanftp, scansmb);
}
}
if ("intranet".equals(post.get("source", ""))) {
scanner.addProtocols(Scanner.genlist(Domains.myIntranetIPs(), subnet), scanhttp, scanhttps, scanftp, scansmb);
scanner.addProtocols(Scanner.genlist(Domains.myIntranetIPs(), subnet), scanhttp, scanhttpport, scanhttps, scanhttpsport, scanftp, scansmb);
}
scanner.terminate();

@ -56,6 +56,7 @@ public class Scanner {
public static enum Protocol {http(80), https(443), ftp(21), smb(445);
public int port;
private Protocol(final int port) {this.port = port;}
public Protocol setPort(int port) {this.port = port; return this;}
}
public class Service implements Runnable {
public Protocol protocol;
@ -228,9 +229,9 @@ public class Scanner {
this.threadPool.shutdown();
}
public void addProtocols(final List<InetAddress> addresses, boolean http, boolean https, boolean ftp, boolean smb) {
if (http) addProtocol(Protocol.http, addresses);
if (https) addProtocol(Protocol.https, addresses);
public void addProtocols(final List<InetAddress> addresses, boolean http, int httpPort, boolean https, int httpsPort, boolean ftp, boolean smb) {
if (http) addProtocol(Protocol.http.setPort(httpPort), addresses);
if (https) addProtocol(Protocol.https.setPort(httpsPort), addresses);
if (ftp) addProtocol(Protocol.ftp, addresses);
if (smb) addProtocol(Protocol.smb, addresses);
}
@ -294,7 +295,7 @@ public class Scanner {
//try {System.out.println("192.168.1.91: " + ping(new MultiProtocolURI("smb://192.168.1.91/"), 1000));} catch (final MalformedURLException e) {}
final Scanner scanner = new Scanner(100, 10);
List<InetAddress> addresses = genlist(Domains.myIntranetIPs(), 20);
scanner.addProtocols(addresses, true, true, true, true);
scanner.addProtocols(addresses, true, 80, true, 443, true, true);
scanner.terminate();
for (final Service service: scanner.services().keySet()) {
System.out.println(service.toString());

Loading…
Cancel
Save