Commit e12bf6a4 authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Skynet database definition

parent 21169c76
#* Skynet - Automated "Cloud" Security Scanner *#
#* Copyright (C) 2014-present Jason Frisvold <friz@godshell.com> *#
#* *#
#* This program is free software; you can redistribute it and/or modify *#
#* it under the terms of the GNU General Public License as published by *#
#* the Free Software Foundation; either version 2 of the License, or *#
#* (at your option) any later version. *#
#* *#
#* This program is distributed in the hope that it will be useful, *#
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *#
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *#
#* GNU General Public License for more details. *#
#* *#
#* You should have received a copy of the GNU General Public License *#
#* along with this program; if not, write to the Free Software *#
#* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *#
DROP TABLE IF EXISTS cloud;
CREATE TABLE cloud (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
server_ip INT UNSIGNED NOT NULL, # IP of the server
description TEXT, # Description of the server
ssh_key TEXT, # Location of the SSH key to connect to the server
gpg_key TEXT, # Location of the GPG key to decrypt data
contact_frequency INT NOT NULL DEFAULT 30, # Frequency to contact this server (in minutes)
config_dir VARCHAR(4096) NOT NULL DEFAULT '/opt/skynet/config',
output_dir VARCHAR(4096) NOT NULL DEFAULT '/opt/skynet/output',
ssh_username VARCHAR(32) NOT NULL DEFAULT 'skynet',
last_contacted TIMESTAMP, # Time of last contact with server
disabled TINYINT NOT NULL DEFAULT 0, # Identifies if this entry is disabled
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, # Time this entry was last modified
PRIMARY KEY id (id)
);
DROP TABLE IF EXISTS spawn;
CREATE TABLE spawn (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
options TEXT, # Options to pass to
override TINYINT, # Override allows multiple simultaneous scans
description TEXT, # Description of scan type
disabled TINYINT NOT NULL DEFAULT 0, # Identifies if this entry is disabled
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, # Time this entry was last modified
PRIMARY KEY id (id)
);
DROP TABLE IF EXISTS target;
CREATE TABLE target (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
address INT UNSIGNED NOT NULL, # Network address of target
cidr TINYINT NOT NULL DEFAULT 24, # CIDR prefix of target
description TEXT, # Description of target
disabled TINYINT NOT NULL DEFAULT 0, # Identifies if this entry is disabled
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, # Time this entry was last modified
PRIMARY KEY id (id)
);
DROP TABLE IF EXISTS timers;
CREATE TABLE timers (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
cloud_id INT NOT NULL, # ID of server to use
spawn_id INT NOT NULL, # ID of nmap profile
target_id INT NOT NULL, # ID of target
hour CHAR(8), # Hour to run (0-23 or *, cron notation)
minute CHAR(8), # Minute to run (0-59 or *, cron notation)
day CHAR(8), # Day to run (1-31 or *, cron notation)
month CHAR(8), # Month to run (1-12 or *, cron notation)
description TEXT, # Description of this timer entry
disabled TINYINT NOT NULL DEFAULT 0, # Identifies if this entry is disabled
last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, # Time this entry was last modified
FOREIGN KEY (cloud_id) REFERENCES cloud(id),
FOREIGN KEY (spawn_id) REFERENCES spawn(id),
FOREIGN KEY (target_id) REFERENCES target(id),
PRIMARY KEY id (id)
);
DROP TABLE IF EXISTS keymgmt;
CREATE TABLE keymgmt (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
name CHAR(32) NOT NULL,
type CHAR(20) NOT NULL,
size INTEGER UNSIGNED NOT NULL,
private TEXT NOT NULL,
public TEXT NOT NULL,
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS results;
CREATE TABLE results (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
cloud_id INT,
spawn_id INT,
target_id INT,
filename TEXT,
xml_version FLOAT,
start_time INT,
end_time INT,
elapsed_time FLOAT,
exit_status TEXT,
port_count INT,
FOREIGN KEY (cloud_id) REFERENCES cloud(id),
FOREIGN KEY (spawn_id) REFERENCES spawn(id),
FOREIGN KEY (target_id) REFERENCES target(id),
PRIMARY KEY id (id)
);
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
username CHAR(15) NOT NULL,
password CHAR(60) BINARY NOT NULL,
admin TINYINT UNSIGNED NOT NULL DEFAULT 0,
full_name CHAR(40),
email VARCHAR(320) NOT NULL,
PRIMARY KEY (id),
UNIQUE (username),
INDEX (password));
DROP TABLE IF EXISTS sessions;
CREATE TABLE sessions (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
phpsessid CHAR(32) NOT NULL,
last INTEGER UNSIGNED NOT NULL,
user_id INTEGER UNSIGNED NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id),
INDEX (last),
INDEX (phpsessid)
);
DROP TABLE IF EXISTS spawn_log;
CREATE TABLE spawn_log (
id INT NOT NULL AUTO_INCREMENT, # auto-increment ID
cloud_id INT,
spawn_id INT,
start_time INT,
end_time INT,
status INT,
FOREIGN KEY (cloud_id) REFERENCES cloud(id),
FOREIGN KEY (spawn_id) REFERENCES spawn(id),
PRIMARY KEY id (id)
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment