Package eu.tneitzel.rmg.internal
Class ExceptionHandler
- java.lang.Object
-
- eu.tneitzel.rmg.internal.ExceptionHandler
-
public class ExceptionHandler extends Object
During the different RMI operations you have always a roughly same set of exceptions that can occur. To have a unified error handling and to avoid too much duplicate code, the most common exceptions are handled by this class. The overall exception handling could be improved even more by defining exception handlers that automatically handle the exceptions that could be thrown by a specific type of attack (e.g. codebase, deserialize, ...). This may be implemented in future and will remove much more duplicate code.- Author:
- Tobias Neitzel (@qtc_de)
-
-
Constructor Summary
Constructors Constructor Description ExceptionHandler()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaccessControl(Exception e, String during1, String during2)static voidalreadyBoundException(Exception e, String boundName)static voidbindException(Exception e)static voidcannotCompile(Exception e, String during1, String during2, boolean exit)static voidcodebaseClassCast(Exception e, boolean wasString)static voidcodebaseClassFormat(Exception e)static voidcodebaseClassNotFound(Exception e, String className)static voidcodebaseClassNotFoundRandom(Exception e, String className, String payloadName)static voidcodebaseSecurityManager(Exception e)static voidconnectException(Exception e, String callName)static voidconnectIOException(Exception e, String callName)static voidconnectionRefused(Exception e, String during1, String during2)static voidconnectionReset(Exception e, String during1, String during2)static voiddeserializeClassCast(Exception e, boolean wasString)static voiddeserializeClassNotFound(Exception e)static voiddeserializeClassNotFoundRandom(Exception e, String during1, String during2, String className)static voideofException(Exception e, String during1, String during2)static voidgenericCall(Exception e)static ThrowablegetCause(Throwable e)Taken from https://stackoverflow.com/questions/17747175/how-can-i-loop-through-exception-getcause-to-find-root-cause-with-detail-messa Returns the actual cause of an exception.static ThrowablegetThrowable(String name, Throwable e)Walks down a stacktrace and searches for a specific exception name.static voidhandleCodebaseException(Exception exception, String className, RMIComponent component, String method)Handle an Exception that is thrown during codebase attacks.static voidhandleCodebaseException(Exception exception, String className, RMIComponent component, String method, String randomClassName)Handle an Exception that is thrown during codebase attacks.static voidhandleGadgetCallException(Exception exception, RMIComponent component, String method)Handle an Exception that is thrown during gadget call attacks.static voidhandleGadgetCallException(Exception exception, RMIComponent component, String method, String randomClassName)Handle an Exception that is thrown during gadget call attacks.static voidillegalArgument(Exception e)static voidillegalArgumentCodebase(Exception e)static voidinternalError(String functionName, String message)static voidinternalException(Exception e, String functionName, boolean exit)static voidinvalidClass(Exception e, String endpoint)static voidinvalidClass(Exception e, String endpoint, boolean trace)static voidinvalidClassBind(Exception e, String operation, String className)static voidinvalidClassEnum(Exception e, String callName)static voidinvalidClassException(Exception e)static voidinvalidHostFormat(String format)static voidinvalidListenerFormat(boolean gadget)static voidinvalidObjectId(String objID)static voidinvalidSignature(String signature)static voidjep290(Exception e)static voidlocalhostBypassNoException()static voidlookupClassNotFoundException(Exception e, String name)static voidmissingSignature()static voidmissingTarget(String action)static voidnetworkUnreachable(Exception e, String during1, String during2)static voidnoJRMPServer(Exception e, String during1, String during2)static voidnonLocalhost(Exception e, String callName, boolean bypass)static voidnoRouteToHost(Exception e, String during1, String during2)static voidnoSuchObjectException(Exception e, String object, boolean exit)static voidnoSuchObjectException(Exception e, ObjID objID, boolean exit)static voidnoSuchObjectExceptionRegistryEnum()static voidnotBoundException(Exception e, String boundName)static voidrequirementException(eu.tneitzel.argparse4j.global.exceptions.RequirementException e)static <T extends Throwable>
voidshowStackTrace(T e)By using the --stack-trace option, uses can always display stack traces if they want to.static voidsingleEntryRegistry(Exception e, String during1)static voidsslError(Exception e, String during1, String during2)static <T extends Throwable>
voidstackTrace(T e)Helper function that prints a stacktrace with a prefixed Logger item.static voidtimeoutException(Exception e, String during1, String during2)static voidunexpectedException(Exception e, String during1, String during2, boolean exit)static voidunknownCodebaseException(Throwable e, boolean exit)static voidunknownDeserializationException(Exception e)static voidunknownHost(Exception e, String host, boolean exit)static voidunrecognizedMethodHash(Exception e, String action, String signature)static voidunsupportedClassVersion(Exception e, String during1, String during2)static voidunsupportedOperationException(Exception e, String callName)static voidunsupportedOperationExceptionEnum(Exception e, String callName)static voidwrongArgumentCount(int expected, int is)static voidysoNotPresent(String location)
-
-
-
Method Detail
-
requirementException
public static void requirementException(eu.tneitzel.argparse4j.global.exceptions.RequirementException e)
- Parameters:
e- description in progress
-
internalError
public static void internalError(String functionName, String message)
- Parameters:
functionName- description in progressmessage- description in progress
-
internalException
public static void internalException(Exception e, String functionName, boolean exit)
- Parameters:
e- description in progressfunctionName- description in progressexit- description in progress
-
unexpectedException
public static void unexpectedException(Exception e, String during1, String during2, boolean exit)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progressexit- description in progress
-
unknownCodebaseException
public static void unknownCodebaseException(Throwable e, boolean exit)
- Parameters:
e- description in progressexit- description in progress
-
alreadyBoundException
public static void alreadyBoundException(Exception e, String boundName)
- Parameters:
e- description in progressboundName- description in progress
-
nonLocalhost
public static void nonLocalhost(Exception e, String callName, boolean bypass)
- Parameters:
e- description in progresscallName- description in progressbypass- description in progress
-
jep290
public static void jep290(Exception e)
- Parameters:
e- description in progress
-
deserializeClassNotFound
public static void deserializeClassNotFound(Exception e)
- Parameters:
e- description in progress
-
deserializeClassNotFoundRandom
public static void deserializeClassNotFoundRandom(Exception e, String during1, String during2, String className)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progressclassName- description in progress
-
deserializeClassCast
public static void deserializeClassCast(Exception e, boolean wasString)
- Parameters:
e- description in progresswasString- description in progress
-
codebaseClassNotFound
public static void codebaseClassNotFound(Exception e, String className)
- Parameters:
e- description in progressclassName- description in progress
-
codebaseSecurityManager
public static void codebaseSecurityManager(Exception e)
- Parameters:
e- description in progress
-
codebaseClassNotFoundRandom
public static void codebaseClassNotFoundRandom(Exception e, String className, String payloadName)
- Parameters:
e- description in progressclassName- description in progresspayloadName- description in progress
-
codebaseClassCast
public static void codebaseClassCast(Exception e, boolean wasString)
- Parameters:
e- description in progresswasString- description in progress
-
codebaseClassFormat
public static void codebaseClassFormat(Exception e)
- Parameters:
e- description in progress
-
connectionRefused
public static void connectionRefused(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
noRouteToHost
public static void noRouteToHost(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
noJRMPServer
public static void noJRMPServer(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
sslError
public static void sslError(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
invalidClass
public static void invalidClass(Exception e, String endpoint)
- Parameters:
e- description in progressendpoint- description in progress
-
invalidClass
public static void invalidClass(Exception e, String endpoint, boolean trace)
- Parameters:
e- description in progressendpoint- description in progresstrace- description in progress
-
invalidClassBind
public static void invalidClassBind(Exception e, String operation, String className)
- Parameters:
e- description in progressoperation- description in progressclassName- description in progress
-
invalidClassEnum
public static void invalidClassEnum(Exception e, String callName)
- Parameters:
e- description in progresscallName- description in progress
-
unsupportedOperationException
public static void unsupportedOperationException(Exception e, String callName)
- Parameters:
e- description in progresscallName- description in progress
-
unsupportedOperationExceptionEnum
public static void unsupportedOperationExceptionEnum(Exception e, String callName)
- Parameters:
e- description in progresscallName- description in progress
-
accessControl
public static void accessControl(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
singleEntryRegistry
public static void singleEntryRegistry(Exception e, String during1)
- Parameters:
e- description in progressduring1- description in progress
-
noSuchObjectException
public static void noSuchObjectException(Exception e, String object, boolean exit)
- Parameters:
e- description in progressobject- description in progressexit- description in progress
-
noSuchObjectException
public static void noSuchObjectException(Exception e, ObjID objID, boolean exit)
- Parameters:
e- description in progressobjID- description in progressexit- description in progress
-
noSuchObjectExceptionRegistryEnum
public static void noSuchObjectExceptionRegistryEnum()
-
eofException
public static void eofException(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
invalidListenerFormat
public static void invalidListenerFormat(boolean gadget)
- Parameters:
gadget- description in progress
-
invalidHostFormat
public static void invalidHostFormat(String format)
- Parameters:
format- description in progress
-
invalidSignature
public static void invalidSignature(String signature)
- Parameters:
signature- description in progress
-
unknownDeserializationException
public static void unknownDeserializationException(Exception e)
- Parameters:
e- description in progress
-
unsupportedClassVersion
public static void unsupportedClassVersion(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
illegalArgument
public static void illegalArgument(Exception e)
- Parameters:
e- description in progress
-
illegalArgumentCodebase
public static void illegalArgumentCodebase(Exception e)
- Parameters:
e- description in progress
-
cannotCompile
public static void cannotCompile(Exception e, String during1, String during2, boolean exit)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progressexit- description in progress
-
unknownHost
public static void unknownHost(Exception e, String host, boolean exit)
- Parameters:
e- description in progresshost- description in progressexit- description in progress
-
networkUnreachable
public static void networkUnreachable(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
bindException
public static void bindException(Exception e)
- Parameters:
e- description in progress
-
ysoNotPresent
public static void ysoNotPresent(String location)
- Parameters:
location- description in progress
-
missingSignature
public static void missingSignature()
-
missingTarget
public static void missingTarget(String action)
- Parameters:
action- description in progress
-
invalidObjectId
public static void invalidObjectId(String objID)
- Parameters:
objID- description in progress
-
wrongArgumentCount
public static void wrongArgumentCount(int expected, int is)- Parameters:
expected- description in progressis- description in progress
-
unrecognizedMethodHash
public static void unrecognizedMethodHash(Exception e, String action, String signature)
- Parameters:
e- description in progressaction- description in progresssignature- description in progress
-
localhostBypassNoException
public static void localhostBypassNoException()
-
lookupClassNotFoundException
public static void lookupClassNotFoundException(Exception e, String name)
- Parameters:
e- description in progressname- description in progress
-
notBoundException
public static void notBoundException(Exception e, String boundName)
- Parameters:
e- description in progressboundName- description in progress
-
timeoutException
public static void timeoutException(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
connectionReset
public static void connectionReset(Exception e, String during1, String during2)
- Parameters:
e- description in progressduring1- description in progressduring2- description in progress
-
genericCall
public static void genericCall(Exception e)
- Parameters:
e- description in progress
-
connectException
public static void connectException(Exception e, String callName)
- Parameters:
e- description in progresscallName- description in progress
-
connectIOException
public static void connectIOException(Exception e, String callName)
- Parameters:
e- description in progresscallName- description in progress
-
invalidClassException
public static void invalidClassException(Exception e)
- Parameters:
e- description in progress
-
getThrowable
public static Throwable getThrowable(String name, Throwable e)
Walks down a stacktrace and searches for a specific exception name. If it finds the corresponding name, the corresponding Throwable is returned.- Parameters:
name- Exception name to look for.e- stack trace to search in.- Returns:
- identified Throwable.
-
showStackTrace
public static <T extends Throwable> void showStackTrace(T e)
By using the --stack-trace option, uses can always display stack traces if they want to. This is handled by this function. It checks whether --stack-trace was used and prints the stacktrace if desired. This function should be used in most of the error handling code of remote-method-guesser.- Type Parameters:
T- throwable type- Parameters:
e- Exception that was caught.
-
stackTrace
public static <T extends Throwable> void stackTrace(T e)
Helper function that prints a stacktrace with a prefixed Logger item.- Type Parameters:
T- throwable type- Parameters:
e- Exception that was caught.
-
getCause
public static Throwable getCause(Throwable e)
Taken from https://stackoverflow.com/questions/17747175/how-can-i-loop-through-exception-getcause-to-find-root-cause-with-detail-messa Returns the actual cause of an exception.- Parameters:
e- Exception that should be handled.- Returns:
- cause of the Exception.
-
handleCodebaseException
public static void handleCodebaseException(Exception exception, String className, RMIComponent component, String method)
Handle an Exception that is thrown during codebase attacks. The exception reasons are similar for most RMI components and it makes sense to use a unified function here.- Parameters:
exception- Exception that was raised during the codebase attackclassName- ClassName that was used during the codebase attackcomponent- RMIComponent that was targetedmethod- Server-side methodName that was used for the attack
-
handleCodebaseException
public static void handleCodebaseException(Exception exception, String className, RMIComponent component, String method, String randomClassName)
Handle an Exception that is thrown during codebase attacks. The exception reasons are similar for most RMI components and it makes sense to use a unified function here. This method uses an additional randomClassName parameter. This can be used to indicate that a canary was used during the attack.- Parameters:
exception- Exception that was raised during the codebase attackclassName- ClassName that was used during the codebase attackcomponent- RMIComponent that was targetedmethod- Server-side methodName that was used for the attackrandomClassName- Class name of the canary that was used during the attack
-
handleGadgetCallException
public static void handleGadgetCallException(Exception exception, RMIComponent component, String method)
Handle an Exception that is thrown during gadget call attacks. The exception reasons are similar for most RMI components and it makes sense to use a unified function here.- Parameters:
exception- Exception that was raised during the gadget call attackcomponent- RMIComponent that was targetedmethod- Server-side methodName that was used for the attack
-
handleGadgetCallException
public static void handleGadgetCallException(Exception exception, RMIComponent component, String method, String randomClassName)
Handle an Exception that is thrown during gadget call attacks. The exception reasons are similar for most RMI components and it makes sense to use a unified function here. This method uses an additional randomClassName parameter. This can be used to indicate that a canary was used during the attack.- Parameters:
exception- Exception that was raised during the gadget call attackcomponent- RMIComponent that was targetedmethod- Server-side methodName that was used for the attackrandomClassName- Class name of the canary that was used during the attack
-
-