-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatabase.sql
69 lines (69 loc) · 2.99 KB
/
database.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
DROP database IF EXISTS `vt_scanned_ips_db`;
CREATE database vt_scanned_ips_db;
use vt_scanned_ips_db;
DROP TABLE `vt_scanned_ips_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_ips_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`scanned_ip` varchar(30) NOT NULL,
`last_scanned_time` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
DROP TABLE IF EXISTS `vt_scanned_resolutions_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_resolutions_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_id` int(11) NOT NULL,
`domain` text NOT NULL,
`scanned_time` text NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ip_id) REFERENCES vt_scanned_ips_table(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
DROP TABLE IF EXISTS `vt_scanned_urls_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_urls_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_id` int(11) NOT NULL,
`url` text NOT NULL,
`detections` text NULL,
`scanned_time` text NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ip_id) REFERENCES vt_scanned_ips_table(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
DROP TABLE IF EXISTS `vt_scanned_downloads_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_downloads_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_id` int(11) NOT NULL,
`hash` text NOT NULL,
`detections` text NULL,
`scanned_time` text NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ip_id) REFERENCES vt_scanned_ips_table(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
DROP TABLE IF EXISTS `vt_scanned_communicating_files_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_communicating_files_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_id` int(11) NOT NULL,
`hash` text NOT NULL,
`detections` text NULL,
`scanned_time` text NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ip_id) REFERENCES vt_scanned_ips_table(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
DROP TABLE IF EXISTS `vt_scanned_referring_files_table`;
CREATE TABLE IF NOT EXISTS `vt_scanned_referring_files_table` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip_id` int(11) NOT NULL,
`hash` text NOT NULL,
`detections` text NULL,
`scanned_time` text NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (ip_id) REFERENCES vt_scanned_ips_table(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
CREATE USER 'theemperor_read'@'localhost' IDENTIFIED WITH mysql_native_password BY '---REDACTED---';
GRANT SELECT ON vt_scanned_ips_db.* TO 'theemperor_read'@'localhost';
CREATE USER 'theemperor_write'@'localhost' IDENTIFIED WITH mysql_native_password BY '---REDACTED---';
GRANT INSERT,SELECT ON vt_scanned_ips_db.* TO 'theemperor_write'@'localhost';
CREATE USER 'theemperor_update'@'localhost' IDENTIFIED WITH mysql_native_password BY '---REDACTED---';
GRANT SELECT,UPDATE ON vt_scanned_ips_db.vt_scanned_ips_table TO 'theemperor_update'@'localhost';
# if mysql version >= 8
#ALTER USER 'theemperor_read'@'localhost' IDENTIFIED BY '---REDACTED---';
#ALTER USER 'theemperor_write'@'localhost' IDENTIFIED BY '---REDACTED---';
#ALTER USER 'theemperor_update'@'localhost' IDENTIFIED BY '---REDACTED---';