tkh4ck.github.io

Personal website and blog of tkh4ck

View on GitHub

Hexordia Weekly CTF - Android - Week 4 - TEaM U prep

What item that Rocco was shopping for came back in stock?

Solution

Temu application screenshot

$ ls -a data/data/com.einnovation.temu/databases/
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mall_1.db
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mall_1.db-shm
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mall_1.db-wal
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mallLocal_6.db
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mallLocal_6.db-shm
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_mallLocal_6.db-wal
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_msgbox_2.db
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_msgbox_2.db-shm
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_msgbox_2.db-wal
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_platform_3.db
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_platform_3.db-shm
ChatDB_BCM6G5ASA5K73AN2N7S3TQYUS2MOBTVG2RFRUULJ_platform_3.db-wal
[...]

sqlitebrowser

Mason jars

import sqlite3
import sys
import pathlib
import re

root = pathlib.Path(sys.argv[1])
app = 'com.einnovation.temu'
databases_folder = root / f'data/data/{app}/databases/'

databases = []
for db in databases_folder.iterdir():
    m = re.search('ChatDB_.*_msgbox_2\.db',str(db))
    if m is not None:
        databases.append(m.group())
assert(len(databases) == 1)

database = databases_folder / databases[0]
assert(database.exists())

connection = sqlite3.connect(database)
sql = "select summary from message"

cursor = connection.cursor()
rows = cursor.execute(sql).fetchall()
assert(len(rows) >= 1)

for row in rows:
    print(row[0])

Flag: mason jar