mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
Some new fetchers:
* PortTextFetcher - generic fetcher for fetching some text from ports * WebDetectFetcher - uses PortTextFetcher for detecting the web servers * LastAliveTimeFetcher - another not yet implemented fetcher git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@158 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
e6e04d5c5f
commit
96da49de99
@ -24,6 +24,7 @@ import net.azib.ipscan.fetchers.IPFetcher;
|
||||
import net.azib.ipscan.fetchers.PingFetcher;
|
||||
import net.azib.ipscan.fetchers.PingTTLFetcher;
|
||||
import net.azib.ipscan.fetchers.PortsFetcher;
|
||||
import net.azib.ipscan.fetchers.WebDetectFetcher;
|
||||
import net.azib.ipscan.gui.MainMenu;
|
||||
import net.azib.ipscan.gui.MainWindow;
|
||||
import net.azib.ipscan.gui.OptionsDialog;
|
||||
@ -90,6 +91,7 @@ public class ComponentRegistry {
|
||||
container.registerComponentImplementation(HostnameFetcher.class);
|
||||
container.registerComponentImplementation(PortsFetcher.class);
|
||||
container.registerComponentImplementation(FilteredPortsFetcher.class);
|
||||
container.registerComponentImplementation(WebDetectFetcher.class);
|
||||
|
||||
container.registerComponentImplementation(PingerRegistry.class, PingerRegistryImpl.class);
|
||||
container.registerComponentImplementation(ScanningResultList.class);
|
||||
|
||||
40
src/net/azib/ipscan/fetchers/LastAliveTimeFetcher.java
Normal file
40
src/net/azib/ipscan/fetchers/LastAliveTimeFetcher.java
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This file is a part of Angry IP Scanner source code,
|
||||
* see http://www.azib.net/ for more information.
|
||||
* Licensed under GPLv2.
|
||||
*/
|
||||
|
||||
package net.azib.ipscan.fetchers;
|
||||
|
||||
import net.azib.ipscan.core.ScanningSubject;
|
||||
|
||||
/**
|
||||
* LastAliveTimeFetcher
|
||||
*
|
||||
* TODO: implement LastAliveTimeFetcher
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class LastAliveTimeFetcher implements Fetcher {
|
||||
|
||||
public void cleanup() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public Object scan(ScanningSubject subject) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
92
src/net/azib/ipscan/fetchers/PortTextFetcher.java
Normal file
92
src/net/azib/ipscan/fetchers/PortTextFetcher.java
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* This file is a part of Angry IP Scanner source code,
|
||||
* see http://www.azib.net/ for more information.
|
||||
* Licensed under GPLv2.
|
||||
*/
|
||||
|
||||
package net.azib.ipscan.fetchers;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.azib.ipscan.config.GlobalConfig;
|
||||
import net.azib.ipscan.config.LoggerFactory;
|
||||
import net.azib.ipscan.core.ScanningSubject;
|
||||
|
||||
/**
|
||||
* PortTextFetcher - generic configurable fetcher to read some particular information from a port.
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class PortTextFetcher implements Fetcher {
|
||||
private static final Logger LOG = LoggerFactory.getLogger();
|
||||
|
||||
private GlobalConfig globalConfig;
|
||||
|
||||
private int port;
|
||||
private String textToSend;
|
||||
private Pattern matchingRegexp;
|
||||
|
||||
public PortTextFetcher(GlobalConfig globalConfig, int port, String textToSend, String matchingRegexp) {
|
||||
this.globalConfig = globalConfig;
|
||||
this.port = port;
|
||||
this.textToSend = textToSend;
|
||||
this.matchingRegexp = Pattern.compile(matchingRegexp);
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return "fetcher.webDetect";
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public Object scan(ScanningSubject subject) {
|
||||
Socket socket = new Socket();
|
||||
try {
|
||||
// TODO: use adapted port timeout if it is configured to do so
|
||||
socket.connect(new InetSocketAddress(subject.getIPAddress(), port), globalConfig.portTimeout);
|
||||
socket.setTcpNoDelay(true);
|
||||
socket.setSoTimeout(globalConfig.portTimeout);
|
||||
socket.setSoLinger(true, 0);
|
||||
|
||||
socket.getOutputStream().write(textToSend.getBytes());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
Matcher matcher = matchingRegexp.matcher(line);
|
||||
if (matcher.matches()) {
|
||||
// mark that additional info is available
|
||||
subject.setResultType(ScanningSubject.RESULT_TYPE_ADDITIONAL_INFO);
|
||||
// return the required contents
|
||||
return matcher.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SocketTimeoutException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.log(Level.FINE, subject.getIPAddress().toString(), e);
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException e) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
22
src/net/azib/ipscan/fetchers/WebDetectFetcher.java
Normal file
22
src/net/azib/ipscan/fetchers/WebDetectFetcher.java
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* This file is a part of Angry IP Scanner source code,
|
||||
* see http://www.azib.net/ for more information.
|
||||
* Licensed under GPLv2.
|
||||
*/
|
||||
|
||||
package net.azib.ipscan.fetchers;
|
||||
|
||||
import net.azib.ipscan.config.GlobalConfig;
|
||||
|
||||
/**
|
||||
* WebDetectFetcher - detects the Web server software running on scanned hosts.
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class WebDetectFetcher extends PortTextFetcher {
|
||||
|
||||
public WebDetectFetcher(GlobalConfig globalConfig) {
|
||||
super(globalConfig, 80, "HEAD /robots.txt HTTP/1.0\r\n\r\n", "^[Ss]erver:\\s+(.*)$");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user