forked from catsay217994/CTFd_zh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctfb.sql
244 lines (224 loc) · 10.6 KB
/
ctfb.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
Navicat Premium Data Transfer
Source Server : localhost_123456
Source Server Type : MySQL
Source Server Version : 50560
Source Host : localhost:3306
Source Schema : ctfb
Target Server Type : MySQL
Target Server Version : 50560
File Encoding : 65001
Date: 19/07/2018 10:44:13
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for alembic_version
-- ----------------------------
DROP TABLE IF EXISTS `alembic_version`;
CREATE TABLE `alembic_version` (
`version_num` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
PRIMARY KEY (`version_num`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for awards
-- ----------------------------
DROP TABLE IF EXISTS `awards`;
CREATE TABLE `awards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`teamid` int(11) NULL DEFAULT NULL,
`name` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`date` datetime NULL DEFAULT NULL,
`value` int(11) NULL DEFAULT NULL,
`category` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`icon` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `teamid`(`teamid`) USING BTREE,
CONSTRAINT `awards_ibfk_1` FOREIGN KEY (`teamid`) REFERENCES `teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for challenges
-- ----------------------------
DROP TABLE IF EXISTS `challenges`;
CREATE TABLE `challenges` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`value` int(11) NULL DEFAULT NULL,
`category` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`hidden` tinyint(1) NULL DEFAULT NULL,
`type` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`max_attempts` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for config
-- ----------------------------
DROP TABLE IF EXISTS `config`;
CREATE TABLE `config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`key` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 33 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for files
-- ----------------------------
DROP TABLE IF EXISTS `files`;
CREATE TABLE `files` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chal` int(11) NULL DEFAULT NULL,
`location` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `chal`(`chal`) USING BTREE,
CONSTRAINT `files_ibfk_1` FOREIGN KEY (`chal`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for hints
-- ----------------------------
DROP TABLE IF EXISTS `hints`;
CREATE TABLE `hints` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` int(11) NULL DEFAULT NULL,
`chal` int(11) NULL DEFAULT NULL,
`hint` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`cost` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `chal`(`chal`) USING BTREE,
CONSTRAINT `hints_ibfk_1` FOREIGN KEY (`chal`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for keys
-- ----------------------------
DROP TABLE IF EXISTS `keys`;
CREATE TABLE `keys` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chal` int(11) NULL DEFAULT NULL,
`type` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`flag` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `chal`(`chal`) USING BTREE,
CONSTRAINT `keys_ibfk_1` FOREIGN KEY (`chal`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for pages
-- ----------------------------
DROP TABLE IF EXISTS `pages`;
CREATE TABLE `pages` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`route` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`html` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`auth_required` tinyint(1) NULL DEFAULT NULL,
`draft` tinyint(1) NULL DEFAULT NULL,
`title` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `route`(`route`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for solves
-- ----------------------------
DROP TABLE IF EXISTS `solves`;
CREATE TABLE `solves` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chalid` int(11) NULL DEFAULT NULL,
`teamid` int(11) NULL DEFAULT NULL,
`ip` varchar(46) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`flag` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`date` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `chalid`(`chalid`, `teamid`) USING BTREE,
INDEX `teamid`(`teamid`) USING BTREE,
CONSTRAINT `solves_ibfk_1` FOREIGN KEY (`chalid`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `solves_ibfk_2` FOREIGN KEY (`teamid`) REFERENCES `teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for tags
-- ----------------------------
DROP TABLE IF EXISTS `tags`;
CREATE TABLE `tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chal` int(11) NULL DEFAULT NULL,
`tag` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `chal`(`chal`) USING BTREE,
CONSTRAINT `tags_ibfk_1` FOREIGN KEY (`chal`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for teams
-- ----------------------------
DROP TABLE IF EXISTS `teams`;
CREATE TABLE `teams` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`email` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`password` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`website` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`affiliation` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`country` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`bracket` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`banned` tinyint(1) NULL DEFAULT NULL,
`verified` tinyint(1) NULL DEFAULT NULL,
`admin` tinyint(1) NULL DEFAULT NULL,
`joined` datetime NULL DEFAULT NULL,
`solves_count` int(255) NULL DEFAULT 0,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `email`(`email`) USING BTREE,
UNIQUE INDEX `name`(`name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for tracking
-- ----------------------------
DROP TABLE IF EXISTS `tracking`;
CREATE TABLE `tracking` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(46) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`team` int(11) NULL DEFAULT NULL,
`date` datetime NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `team`(`team`) USING BTREE,
CONSTRAINT `tracking_ibfk_1` FOREIGN KEY (`team`) REFERENCES `teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for unlocks
-- ----------------------------
DROP TABLE IF EXISTS `unlocks`;
CREATE TABLE `unlocks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`teamid` int(11) NULL DEFAULT NULL,
`date` datetime NULL DEFAULT NULL,
`itemid` int(11) NULL DEFAULT NULL,
`model` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `teamid`(`teamid`) USING BTREE,
CONSTRAINT `unlocks_ibfk_1` FOREIGN KEY (`teamid`) REFERENCES `teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Table structure for wrong_keys
-- ----------------------------
DROP TABLE IF EXISTS `wrong_keys`;
CREATE TABLE `wrong_keys` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chalid` int(11) NULL DEFAULT NULL,
`teamid` int(11) NULL DEFAULT NULL,
`date` datetime NULL DEFAULT NULL,
`flag` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL,
`ip` varchar(46) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `chalid`(`chalid`) USING BTREE,
INDEX `teamid`(`teamid`) USING BTREE,
CONSTRAINT `wrong_keys_ibfk_1` FOREIGN KEY (`chalid`) REFERENCES `challenges` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `wrong_keys_ibfk_2` FOREIGN KEY (`teamid`) REFERENCES `teams` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Compact;
-- ----------------------------
-- Triggers structure for table solves
-- ----------------------------
DROP TRIGGER IF EXISTS `solves_abb1`;
delimiter ;;
CREATE TRIGGER `solves_abb1` AFTER INSERT ON `solves` FOR EACH ROW BEGIN
UPDATE teams SET teams.solves_count=solves_count+1 WHERE teams.id=new.teamid;
END
;;
delimiter ;
SET FOREIGN_KEY_CHECKS = 1;