H2 Database
H2 Database can expose a web console on TCP 8082 and a database service on TCP 9092. H2 1.4.199 can be abused for command execution through the console.
Discovery
nmap -sC -sV TARGET
# 80/tcp open http Microsoft IIS httpd 10.0
# http-title: H2 Database Engine (redirect)
# 8082/tcp open http H2 database http console
# http-title: H2 ConsoleFull port scans may show the H2 TCP service:
9092/tcp open XmlIpcRegSvc?
Remote connections to this server are not allowed
org.h2.jdbc.JdbcSQLNonTransientConnectionExceptionUseful documentation paths:
http://TARGET/html/main.html
http://TARGET/html/tutorial.html
http://TARGET/html/features.html
http://TARGET/html/quickstart.htmlConsole Login
Browse to the H2 console:
The console may be prefilled with the sa user and no password. Use the default values and connect.
After login, check the version in the left pane:
JNDI Callback Check
Set the driver class to:
Set the JDBC URL to an attacker-controlled LDAP listener:
Confirm the target connects back before continuing:
JNI Code Execution
Exploit-DB 49384 can enable JNIScriptEngine.eval command execution in H2 1.4.199.
After the exploit setup, create the alias and execute a command:
Confirm execution with ICMP:
Reverse Shell
Create a Meterpreter payload and handler:
Use H2 command execution to download and run it:
Successful access:
References
https://www.exploit-db.com/exploits/49384
https://github.com/advisories/GHSA-h376-j262-vhq6
Last updated