feat: support spring webflux shell generate (resolved #6)

This commit is contained in:
ReaJason
2024-12-26 00:59:24 +08:00
parent cfa4bfdb1d
commit ee82fc102d
45 changed files with 1510 additions and 20 deletions
+8
View File
@@ -0,0 +1,8 @@
FROM openjdk:8
WORKDIR /app
COPY build/libs/vul-springboot2-webflux.jar /app/vul-springboot2-webflux.jar
EXPOSE 8080
ENTRYPOINT java $JAVA_OPTS -jar vul-springboot2-webflux.jar
+13
View File
@@ -0,0 +1,13 @@
plugins {
id 'org.springframework.boot' version '2.7.6'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'com.reajason.javaweb.vul'
version = ''
sourceCompatibility = '1.8'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
}
@@ -0,0 +1,14 @@
package com.reajason.javaweb.vul.springboot2;
public class ClassDefiner extends ClassLoader {
public ClassDefiner() {
}
public ClassDefiner(ClassLoader parent) {
super(parent);
}
public Class<?> defineClass(byte[] bytes) {
return defineClass(null, bytes, 0, bytes.length);
}
}
@@ -0,0 +1,17 @@
package com.reajason.javaweb.vul.springboot2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;
@SpringBootApplication
public class VulSpringboot2Application {
public static void main(String[] args) {
SpringApplication.run(VulSpringboot2Application.class, args);
}
}
@@ -0,0 +1,36 @@
package com.reajason.javaweb.vul.springboot2.controller;
import com.reajason.javaweb.vul.springboot2.ClassDefiner;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
import java.util.Base64;
/**
* @author ReaJason
* @since 2024/12/22
*/
@RestController
@RequestMapping("/b64")
public class Base64ClassLoaderController {
@PostMapping
public Mono<String> handleFormSubmission(ServerWebExchange exchange) {
System.out.println("hello i'm coming");
return exchange.getFormData()
.flatMap(formData -> {
String data = formData.getFirst("data");
System.out.println("b64: " + data);
byte[] bytes = Base64.getDecoder().decode(data);
Object o = null;
try {
o = new ClassDefiner(Thread.currentThread().getContextClassLoader()).defineClass(bytes).newInstance();
} catch (Exception e) {
throw new RuntimeException(e);
}
return Mono.just(o.toString());
});
}
}
@@ -0,0 +1,23 @@
package com.reajason.javaweb.vul.springboot2.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author ReaJason
* @since 2024/12/22
*/
@RequestMapping
@RestController
public class IndexController {
@GetMapping("/test")
public String test() {
return "";
}
@GetMapping("/")
public String index() {
return "hello";
}
}