Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit 7156baf

Browse files
authored
Merge /dev to /master (#605)
Merge `dev` into `master` Commits: * Merge /master into /dev (#543) (ed0a225) * Brazilian Portuguese Filename Fix (#562) (5e28529) * Spanish translations added (#566) (da4d8d1) * Update index.js (#568) (1a8286b) * Travis-CI to use Docker (#569) (b9822ff) * Make sure that requests are not being generated if an error was generated (#565) (37c43e7) * Ensure /root/tmp exists before writing there (#587) (80da145) * Attachment Security Update (#590) (780071b) * Google OAuth Security Update (#591) (7d782d3) * Major Performance Enhancements and Bug Fixes (#594) (d2659ff) * Upgrade from Ubuntu 14.04 (Trusty) to Ubuntu 16.04 (Xenial) (#601) (4dbbf10) * Merge branch 'dev' into WraySec/fbctf/merge@08d0f52
2 parents 1f236bb + 08d0f52 commit 7156baf

File tree

107 files changed

+5226
-1727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5226
-1727
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ www.pid
3131
*.swo
3232

3333
# Attachments directory
34-
src/data/attachments/*
35-
!src/data/attachments/index.php
36-
src/data/attachments/deleted/*
37-
!src/data/attachments/deleted/index.php
34+
attachments/*
35+
!attachments/index.php
36+
attachments/deleted/*
37+
!attachments/deleted/index.php
3838

3939
# Custom logos directory
4040
src/data/customlogos/*

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# We use language generic because that's the only thing that's supported for the
2-
# trusty distro
3-
language: generic
1+
# We are now using Docker to test builds with Travis - this removes our dependency on Ubuntu 14.04
42
sudo: required
5-
dist: trusty
3+
language: generic
64

7-
group: deprecated-2017Q2
5+
services:
6+
- docker
87

9-
install: ./extra/provision.sh -m dev -s $TRAVIS_BUILD_DIR -d $TRAVIS_BUILD_DIR
8+
install:
9+
- docker build --build-arg MODE=dev -t="fbctf_in_travis" .
1010

11-
script: ./extra/run_tests.sh $TRAVIS_BUILD_DIR
11+
script:
12+
- docker run -d -p 80:80 -p 443:443 --name="fbctf_in_travis" fbctf_in_travis
13+
- docker exec fbctf_in_travis /var/www/fbctf/extra/run_tests.sh /var/www/fbctf/

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
FROM ubuntu:trusty
2-
LABEL maintainer="Boik Su <boik@tdohacker.org>"
1+
FROM ubuntu:xenial
32

43
ENV HOME /root
54

@@ -10,9 +9,11 @@ ARG TYPE=self
109
ARG KEY
1110
ARG CRT
1211

12+
ENV HHVM_DISABLE_NUMA true
13+
1314
WORKDIR $HOME
1415
COPY . $HOME
15-
RUN chown www-data:www-data $HOME
1616

17+
RUN apt-get update && apt-get -y install sudo apt-utils
1718
RUN ./extra/provision.sh -m $MODE -c $TYPE -k $KEY -C $CRT -D $DOMAIN -e $EMAIL -s `pwd` --docker
1819
CMD ["./extra/service_startup.sh"]

Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
VAGRANTFILE_API_VERSION = "2"
55

66
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7-
config.vm.box = "ubuntu/trusty64"
7+
config.vm.box = "ubuntu/xenial64"
88
config.vm.network "private_network", ip: "10.10.10.5"
99
config.vm.hostname = "FacebookCTF-Dev"
1010
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

Vagrantfile-multi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
VAGRANTFILE_API_VERSION = "2"
55

66
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7-
config.vm.box = "ubuntu/trusty64"
7+
config.vm.box = "ubuntu/xenial64"
88
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
99

1010
# MySQL Server

Vagrantfile-single

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
VAGRANTFILE_API_VERSION = "2"
55

66
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7-
config.vm.box = "ubuntu/trusty64"
7+
config.vm.box = "ubuntu/xenial64"
88
config.vm.network "private_network", ip: "10.10.10.5"
99
config.vm.hostname = "facebookCTF-Dev"
1010
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"license": "CC-BY-NC-4.0",
55
"require": {
66
"facebook/xhp-lib": "2.x",
7+
"facebook/graph-sdk": "5.x",
78
"google/apiclient": "^2.0"
89
},
910
"require-dev": {

composer.lock

Lines changed: 61 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

database/countries.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ CREATE TABLE `countries` (
1212
`enabled` tinyint(1) DEFAULT 0,
1313
`d` text DEFAULT NULL,
1414
`transform` text DEFAULT NULL,
15-
PRIMARY KEY (`id`)
15+
PRIMARY KEY (`id`),
16+
KEY `iso_code` (`iso_code`),
17+
KEY `enabled` (`enabled`)
1618
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
1719
/*!40101 SET character_set_client = @saved_cs_client */;
1820

@@ -298,4 +300,4 @@ UPDATE `countries` SET enabled = 1 WHERE iso_code = "ZA";
298300
UPDATE `countries` SET enabled = 1 WHERE iso_code = "ZM";
299301
UPDATE `countries` SET enabled = 1 WHERE iso_code = "ZW";
300302
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
301-
UNLOCK TABLES;
303+
UNLOCK TABLES;

database/schema.sql

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CREATE TABLE `levels` (
3636
`id` int(11) NOT NULL AUTO_INCREMENT,
3737
`active` tinyint(1) NOT NULL,
3838
`type` varchar(4) NOT NULL,
39-
`title` text NOT NULL,
39+
`title` varchar(255) NOT NULL,
4040
`description` text NOT NULL,
4141
`entity_id` int(11) NOT NULL,
4242
`category_id` int(11) NOT NULL,
@@ -48,7 +48,9 @@ CREATE TABLE `levels` (
4848
`hint` text NOT NULL,
4949
`penalty` int(11) NOT NULL,
5050
`created_ts` timestamp NOT NULL DEFAULT 0,
51-
PRIMARY KEY (`id`)
51+
PRIMARY KEY (`id`),
52+
KEY `entity_id` (`entity_id`),
53+
KEY `active` (`active`)
5254
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
5355
/*!40101 SET character_set_client = @saved_cs_client */;
5456

@@ -61,7 +63,7 @@ DROP TABLE IF EXISTS `categories`;
6163
/*!40101 SET character_set_client = utf8 */;
6264
CREATE TABLE `categories` (
6365
`id` int(11) NOT NULL AUTO_INCREMENT,
64-
`category` text NOT NULL,
66+
`category` varchar(255) NOT NULL,
6567
`protected` tinyint(1) NOT NULL,
6668
`created_ts` timestamp NOT NULL DEFAULT 0,
6769
PRIMARY KEY (`id`)
@@ -116,16 +118,18 @@ DROP TABLE IF EXISTS `teams`;
116118
CREATE TABLE `teams` (
117119
`id` int(11) NOT NULL AUTO_INCREMENT,
118120
`active` tinyint(1) NOT NULL DEFAULT 1,
119-
`name` text NOT NULL,
120-
`password_hash` text NOT NULL,
121+
`name` varchar(255) NOT NULL,
122+
`password_hash` varchar(255) NOT NULL,
121123
`points` int(11) NOT NULL DEFAULT 0,
122124
`last_score` timestamp NOT NULL,
123125
`logo` text NOT NULL,
124126
`admin` tinyint(1) NOT NULL DEFAULT 0,
125127
`protected` tinyint(1) NOT NULL DEFAULT 0,
126128
`visible` tinyint(1) NOT NULL DEFAULT 1,
127129
`created_ts` timestamp NOT NULL DEFAULT 0,
128-
PRIMARY KEY (`id`)
130+
PRIMARY KEY (`id`),
131+
KEY `visible` (`visible`),
132+
KEY `active` (`active`)
129133
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
130134
/*!40101 SET character_set_client = @saved_cs_client */;
131135

@@ -146,6 +150,22 @@ CREATE TABLE `livesync` (
146150
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
147151
/*!40101 SET character_set_client = @saved_cs_client */;
148152

153+
--
154+
-- Table structure for table `teams_oauth`
155+
--
156+
157+
DROP TABLE IF EXISTS `teams_oauth`;
158+
/*!40101 SET @saved_cs_client = @@character_set_client */;
159+
/*!40101 SET character_set_client = utf8 */;
160+
CREATE TABLE `teams_oauth` (
161+
`id` int(11) NOT NULL AUTO_INCREMENT,
162+
`type` text NOT NULL,
163+
`team_id` int(11) NOT NULL,
164+
`token` text NOT NULL,
165+
PRIMARY KEY (`id`)
166+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
167+
/*!40101 SET character_set_client = @saved_cs_client */;
168+
149169
--
150170
-- Table structure for table `teams_data`
151171
--
@@ -156,10 +176,11 @@ DROP TABLE IF EXISTS `teams_data`;
156176
CREATE TABLE `teams_data` (
157177
`id` int(11) NOT NULL AUTO_INCREMENT,
158178
`team_id` int(11) NOT NULL,
159-
`name` text NOT NULL,
160-
`email` text NOT NULL,
179+
`name` varchar(255) NOT NULL,
180+
`email` varchar(255) NOT NULL,
161181
`created_ts` timestamp NOT NULL DEFAULT 0,
162-
PRIMARY KEY (`id`)
182+
PRIMARY KEY (`id`),
183+
KEY `team_id` (`team_id`)
163184
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
164185
/*!40101 SET character_set_client = @saved_cs_client */;
165186

@@ -172,13 +193,14 @@ DROP TABLE IF EXISTS `sessions`;
172193
/*!40101 SET character_set_client = utf8 */;
173194
CREATE TABLE `sessions` (
174195
`id` int(11) NOT NULL AUTO_INCREMENT,
175-
`cookie` text NOT NULL,
196+
`cookie` varchar(200) NOT NULL,
176197
`data` text NOT NULL,
177198
`team_id` int(11) NOT NULL,
178199
`created_ts` timestamp NOT NULL DEFAULT 0,
179200
`last_access_ts` timestamp NOT NULL,
180-
`last_page_access` text NOT NULL,
181-
PRIMARY KEY (`id`)
201+
`last_page_access` varchar(200) NOT NULL,
202+
PRIMARY KEY (`id`),
203+
KEY `cookie` (`cookie`)
182204
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
183205
/*!40101 SET character_set_client = @saved_cs_client */;
184206

@@ -215,17 +237,25 @@ INSERT INTO `configuration` (field, value, description) VALUES("auto_announce",
215237
INSERT INTO `configuration` (field, value, description) VALUES("progressive_cycle", "300", "(Integer) Frequency to take progressive scoreboard in seconds");
216238
INSERT INTO `configuration` (field, value, description) VALUES("bases_cycle", "5", "(Integer) Frequency to score base levels in seconds");
217239
INSERT INTO `configuration` (field, value, description) VALUES("autorun_cycle", "30", "(Integer) Frequency to cycle autorun in seconds");
240+
INSERT INTO `configuration` (field, value, description) VALUES("gameboard_cycle", "5", "(Integer) Frequency to cycle gameboard in seconds");
241+
INSERT INTO `configuration` (field, value, description) VALUES("conf_cycle", "10", "(Integer) Frequency to cycle configuration and commandline in seconds");
242+
INSERT INTO `configuration` (field, value, description) VALUES("leaderboard_limit", "50", "(Integer) Maximum number of teams to show on the leaderboard");
218243
INSERT INTO `configuration` (field, value, description) VALUES("registration", "0", "(Boolean) Ability to register teams");
219244
INSERT INTO `configuration` (field, value, description) VALUES("registration_names", "0", "(Boolean) Registration will ask for names");
220245
INSERT INTO `configuration` (field, value, description) VALUES("registration_type", "1", "(Integer) Type of registration: 1 - Open; 2 - Tokenized;");
221246
INSERT INTO `configuration` (field, value, description) VALUES("registration_players", "3", "(Integer) Number of players per team");
247+
INSERT INTO `configuration` (field, value, description) VALUES("registration_facebook", "0", "(Boolean) Allow Facebook Registration");
248+
INSERT INTO `configuration` (field, value, description) VALUES("registration_google", "0", "(Boolean) Allow Google Registration");
249+
INSERT INTO `configuration` (field, value, description) VALUES("registration_prefix", "Hacker", "(String) Automated Team Registation Name Prefix");
222250
INSERT INTO `configuration` (field, value, description) VALUES("ldap", "0", "(Boolean) Ability to use LDAP to login");
223251
INSERT INTO `configuration` (field, value, description) VALUES("ldap_server", "ldap://localhost", "(String) LDAP Server");
224252
INSERT INTO `configuration` (field, value, description) VALUES("ldap_port", "389", "(Integer) LDAP Port");
225253
INSERT INTO `configuration` (field, value, description) VALUES("ldap_domain_suffix", "@localhost", "(String) LDAP Domain");
226254
INSERT INTO `configuration` (field, value, description) VALUES("login", "1", "(Boolean) Ability to login");
227255
INSERT INTO `configuration` (field, value, description) VALUES("login_select", "0", "(Boolean) Login selecting the team");
228256
INSERT INTO `configuration` (field, value, description) VALUES("login_strongpasswords", "0", "(Boolean) Enforce using strong passwords");
257+
INSERT INTO `configuration` (field, value, description) VALUES("login_facebook", "0", "(Boolean) Allow Facebook Login");
258+
INSERT INTO `configuration` (field, value, description) VALUES("login_google", "0", "(Boolean) Allow Google Login");
229259
INSERT INTO `configuration` (field, value, description) VALUES("password_type", "1", "(Integer) Type of passwords: See table password_types");
230260
INSERT INTO `configuration` (field, value, description) VALUES("default_bonus", "30", "(Integer) Default value for bonus in levels");
231261
INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec", "10", "(Integer) Default bonus decrement in levels");
@@ -291,12 +321,13 @@ DROP TABLE IF EXISTS `registration_tokens`;
291321
/*!40101 SET character_set_client = utf8 */;
292322
CREATE TABLE `registration_tokens` (
293323
`id` int(11) NOT NULL AUTO_INCREMENT,
294-
`token` text NOT NULL,
324+
`token` varchar(250) NOT NULL,
295325
`used` tinyint(1) NOT NULL,
296326
`team_id` int(11) NOT NULL,
297327
`created_ts` timestamp NOT NULL DEFAULT 0,
298328
`use_ts` timestamp NOT NULL,
299-
PRIMARY KEY (`id`)
329+
PRIMARY KEY (`id`),
330+
KEY `token` (`token`)
300331
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
301332
/*!40101 SET character_set_client = @saved_cs_client */;
302333

@@ -314,7 +345,9 @@ CREATE TABLE `scores_log` (
314345
`points` int(11) NOT NULL,
315346
`level_id` int(11) NOT NULL,
316347
`type` varchar(4) NOT NULL,
317-
PRIMARY KEY (`id`)
348+
PRIMARY KEY (`id`),
349+
KEY `level_id` (`level_id`),
350+
KEY `team_id` (`team_id`)
318351
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
319352
/*!40101 SET character_set_client = @saved_cs_client */;
320353

@@ -331,7 +364,8 @@ CREATE TABLE `bases_log` (
331364
`code` int(11) NOT NULL,
332365
`response` text NOT NULL,
333366
`level_id` int(11) NOT NULL,
334-
PRIMARY KEY (`id`)
367+
PRIMARY KEY (`id`),
368+
KEY `level_id` (`level_id`)
335369
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
336370
/*!40101 SET character_set_client = @saved_cs_client */;
337371

@@ -344,12 +378,16 @@ DROP TABLE IF EXISTS `scripts`;
344378
/*!40101 SET character_set_client = utf8 */;
345379
CREATE TABLE `scripts` (
346380
`id` int(11) NOT NULL AUTO_INCREMENT,
381+
`host` varchar(1024) NOT NULL,
347382
`ts` timestamp NULL,
348383
`pid` int(11) NOT NULL,
349-
`name` text NOT NULL,
384+
`name` varchar(255) NOT NULL,
350385
`cmd` text NOT NULL,
351386
`status` tinyint(1) NOT NULL,
352-
PRIMARY KEY (`id`)
387+
PRIMARY KEY (`id`),
388+
KEY `host` (`host`),
389+
KEY `status` (`status`),
390+
KEY `name` (`name`)
353391
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
354392
/*!40101 SET character_set_client = @saved_cs_client */;
355393

@@ -366,7 +404,9 @@ CREATE TABLE `failures_log` (
366404
`team_id` int(11) NOT NULL,
367405
`level_id` int(11) NOT NULL,
368406
`flag` text NOT NULL,
369-
PRIMARY KEY (`id`)
407+
PRIMARY KEY (`id`),
408+
KEY `team_id` (`team_id`),
409+
KEY `level_id` (`level_id`)
370410
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
371411
/*!40101 SET character_set_client = @saved_cs_client */;
372412

@@ -383,7 +423,9 @@ CREATE TABLE `hints_log` (
383423
`level_id` int(11) NOT NULL,
384424
`team_id` int(11) NOT NULL,
385425
`penalty` int(11) NOT NULL,
386-
PRIMARY KEY (`id`)
426+
PRIMARY KEY (`id`),
427+
KEY `level_id` (`level_id`),
428+
KEY `team_id` (`team_id`)
387429
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
388430
/*!40101 SET character_set_client = @saved_cs_client */;
389431

0 commit comments

Comments
 (0)