private static void dumpFields(final ClassInfo info, final Map<Integer, ClassInfo> map, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth) throws IOException { if ((info.flags & SC_EXTERNALIZABLE) != 0) { printf(w, depth, "[--] Externalizable data block:"); dumpBlockData(map, seq, dis, w, depth + 1); } else if ((info.flags & SC_SERIALIZABLE) != 0) { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] Fields for class %s:", info.name); for (FieldInfo fieldInfo : info.info) { printf(w, depth + 1, "[--] Field %s = %s", fieldInfo.name, fieldInfo.type.getValueString(dis)); if (fieldInfo.type.isObject()) { dumpObject(map, seq, dis, w, depth + 2, dis.readUnsignedByte()); } } if ((info.flags & SC_WRITE_METHOD) != 0) { printf(w, depth, "[--] Custom data for class %s:", info.name); dumpBlockData(map, seq, dis, w, depth + 1); } } else { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] No info for class %s", info.name); } }
private static void dumpBlockData(final Map<Integer, ClassInfo> map, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth) throws IOException { for (;;) { final int leadByte = dis.readUnsignedByte(); if (leadByte == TC_ENDBLOCKDATA) { printf(w, depth, "[%02x] TC_ENDBLOCKDATA - End block data", Byte.valueOf(TC_ENDBLOCKDATA)); return; } else { dumpContent(map, seq, dis, w, depth, leadByte); } } }
public static void dumpStream(InputStream serializedData, Writer destination) throws IOException { final DataInputStream dis = serializedData instanceof DataInputStream ? (DataInputStream) serializedData : new DataInputStream(serializedData); final BufferedWriter bw = destination instanceof BufferedWriter ? (BufferedWriter) destination : new BufferedWriter(destination); try { dumpStream(dis, bw); } finally { bw.flush(); destination.flush(); } }
private static void dumpContent(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_BLOCKDATA: { final int len = dis.readUnsignedByte(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } case TC_BLOCKDATALONG: { final int len = dis.readInt(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } default: { dumpObject(descrMap, seq, dis, w, depth, leadByte); return; } } }
printf(w, depth, "[%02x] TC_OBJECT - New object", Integer.valueOf(TC_OBJECT)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New object handle is [%08x]", Integer.valueOf(handle)); dumpFields(classInfo, descrMap, seq, dis, w, depth + 1); return; printf(w, depth, "[%02x] TC_OBJECTTABLE - New object from table, handle is [%08x]", Integer.valueOf(TC_OBJECTTABLE), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth + 1); printf(w, depth, "[%02x] TC_CLASS - New class", Integer.valueOf(TC_CLASS)); dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New class handle is [%08x]", Integer.valueOf(handle)); return; printf(w, depth, "[%02x] TC_ARRAY - New array", Integer.valueOf(TC_ARRAY)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New array handle is [%08x]", Integer.valueOf(handle)); final int len = dis.readInt(); printf(w, depth + 1, "[%x08] Array of length %d", Integer.valueOf(len), Integer.valueOf(len)); for (int i = 0; i < len; i ++) { final FieldType fieldType = FieldType.fromTypeCode(classInfo.name.charAt(1)); printf(w, depth + 2, "[%d] = %s", Integer.valueOf(i), fieldType.getValueString(dis)); if (fieldType.isObject()) { dumpObject(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); dumpString(descrMap, seq, dis, w, depth, leadByte);
printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(h)); return descrMap.get(Integer.valueOf(h)); printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return null; printf(w, depth, "[%02x] TC_CLASSTABLEDESC - New class descriptor from table, handle [%08x] - stream is indeterminate from this point on", Integer.valueOf(TC_CLASSTABLEDESC), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth); return null; final long svu = dis.readLong(); final int handle = seq.getAndIncrement(); printf(w, depth, "[%02x] TC_CLASSDESC - New class descriptor, class = \"%s\", uid = %d, handle [%08x]", Integer.valueOf(TC_CLASSDESC), name, Long.valueOf(svu), Integer.valueOf(handle)); final int flags = dis.readUnsignedByte(); final int fieldCount = dis.readUnsignedShort(); FieldInfo[] info = new FieldInfo[fieldCount]; printf(w, depth + 1, "[--] Flags: (" + (((flags & SC_BLOCK_DATA) != 0) ? " SC_BLOCK_DATA" : "") + (((flags & SC_ENUM) != 0) ? " SC_ENUM" : "") + (((flags & SC_EXTERNALIZABLE) != 0) ? " SC_EXTERNALIZABLE" : "") + (((flags & SC_SERIALIZABLE) != 0) ? " SC_SERIALIZABLE" : "") + (((flags & SC_WRITE_METHOD) != 0) ? " SC_WRITE_METHOD" : "") + ")"); printf(w, depth + 1, "[--] %d fields", Integer.valueOf(fieldCount)); for (int i = 0; i < fieldCount; i++) { final int typeCode = dis.readUnsignedByte(); final String fieldName = dis.readUTF(); printf(w, depth + 2, "[--] Field \"%s\" type code '%s'%s", fieldName, Character.toString((char)typeCode), (typeCode == '[' || typeCode == 'L' ? ", type name follows" : "")); if (typeCode == '[' || typeCode == 'L') { dumpString(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); printf(w, depth + 1, "[--] Class desc data block:"); dumpBlockData(descrMap, seq, dis, w, depth + 2); final ClassInfo classInfo = new ClassInfo(); descrMap.put(Integer.valueOf(handle), classInfo);
private static void dumpString(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_STRING: { final int handle = seq.getAndIncrement(); final String str = dis.readUTF(); printf(w, depth, "[%02x] TC_STRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_STRING), Integer.valueOf(handle), str); return; } case TC_LONGSTRING: { final int handle = seq.getAndIncrement(); final String str = UTFUtils.readUTFBytesByByteCount(Marshalling.createByteInput(dis), dis.readLong()); printf(w, depth, "[%02x] TC_LONGSTRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_LONGSTRING), Integer.valueOf(handle), str); return; } case TC_REFERENCE: { printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(dis.readInt())); return; } case TC_NULL: { printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return; } default: { throw new IllegalStateException("Wrong lead byte: " + leadByte); } } }
printf(w, depth, "[%02x] TC_OBJECT - New object", Integer.valueOf(TC_OBJECT)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New object handle is [%08x]", Integer.valueOf(handle)); dumpFields(classInfo, descrMap, seq, dis, w, depth + 1); return; printf(w, depth, "[%02x] TC_OBJECTTABLE - New object from table, handle is [%08x]", Integer.valueOf(TC_OBJECTTABLE), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth + 1); printf(w, depth, "[%02x] TC_CLASS - New class", Integer.valueOf(TC_CLASS)); dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New class handle is [%08x]", Integer.valueOf(handle)); return; printf(w, depth, "[%02x] TC_ARRAY - New array", Integer.valueOf(TC_ARRAY)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New array handle is [%08x]", Integer.valueOf(handle)); final int len = dis.readInt(); printf(w, depth + 1, "[%x08] Array of length %d", Integer.valueOf(len), Integer.valueOf(len)); for (int i = 0; i < len; i ++) { final FieldType fieldType = FieldType.fromTypeCode(classInfo.name.charAt(1)); printf(w, depth + 2, "[%d] = %s", Integer.valueOf(i), fieldType.getValueString(dis)); if (fieldType.isObject()) { dumpObject(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); dumpString(descrMap, seq, dis, w, depth, leadByte);
printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(h)); return descrMap.get(Integer.valueOf(h)); printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return null; printf(w, depth, "[%02x] TC_CLASSTABLEDESC - New class descriptor from table, handle [%08x] - stream is indeterminate from this point on", Integer.valueOf(TC_CLASSTABLEDESC), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth); return null; final long svu = dis.readLong(); final int handle = seq.getAndIncrement(); printf(w, depth, "[%02x] TC_CLASSDESC - New class descriptor, class = \"%s\", uid = %d, handle [%08x]", Integer.valueOf(TC_CLASSDESC), name, Long.valueOf(svu), Integer.valueOf(handle)); final int flags = dis.readUnsignedByte(); final int fieldCount = dis.readUnsignedShort(); FieldInfo[] info = new FieldInfo[fieldCount]; printf(w, depth + 1, "[--] Flags: (" + (((flags & SC_BLOCK_DATA) != 0) ? " SC_BLOCK_DATA" : "") + (((flags & SC_ENUM) != 0) ? " SC_ENUM" : "") + (((flags & SC_EXTERNALIZABLE) != 0) ? " SC_EXTERNALIZABLE" : "") + (((flags & SC_SERIALIZABLE) != 0) ? " SC_SERIALIZABLE" : "") + (((flags & SC_WRITE_METHOD) != 0) ? " SC_WRITE_METHOD" : "") + ")"); printf(w, depth + 1, "[--] %d fields", Integer.valueOf(fieldCount)); for (int i = 0; i < fieldCount; i++) { final int typeCode = dis.readUnsignedByte(); final String fieldName = dis.readUTF(); printf(w, depth + 2, "[--] Field \"%s\" type code '%s'%s", fieldName, Character.toString((char)typeCode), (typeCode == '[' || typeCode == 'L' ? ", type name follows" : "")); if (typeCode == '[' || typeCode == 'L') { dumpString(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); printf(w, depth + 1, "[--] Class desc data block:"); dumpBlockData(descrMap, seq, dis, w, depth + 2); final ClassInfo classInfo = new ClassInfo(); descrMap.put(Integer.valueOf(handle), classInfo);
private static void dumpContent(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_BLOCKDATA: { final int len = dis.readUnsignedByte(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } case TC_BLOCKDATALONG: { final int len = dis.readInt(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } default: { dumpObject(descrMap, seq, dis, w, depth, leadByte); return; } } }
private static void dumpString(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_STRING: { final int handle = seq.getAndIncrement(); final String str = dis.readUTF(); printf(w, depth, "[%02x] TC_STRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_STRING), Integer.valueOf(handle), str); return; } case TC_LONGSTRING: { final int handle = seq.getAndIncrement(); final String str = UTFUtils.readUTFBytesByByteCount(Marshalling.createByteInput(dis), dis.readLong()); printf(w, depth, "[%02x] TC_LONGSTRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_LONGSTRING), Integer.valueOf(handle), str); return; } case TC_REFERENCE: { printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(dis.readInt())); return; } case TC_NULL: { printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return; } default: { throw new IllegalStateException("Wrong lead byte: " + leadByte); } } }
printf(w, depth, "[%02x] TC_OBJECT - New object", Integer.valueOf(TC_OBJECT)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New object handle is [%08x]", Integer.valueOf(handle)); dumpFields(classInfo, descrMap, seq, dis, w, depth + 1); return; printf(w, depth, "[%02x] TC_OBJECTTABLE - New object from table, handle is [%08x]", Integer.valueOf(TC_OBJECTTABLE), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth + 1); printf(w, depth, "[%02x] TC_CLASS - New class", Integer.valueOf(TC_CLASS)); dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New class handle is [%08x]", Integer.valueOf(handle)); return; printf(w, depth, "[%02x] TC_ARRAY - New array", Integer.valueOf(TC_ARRAY)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New array handle is [%08x]", Integer.valueOf(handle)); final int len = dis.readInt(); printf(w, depth + 1, "[%x08] Array of length %d", Integer.valueOf(len), Integer.valueOf(len)); for (int i = 0; i < len; i ++) { final FieldType fieldType = FieldType.fromTypeCode(classInfo.name.charAt(1)); printf(w, depth + 2, "[%d] = %s", Integer.valueOf(i), fieldType.getValueString(dis)); if (fieldType.isObject()) { dumpObject(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); dumpString(descrMap, seq, dis, w, depth, leadByte);
private static void dumpFields(final ClassInfo info, final Map<Integer, ClassInfo> map, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth) throws IOException { if ((info.flags & SC_EXTERNALIZABLE) != 0) { printf(w, depth, "[--] Externalizable data block:"); dumpBlockData(map, seq, dis, w, depth + 1); } else if ((info.flags & SC_SERIALIZABLE) != 0) { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] Fields for class %s:", info.name); for (FieldInfo fieldInfo : info.info) { printf(w, depth + 1, "[--] Field %s = %s", fieldInfo.name, fieldInfo.type.getValueString(dis)); if (fieldInfo.type.isObject()) { dumpObject(map, seq, dis, w, depth + 2, dis.readUnsignedByte()); } } if ((info.flags & SC_WRITE_METHOD) != 0) { printf(w, depth, "[--] Custom data for class %s:", info.name); dumpBlockData(map, seq, dis, w, depth + 1); } } else { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] No info for class %s", info.name); } }
printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(h)); return descrMap.get(Integer.valueOf(h)); printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return null; printf(w, depth, "[%02x] TC_CLASSTABLEDESC - New class descriptor from table, handle [%08x] - stream is indeterminate from this point on", Integer.valueOf(TC_CLASSTABLEDESC), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth); return null; final long svu = dis.readLong(); final int handle = seq.getAndIncrement(); printf(w, depth, "[%02x] TC_CLASSDESC - New class descriptor, class = \"%s\", uid = %d, handle [%08x]", Integer.valueOf(TC_CLASSDESC), name, Long.valueOf(svu), Integer.valueOf(handle)); final int flags = dis.readUnsignedByte(); final int fieldCount = dis.readUnsignedShort(); FieldInfo[] info = new FieldInfo[fieldCount]; printf(w, depth + 1, "[--] Flags: (" + (((flags & SC_BLOCK_DATA) != 0) ? " SC_BLOCK_DATA" : "") + (((flags & SC_ENUM) != 0) ? " SC_ENUM" : "") + (((flags & SC_EXTERNALIZABLE) != 0) ? " SC_EXTERNALIZABLE" : "") + (((flags & SC_SERIALIZABLE) != 0) ? " SC_SERIALIZABLE" : "") + (((flags & SC_WRITE_METHOD) != 0) ? " SC_WRITE_METHOD" : "") + ")"); printf(w, depth + 1, "[--] %d fields", Integer.valueOf(fieldCount)); for (int i = 0; i < fieldCount; i++) { final int typeCode = dis.readUnsignedByte(); final String fieldName = dis.readUTF(); printf(w, depth + 2, "[--] Field \"%s\" type code '%s'%s", fieldName, Character.toString((char)typeCode), (typeCode == '[' || typeCode == 'L' ? ", type name follows" : "")); if (typeCode == '[' || typeCode == 'L') { dumpString(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); printf(w, depth + 1, "[--] Class desc data block:"); dumpBlockData(descrMap, seq, dis, w, depth + 2); final ClassInfo classInfo = new ClassInfo(); descrMap.put(Integer.valueOf(handle), classInfo);
private static void dumpBlockData(final Map<Integer, ClassInfo> map, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth) throws IOException { for (;;) { final int leadByte = dis.readUnsignedByte(); if (leadByte == TC_ENDBLOCKDATA) { printf(w, depth, "[%02x] TC_ENDBLOCKDATA - End block data", Byte.valueOf(TC_ENDBLOCKDATA)); return; } else { dumpContent(map, seq, dis, w, depth, leadByte); } } }
private static void dumpContent(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_BLOCKDATA: { final int len = dis.readUnsignedByte(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } case TC_BLOCKDATALONG: { final int len = dis.readInt(); printf(w, depth, "[%02x] TC_BLOCKDATA - Data block of %d bytes", Integer.valueOf(TC_BLOCKDATA), Integer.valueOf(len)); for (int i = 0; i < len; i += dis.skipBytes(len - i)); return; } default: { dumpObject(descrMap, seq, dis, w, depth, leadByte); return; } } }
public static void dumpStream(InputStream serializedData, Writer destination) throws IOException { final DataInputStream dis = serializedData instanceof DataInputStream ? (DataInputStream) serializedData : new DataInputStream(serializedData); final BufferedWriter bw = destination instanceof BufferedWriter ? (BufferedWriter) destination : new BufferedWriter(destination); try { dumpStream(dis, bw); } finally { bw.flush(); destination.flush(); } }
private static void dumpString(Map<Integer, ClassInfo> descrMap, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth, final int leadByte) throws IOException { switch (leadByte) { case TC_STRING: { final int handle = seq.getAndIncrement(); final String str = dis.readUTF(); printf(w, depth, "[%02x] TC_STRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_STRING), Integer.valueOf(handle), str); return; } case TC_LONGSTRING: { final int handle = seq.getAndIncrement(); final String str = UTFUtils.readUTFBytesByByteCount(Marshalling.createByteInput(dis), dis.readLong()); printf(w, depth, "[%02x] TC_LONGSTRING - New string, handle [%08x] = \"%s\"", Integer.valueOf(TC_LONGSTRING), Integer.valueOf(handle), str); return; } case TC_REFERENCE: { printf(w, depth, "[%02x] TC_REFERENCE - Backreference [%08x]", Integer.valueOf(TC_REFERENCE), Integer.valueOf(dis.readInt())); return; } case TC_NULL: { printf(w, depth, "[%02x] TC_NULL - Null value", Integer.valueOf(TC_NULL)); return; } default: { throw new IllegalStateException("Wrong lead byte: " + leadByte); } } }
printf(w, depth, "[%02x] TC_OBJECT - New object", Integer.valueOf(TC_OBJECT)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New object handle is [%08x]", Integer.valueOf(handle)); dumpFields(classInfo, descrMap, seq, dis, w, depth + 1); return; printf(w, depth, "[%02x] TC_OBJECTTABLE - New object from table, handle is [%08x]", Integer.valueOf(TC_OBJECTTABLE), Integer.valueOf(handle)); dumpBlockData(descrMap, seq, dis, w, depth + 1); printf(w, depth, "[%02x] TC_CLASS - New class", Integer.valueOf(TC_CLASS)); dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New class handle is [%08x]", Integer.valueOf(handle)); return; printf(w, depth, "[%02x] TC_ARRAY - New array", Integer.valueOf(TC_ARRAY)); final ClassInfo classInfo = dumpDescriptor(descrMap, seq, dis, w, depth + 1, dis.readUnsignedByte()); final int handle = seq.getAndIncrement(); printf(w, depth + 1, "[--] New array handle is [%08x]", Integer.valueOf(handle)); final int len = dis.readInt(); printf(w, depth + 1, "[%x08] Array of length %d", Integer.valueOf(len), Integer.valueOf(len)); for (int i = 0; i < len; i ++) { final FieldType fieldType = FieldType.fromTypeCode(classInfo.name.charAt(1)); printf(w, depth + 2, "[%d] = %s", Integer.valueOf(i), fieldType.getValueString(dis)); if (fieldType.isObject()) { dumpObject(descrMap, seq, dis, w, depth + 3, dis.readUnsignedByte()); dumpString(descrMap, seq, dis, w, depth, leadByte);
private static void dumpFields(final ClassInfo info, final Map<Integer, ClassInfo> map, final AtomicInteger seq, final DataInputStream dis, final BufferedWriter w, final int depth) throws IOException { if ((info.flags & SC_EXTERNALIZABLE) != 0) { printf(w, depth, "[--] Externalizable data block:"); dumpBlockData(map, seq, dis, w, depth + 1); } else if ((info.flags & SC_SERIALIZABLE) != 0) { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] Fields for class %s:", info.name); for (FieldInfo fieldInfo : info.info) { printf(w, depth + 1, "[--] Field %s = %s", fieldInfo.name, fieldInfo.type.getValueString(dis)); if (fieldInfo.type.isObject()) { dumpObject(map, seq, dis, w, depth + 2, dis.readUnsignedByte()); } } if ((info.flags & SC_WRITE_METHOD) != 0) { printf(w, depth, "[--] Custom data for class %s:", info.name); dumpBlockData(map, seq, dis, w, depth + 1); } } else { if (info.parent != null) { dumpFields(info.parent, map, seq, dis, w, depth); } printf(w, depth, "[--] No info for class %s", info.name); } }