Package eu.tneitzel.rmg.internal
Class ArgumentHandler
- java.lang.Object
-
- eu.tneitzel.rmg.internal.ArgumentHandler
-
public class ArgumentHandler extends Object
The ArgumentHandler class is a wrapper around an argparse4j ArgumentParser. It adds some additional functionality that is useful for other parts of the program. Especially, it initializes the RMGOption enum, which is used for global argument access.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Constructor Summary
Constructors Constructor Description ArgumentHandler(String[] argv)Creates the ArgumentParser used for remote-method-guesser and adds the desired arguments and ArgumentGroups.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPorts(String portString, Set<Integer> portList)Helper function that handles port lists.voidaddRange(String portRange, Set<Integer> portList)Helper function that handles port ranges.OperationgetAction()Returns the user specified remote-method-guesser action.Object[]getCallArguments()Parses the user specified argument string during a call action.RMIComponentgetComponent()Parse the user specified --component value.StringgetDgcMethod()During DGC related rmg operations, users can select the DGC method that is used for the different RMI calls.ObjectgetGadget()Parses the user specified gadget arguments to request a corresponding gadget from the PayloadProvider.StringgetRegMethod()During registry related rmg operations, users can select the registry method that is used for the different RMI calls.int[]getRmiPorts()Is used to parse the port specification for the scan operation.EnumSet<ScanAction>getScanActions()Is used when the enum action was specified.voidsetSocketTimeout()Is called when the scan action was requested.
-
-
-
Constructor Detail
-
ArgumentHandler
public ArgumentHandler(String[] argv)
Creates the ArgumentParser used for remote-method-guesser and adds the desired arguments and ArgumentGroups. Also starts the initialization of the RMGOption enum.- Parameters:
argv- Argument array as specified on the command line.
-
-
Method Detail
-
getAction
public Operation getAction()
Returns the user specified remote-method-guesser action.- Returns:
- Operation requested by the client
-
getRegMethod
public String getRegMethod()
During registry related rmg operations, users can select the registry method that is used for the different RMI calls. This is done by using the --signature option. In contrast to custom remote objects, the method signature is not really parsed. It is only checked for specific keywords and the corresponding registry methods signature is chosen automatically.- Returns:
- method to use for registry operations - if valid.
-
getDgcMethod
public String getDgcMethod()
During DGC related rmg operations, users can select the DGC method that is used for the different RMI calls. This is done by using the --signature option. In contrast to custom remote objects, the method signature is not really parsed. It is only checked for specific keywords and the corresponding DGC methods signature is chosen automatically.- Returns:
- method to use for DGC operations - if valid.
-
getComponent
public RMIComponent getComponent()
Parse the user specified --component value. This function verifies that the value matches one of the supported values: act, dgc or reg.- Returns:
- user specified component value - if valid.
-
getGadget
public Object getGadget()
Parses the user specified gadget arguments to request a corresponding gadget from the PayloadProvider. The corresponding gadget object is returned.- Returns:
- gadget object build from the user specified arguments
-
getCallArguments
public Object[] getCallArguments()
Parses the user specified argument string during a call action. Passes the string to the corresponding ArgumentProvider and returns the result argument array.- Returns:
- Object array resulting from the specified argument string
-
getScanActions
public EnumSet<ScanAction> getScanActions()
Is used when the enum action was specified. The enum action allows users to limit enumeration to certain scan actions. This function parses the user supplied arguments and checks which scan actions were requested. The corresponding actions are returned as EnumSet.- Returns:
- EnumSet of ScanAction which were requested by the user.
-
getRmiPorts
public int[] getRmiPorts()
Is used to parse the port specification for the scan operation. For the scan operation, the second port argument can be a range (e.g. 10-1000), a list (e.g. 1090-1099,9000,9010) a single port (e.g. 1090) or the keyword "-" (scans all rmi ports configured in the config file). This function parses the user specified value and returns the corresponding int array that needs to be scanned.- Returns:
- array of int which contains all ports that should be scanned
-
addPorts
public void addPorts(String portString, Set<Integer> portList)
Helper function that handles port lists.- Parameters:
portString- user specified port stringportList- Set of Integer where parsed ports are added
-
addRange
public void addRange(String portRange, Set<Integer> portList)
Helper function that handles port ranges.- Parameters:
portRange- user specified port stringportList- Set of Integer where parsed ports are added
-
setSocketTimeout
public void setSocketTimeout()
Is called when the scan action was requested. Sets custom timeout values for RMI socket operations, as the default values are not well suited for portscanning. This function needs to be called early before the corresponding RMI classes are loaded.
-
-