// 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;
package nb.barmie.util;


/***********************************************************
 * Class to parse, load, validate and provide access to
 * command line options.
 **********************************************************
 * Command line should be one of the following:
 *	BaRMIe -enum [options] [target-host] [target-port]
 *	BaRMIe -attack [options] [target-host] [target-port]
 * 
 * Mode flags:
 * -enum		Enumerate the given target(s) to retrieve details of objects and exploits we can perform.
 * -attack		Enumerate the given target(s) and present attack options.
 * 
 * Options supported by all modes:
 * --targets	Used to specify a file containing targets (supports nmap output).
 * --timeout	Used to set timeout on blocking TCP operations.
 * 
 * Options supported by enumeration mode only:
 * --threads	Number of threads to use for scanning.
 **********************************************************
 * Written by Nicky Bloor (@NickstaDB).
 **********************************************************/
public class ProgramOptions {
	/*******************
	 * Constants and properties
	 ******************/
	//Default option values
	private final String DEFAULT_MODE = "-enum";	//Default to enumeration mode if no mode is specified
	private final int DEFAULT_THREADS = 10;			//Default to using 10 worker threads
	private final int DEFAULT_SOCKTIMEOUT = 5000;	//Default to a 5 second timeout on blocking socket operations
	private final int DEFAULT_RMIPORT = 1099;		//Default TCP port for RMI registry services
	
	//Program option properties
	private String _mode;							//Execution mode - enum/attack
// 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;

package nb.barmie.util;


/***********************************************************
 * Class to parse, load, validate and provide access to
 * command line options.
 **********************************************************
 * Command line should be one of the following:
 *	BaRMIe -enum [options] [target-host] [target-port]
 *	BaRMIe -attack [options] [target-host] [target-port]
 * 
 * Mode flags:
 * -enum		Enumerate the given target(s) to retrieve details of objects and exploits we can perform.
 * -attack		Enumerate the given target(s) and present attack options.
 * 
 * Options supported by all modes:
 * --targets	Used to specify a file containing targets (supports nmap output).
 * --timeout	Used to set timeout on blocking TCP operations.
 * 
 * Options supported by enumeration mode only:
 * --threads	Number of threads to use for scanning.
 **********************************************************
 * Written by Nicky Bloor (@NickstaDB).
 **********************************************************/
public class ProgramOptions {
	/*******************
	 * Constants and properties
	 ******************/
	//Default option values
	private final String DEFAULT_MODE = "-enum";	//Default to enumeration mode if no mode is specified
	private final int DEFAULT_THREADS = 10;			//Default to using 10 worker threads
	private final int DEFAULT_SOCKTIMEOUT = 5000;	//Default to a 5 second timeout on blocking socket operations
	private final int DEFAULT_RMIPORT = 1099;		//Default TCP port for RMI registry services
	
	//Program option properties
	private String _mode;							//Execution mode - enum/attack
	private ArrayList<TCPEndpoint> _targets;		//Targets