Skip to content

Commit

Permalink
Argument parsing related bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Jan 9, 2024
1 parent 0f24cd0 commit fbf1f89
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/eu/tneitzel/rmg/internal/ArgumentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private Properties loadConfig(String filename)
{
InputStream configStream = null;

configStream = ArgumentParser.class.getResourceAsStream(defaultConfiguration);
configStream = ArgumentHandler.class.getResourceAsStream(defaultConfiguration);
config.load(configStream);
configStream.close();

Expand Down
26 changes: 13 additions & 13 deletions src/eu/tneitzel/rmg/internal/RMGOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public enum RMGOption implements IOption
Arguments.store(),
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("path"),
new MetaVar("port"),
new Type(Integer.class)
}),

Expand Down Expand Up @@ -199,7 +199,7 @@ public enum RMGOption implements IOption
BIND_ADDRESS("bind-host",
"host specifications the bound remote object should point to",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("host:port"),
}),
Expand All @@ -208,7 +208,7 @@ public enum RMGOption implements IOption
BIND_BOUND_NAME("bound-name",
"Bound name to use for (un)bind action",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("name"),
}),
Expand Down Expand Up @@ -241,7 +241,7 @@ public enum RMGOption implements IOption
CODEBASE_CLASS("classname",
"classname to load during codebase attack",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("name"),
}),
Expand All @@ -250,7 +250,7 @@ public enum RMGOption implements IOption
CODEBASE_URL("url",
"codebase URL to load the payload from",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("url"),
}),
Expand All @@ -259,7 +259,7 @@ public enum RMGOption implements IOption
LISTEN_IP("ip",
"IP address to start the listener on",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("IP"),
}),
Expand All @@ -268,7 +268,7 @@ public enum RMGOption implements IOption
LISTEN_PORT("port",
"port number to start the listener on",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("port"),
new Type(Integer.class)
Expand Down Expand Up @@ -395,7 +395,7 @@ public enum RMGOption implements IOption
GADGET_NAME("gadget",
"gadget name to use for the deserialization attack",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("gadget"),
}),
Expand All @@ -404,7 +404,7 @@ public enum RMGOption implements IOption
GADGET_CMD("cmd",
"command to pass for the specified gadget",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("cmd"),
}),
Expand All @@ -431,7 +431,7 @@ public enum RMGOption implements IOption
SCAN_HOST("host",
"host to perform the scan on",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("host"),
}),
Expand All @@ -450,7 +450,7 @@ public enum RMGOption implements IOption
CALL_ARGUMENTS("arguments",
"argument string to use for the call",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("args"),
}),
Expand All @@ -459,7 +459,7 @@ public enum RMGOption implements IOption
OBJID_OBJID("objid",
"ObjID string to parse",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("objid"),
}),
Expand All @@ -468,7 +468,7 @@ public enum RMGOption implements IOption
KNOWN_CLASS("classname",
"classname to check within the database",
Arguments.store(),
RMGOptionGroup.ACTION,
RMGOptionGroup.NONE,
new IArgumentModifier[] {
new MetaVar("name"),
}),
Expand Down
42 changes: 21 additions & 21 deletions src/eu/tneitzel/rmg/operations/Operation.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public enum Operation implements IAction
BIND("dispatchBind", "[object] <listener>", "Binds an object to the registry that points to listener", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.BIND_ADDRESS,
RMGOption.BIND_BOUND_NAME,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_PLUGIN,
Expand All @@ -41,10 +43,8 @@ public enum Operation implements IAction
RMGOption.SSRF_ENCODE,
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.BIND_BOUND_NAME,
RMGOption.BIND_BYPASS,
RMGOption.BIND_OBJID,
RMGOption.BIND_ADDRESS,
RMGOption.BIND_GADGET_NAME,
RMGOption.BIND_GADGET_CMD,
RMGOption.YSO,
Expand All @@ -57,6 +57,7 @@ public enum Operation implements IAction
CALL("dispatchCall", "<arguments>", "Regularly calls a method with the specified arguments", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.CALL_ARGUMENTS,
RMGOption.TARGET_BOUND_NAME,
RMGOption.TARGET_OBJID,
RMGOption.TARGET_SIGNATURE,
Expand All @@ -74,7 +75,6 @@ public enum Operation implements IAction
RMGOption.SSRF_ENCODE,
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.CALL_ARGUMENTS,
RMGOption.FORCE_ACTIVATION,
RMGOption.SERIAL_VERSION_UID,
RMGOption.SOCKET_FACTORY,
Expand All @@ -87,6 +87,8 @@ public enum Operation implements IAction
CODEBASE("dispatchCodebase", "<classname> <url>", "Perform remote class loading attacks", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.CODEBASE_CLASS,
RMGOption.CODEBASE_URL,
RMGOption.TARGET_BOUND_NAME,
RMGOption.TARGET_OBJID,
RMGOption.TARGET_SIGNATURE,
Expand All @@ -103,8 +105,6 @@ public enum Operation implements IAction
RMGOption.SSRF_ENCODE,
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.CODEBASE_URL,
RMGOption.CODEBASE_CLASS,
RMGOption.ARGUMENT_POS,
RMGOption.FORCE_ACTIVATION,
RMGOption.SERIAL_VERSION_UID,
Expand Down Expand Up @@ -178,38 +178,40 @@ public enum Operation implements IAction

/** Display details of known remote objects */
KNOWN("dispatchKnown", "<className>", "Display details of known remote objects", new RMGOption[] {
RMGOption.KNOWN_CLASS,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
RMGOption.KNOWN_CLASS,
}),

/** Open ysoserials JRMP listener */
LISTEN("dispatchListen", "<gadget> <command>", "Open ysoserials JRMP listener", new RMGOption[] {
RMGOption.LISTEN_IP,
RMGOption.LISTEN_PORT,
RMGOption.GADGET_NAME,
RMGOption.GADGET_CMD,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
RMGOption.GLOBAL_VERBOSE,
RMGOption.GLOBAL_PLUGIN,
RMGOption.LISTEN_IP,
RMGOption.LISTEN_PORT,
RMGOption.GADGET_NAME,
RMGOption.GADGET_CMD,
RMGOption.YSO,
}),

/** Print information contained within an ObjID */
OBJID("dispatchObjID", "<objid>", "Print information contained within an ObjID", new RMGOption[] {
RMGOption.OBJID_OBJID,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
RMGOption.GLOBAL_VERBOSE,
RMGOption.OBJID_OBJID,
}),

/** Rebinds boundname as object that points to listener */
REBIND("dispatchRebind", "[object] <listener>", "Rebinds boundname as object that points to listener", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.BIND_ADDRESS,
RMGOption.BIND_BOUND_NAME,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_PLUGIN,
Expand All @@ -222,10 +224,8 @@ public enum Operation implements IAction
RMGOption.SSRF_ENCODE,
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.BIND_BOUND_NAME,
RMGOption.BIND_BYPASS,
RMGOption.BIND_OBJID,
RMGOption.BIND_ADDRESS,
RMGOption.BIND_GADGET_NAME,
RMGOption.BIND_GADGET_CMD,
RMGOption.YSO,
Expand All @@ -236,6 +236,8 @@ public enum Operation implements IAction

/** Creates a rogue JMX listener (collect credentials) */
ROGUEJMX("dispatchRogueJMX", "[forward-host]", "Creates a rogue JMX listener (collect credentials)", new RMGOption[] {
RMGOption.LISTEN_IP,
RMGOption.LISTEN_PORT,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
Expand All @@ -247,18 +249,16 @@ public enum Operation implements IAction
RMGOption.ROGUEJMX_FORWARD_PORT,
RMGOption.ROGUEJMX_FORWARD_BOUND_NAME,
RMGOption.ROGUEJMX_FORWARD_OBJID,
RMGOption.LISTEN_IP,
RMGOption.LISTEN_PORT
}),

/** Perform an RMI service scan on common RMI ports */
SCAN("dispatchPortScan", "[<port> [<port>] ...]", "Perform an RMI service scan on common RMI ports", new RMGOption[] {
RMGOption.SCAN_HOST,
RMGOption.SCAN_PORTS,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
RMGOption.GLOBAL_VERBOSE,
RMGOption.SCAN_HOST,
RMGOption.SCAN_PORTS,
RMGOption.SCAN_TIMEOUT_CONNECT,
RMGOption.SCAN_TIMEOUT_READ,
RMGOption.THREADS,
Expand All @@ -269,6 +269,8 @@ public enum Operation implements IAction
SERIAL("dispatchSerial", "<gadget> <command>", "Perform deserialization attacks against default RMI components", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.GADGET_NAME,
RMGOption.GADGET_CMD,
RMGOption.TARGET_BOUND_NAME,
RMGOption.TARGET_OBJID,
RMGOption.TARGET_SIGNATURE,
Expand All @@ -287,8 +289,6 @@ public enum Operation implements IAction
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.ARGUMENT_POS,
RMGOption.GADGET_NAME,
RMGOption.GADGET_CMD,
RMGOption.YSO,
RMGOption.FORCE_ACTIVATION,
RMGOption.SERIAL_VERSION_UID,
Expand All @@ -301,6 +301,7 @@ public enum Operation implements IAction
UNBIND("dispatchUnbind", "", "Removes the specified bound name from the registry", new RMGOption[] {
RMGOption.TARGET_HOST,
RMGOption.TARGET_PORT,
RMGOption.BIND_BOUND_NAME,
RMGOption.GLOBAL_CONFIG,
RMGOption.GLOBAL_NO_COLOR,
RMGOption.GLOBAL_STACK_TRACE,
Expand All @@ -312,7 +313,6 @@ public enum Operation implements IAction
RMGOption.SSRF_ENCODE,
RMGOption.SSRF_RAW,
RMGOption.SSRF_STREAM_PROTOCOL,
RMGOption.BIND_BOUND_NAME,
RMGOption.BIND_BYPASS,
RMGOption.SOCKET_FACTORY,
RMGOption.SOCKET_FACTORY_SSL,
Expand Down Expand Up @@ -433,7 +433,7 @@ public static void addSubparsers(Subparsers argumentParser)
for (Operation operation : Operation.values())
{
Subparser parser = argumentParser.addParser(operation.name().toLowerCase()).help(operation.description);
GlobalOption.addOptions(parser, operation, RMGOption.values());
GlobalOption.addOptions(parser, operation);
}
}

Expand Down

0 comments on commit fbf1f89

Please sign in to comment.