- Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets.
52 lines
1.9 KiB
Python
Executable File
52 lines
1.9 KiB
Python
Executable File
SCHEMA = """
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id TEXT PRIMARY KEY,
|
|
username TEXT NOT NULL UNIQUE,
|
|
namespace TEXT NOT NULL DEFAULT '',
|
|
password_hash TEXT NOT NULL,
|
|
created_at TEXT NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS users_created_at ON users (created_at);
|
|
CREATE TABLE IF NOT EXISTS auth_sessions (
|
|
tid TEXT PRIMARY KEY,
|
|
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
expires_at INTEGER NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS auth_sessions_user_id ON auth_sessions (user_id);
|
|
CREATE INDEX IF NOT EXISTS auth_sessions_expires_at ON auth_sessions (expires_at);
|
|
CREATE TABLE IF NOT EXISTS implants (
|
|
id TEXT PRIMARY KEY,
|
|
user_id TEXT NOT NULL REFERENCES users(id),
|
|
display_name TEXT NOT NULL CHECK(length(trim(display_name)) BETWEEN 1 AND 80),
|
|
model TEXT NOT NULL DEFAULT '',
|
|
details TEXT NOT NULL,
|
|
created_at TEXT NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS implants_user_id ON implants (user_id);
|
|
CREATE INDEX IF NOT EXISTS implants_created_at ON implants (created_at);
|
|
CREATE TABLE IF NOT EXISTS implant_telemetry (
|
|
implant_id TEXT PRIMARY KEY REFERENCES implants(id) ON DELETE CASCADE,
|
|
display_name TEXT NOT NULL,
|
|
model TEXT NOT NULL,
|
|
public_key_pem TEXT NOT NULL,
|
|
project_codename TEXT NOT NULL,
|
|
installed_by TEXT NOT NULL
|
|
);
|
|
CREATE TABLE IF NOT EXISTS implant_certificates (
|
|
serial TEXT PRIMARY KEY,
|
|
implant_id TEXT NOT NULL REFERENCES implants(id) ON DELETE CASCADE,
|
|
cert_pem TEXT NOT NULL,
|
|
fingerprint TEXT NOT NULL UNIQUE,
|
|
created_at TEXT NOT NULL,
|
|
not_after TEXT NOT NULL,
|
|
revoked_at TEXT
|
|
);
|
|
CREATE TABLE IF NOT EXISTS implant_challenges (
|
|
nonce TEXT PRIMARY KEY,
|
|
implant_id TEXT NOT NULL REFERENCES implants(id) ON DELETE CASCADE,
|
|
certificate_serial TEXT NOT NULL REFERENCES implant_certificates(serial),
|
|
created_at TEXT NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS implant_challenges_created_at ON implant_challenges (created_at);
|
|
"""
|