// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java
// public class BaRMIeIllegalArgumentException extends BaRMIeException {
// 	public BaRMIeIllegalArgumentException(String message) {
// 		super(message);
// 	}
// 	
// 	public BaRMIeIllegalArgumentException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java
// public class BaRMIeInvalidPortException extends BaRMIeException {
// 	public BaRMIeInvalidPortException(int portNumber) {
// 		super("The given port number (" + portNumber + ") is not a valid TCP port number.");
// 	}
// }
// 
// Path: src/nb/barmie/net/TCPEndpoint.java
// public class TCPEndpoint {
// 	/*******************
// 	 * Properties
// 	 ******************/
// 	private final String _host;
// 	private final int _port;
// 	
// 	/*******************
// 	 * Construct the TCP endpoint object with a given host and port.
// 	 * 
// 	 * @param host The host/IP to use.
// 	 * @param port The port to use.
// 	 * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number.
// 	 ******************/
// 	public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException {
// 		//Store the properties
// 		this._host = host;
// 		this._port = port;
// 		
// 		//Validate the port number
// 		if(this._port < 1 || this._port > 65535) {
// 			throw new BaRMIeInvalidPortException(this._port);
// 		}
// 	}
// 	
// 	/*******************
// 	 * Return a string representation of this endpoint.
// 	 * 
// 	 * @return A host:port string.
// 	 ******************/
// 	public String toString() {
// 		return this._host + ":" + this._port;
// 	}
// 	
// 	/*******************
// 	 * Getters
// 	 ******************/
// 	public String getHost() { return this._host; }
// 	public int getPort() { return this._port; }
// }


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import nb.barmie.exceptions.BaRMIeIllegalArgumentException;
import nb.barmie.exceptions.BaRMIeInvalidPortException;
import nb.barmie.net.TCPEndpoint;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
					break;
					
				default:
					//Invalid command line...
					throw new BaRMIeIllegalArgumentException("Invalid command line, parameters following the target are not supported.");
			}
		}
	}
	
	/*******************
	 * Load a targets file passed in on the command line.
	 * 
	 * @param targetFilename The filename passed in using the --targets command line parameter.
	 ******************/
	private void loadTargets(String targetFilename) throws BaRMIeIllegalArgumentException, BaRMIeInvalidPortException {
		//Work out the target file format and load targets from it accordingly
		switch(this.getNetworkTargetsFileFormat(targetFilename)) {
			case "basic":
				//Each line should contain a single host or space-separated host and port
				this.loadNetworkTargetsBasic(targetFilename);
				break;
				
			case "nmap":
				//Parse nmap output for open TCP port 1099, rmiregistry services, or Java RMI services
				this.loadNetworkTargetsNmap(targetFilename);
				break;
				
			case "gnmap":
				//Parse greppable nmap output for open TCP port 1099, rmiregistry services, or Java RMI services
				this.loadNetworkTargetsGnmap(targetFilename);
// Path: src/nb/barmie/exceptions/BaRMIeIllegalArgumentException.java
// public class BaRMIeIllegalArgumentException extends BaRMIeException {
// 	public BaRMIeIllegalArgumentException(String message) {
// 		super(message);
// 	}
// 	
// 	public BaRMIeIllegalArgumentException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// }
// 
// Path: src/nb/barmie/exceptions/BaRMIeInvalidPortException.java
// public class BaRMIeInvalidPortException extends BaRMIeException {
// 	public BaRMIeInvalidPortException(int portNumber) {
// 		super("The given port number (" + portNumber + ") is not a valid TCP port number.");
// 	}
// }
// 
// Path: src/nb/barmie/net/TCPEndpoint.java
// public class TCPEndpoint {
// 	/*******************
// 	 * Properties
// 	 ******************/
// 	private final String _host;
// 	private final int _port;
// 	
// 	/*******************
// 	 * Construct the TCP endpoint object with a given host and port.
// 	 * 
// 	 * @param host The host/IP to use.
// 	 * @param port The port to use.
// 	 * @throws nb.barmie.exceptions.BaRMIeInvalidPortException If the given port number is not a valid TCP port number.
// 	 ******************/
// 	public TCPEndpoint(String host, int port) throws BaRMIeInvalidPortException {
// 		//Store the properties
// 		this._host = host;
// 		this._port = port;
// 		
// 		//Validate the port number
// 		if(this._port < 1 || this._port > 65535) {
// 			throw new BaRMIeInvalidPortException(this._port);
// 		}
// 	}
// 	
// 	/*******************
// 	 * Return a string representation of this endpoint.
// 	 * 
// 	 * @return A host:port string.
// 	 ******************/
// 	public String toString() {
// 		return this._host + ":" + this._port;
// 	}
// 	
// 	/*******************
// 	 * Getters
// 	 ******************/
// 	public String getHost() { return this._host; }
// 	public int getPort() { return this._port; }
// }


// Path: src/nb/barmie/util/ProgramOptions.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import nb.barmie.exceptions.BaRMIeIllegalArgumentException;
import nb.barmie.exceptions.BaRMIeInvalidPortException;
import nb.barmie.net.TCPEndpoint;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

					break;
					
				default:
					//Invalid command line...
					throw new BaRMIeIllegalArgumentException("Invalid command line, parameters following the target are not supported.");
			}
		}
	}
	
	/*******************
	 * Load a targets file passed in on the command line.
	 * 
	 * @param targetFilename The filename passed in using the --targets command line parameter.
	 ******************/
	private void loadTargets(String targetFilename) throws BaRMIeIllegalArgumentException, BaRMIeInvalidPortException {
		//Work out the target file format and load targets from it accordingly
		switch(this.getNetworkTargetsFileFormat(targetFilename)) {
			case "basic":
				//Each line should contain a single host or space-separated host and port
				this.loadNetworkTargetsBasic(targetFilename);
				break;
				
			case "nmap":
				//Parse nmap output for open TCP port 1099, rmiregistry services, or Java RMI services
				this.loadNetworkTargetsNmap(targetFilename);
				break;
				
			case "gnmap":
				//Parse greppable nmap output for open TCP port 1099, rmiregistry services, or Java RMI services
				this.loadNetworkTargetsGnmap(targetFilename);
				break;