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

Making fbctf great again #654

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 4
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
end
7 changes: 5 additions & 2 deletions database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ CREATE TABLE `attachments` (
`created_ts` timestamp NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

-- Temp Fix by having a dummy row to prevent constant SELECT queries
INSERT INTO attachments (filename, type, level_id, created_ts) VALUES ("test", "text/plain", 0, NOW());
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand Down Expand Up @@ -257,8 +260,8 @@ INSERT INTO `configuration` (field, value, description) VALUES("login_strongpass
INSERT INTO `configuration` (field, value, description) VALUES("login_facebook", "0", "(Boolean) Allow Facebook Login");
INSERT INTO `configuration` (field, value, description) VALUES("login_google", "0", "(Boolean) Allow Google Login");
INSERT INTO `configuration` (field, value, description) VALUES("password_type", "1", "(Integer) Type of passwords: See table password_types");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonus", "30", "(Integer) Default value for bonus in levels");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec", "10", "(Integer) Default bonus decrement in levels");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonus", "0", "(Integer) Default value for bonus in levels");
INSERT INTO `configuration` (field, value, description) VALUES("default_bonusdec", "0", "(Integer) Default bonus decrement in levels");
INSERT INTO `configuration` (field, value, description) VALUES("language", "en", "(String) Language of the system");
INSERT INTO `configuration` (field, value, description) VALUES("livesync", "0", "(Boolean) LiveSync functionality");
INSERT INTO `configuration` (field, value, description) VALUES("livesync_auth_key", "", "(String) Optional LiveSync Auth Key");
Expand Down
1 change: 1 addition & 0 deletions extra/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ function install_hhvm() {
local __multiservers=$3

package software-properties-common
package apt-transport-https

log "Adding HHVM keys"
sudo DEBIAN_FRONTEND=noninteractive apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
Expand Down
2 changes: 1 addition & 1 deletion extra/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server {
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

add_header Cache-Control "no-cache, no-store";
add_header Cache-Control "no-cache";
add_header Pragma "no-cache";
expires -1;

Expand Down
2 changes: 1 addition & 1 deletion extra/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ server {
add_header X-Content-Type-Options nosniff;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

add_header Cache-Control "no-cache, no-store";
add_header Cache-Control "no-cache";
add_header Pragma "no-cache";
expires -1;

Expand Down
1 change: 1 addition & 0 deletions extra/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ package_repo_update
package git
package curl
package rsync
package unzip

# Check for available memory, should be over 1GB
AVAILABLE_RAM=`free -mt | grep Total | awk '{print $2}'`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"d3": "^3.5.16",
"dropkickjs": "2.1.10",
"hoverintent-jqplugin": "^0.2.1",
"jquery": "^2.2.3",
"jquery": "^3.0.0",
"keycode": "^2.1.1",
"typed.js": "^1.1.1",
"bxslider": "4.2.6"
Expand Down
2 changes: 1 addition & 1 deletion src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Router {
case 'logout':
// TODO: Make a confirmation modal?
SessionUtils::sessionLogout();
invariant(false, 'should not reach here');
return await (new IndexController())->genRender();
default:
throw new NotFoundRedirectException();
}
Expand Down
2 changes: 0 additions & 2 deletions src/SessionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public static function sessionLogout(): void {
$params["httponly"],
);
session_destroy();

throw new IndexRedirectException();
}

public static function sessionActive(): bool {
Expand Down
32 changes: 21 additions & 11 deletions src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class="fb--conf--language"
$team = await MultiTeam::genTeam($token->getTeamId()); // TODO: Combine Awaits
$token_status =
<span class="highlighted--red">
{tr('Used by')} {$team->getName()}
{tr('Used by')}&nbsp;{$team->getName()}
</span>;
} else {
$token_status =
Expand Down Expand Up @@ -410,11 +410,11 @@ class="fb-cta cta--yellow"
if ($start_ts->getValue() !== '0' && $start_ts->getValue() !== 'NaN') {
$game_start_ts = $start_ts->getValue();
$game_start_array = array();
$game_start_array['year'] = gmdate('Y', $game_start_ts);
$game_start_array['mon'] = gmdate('m', $game_start_ts);
$game_start_array['mday'] = gmdate('d', $game_start_ts);
$game_start_array['hours'] = gmdate('H', $game_start_ts);
$game_start_array['minutes'] = gmdate('i', $game_start_ts);
$game_start_array['year'] = date('Y', $game_start_ts);
$game_start_array['mon'] = date('m', $game_start_ts);
$game_start_array['mday'] = date('d', $game_start_ts);
$game_start_array['hours'] = date('H', $game_start_ts);
$game_start_array['minutes'] = date('i', $game_start_ts);
} else {
$game_start_ts = '0';
$game_start_array['year'] = '0';
Expand All @@ -428,11 +428,11 @@ class="fb-cta cta--yellow"
if ($end_ts->getValue() !== '0' && $end_ts->getValue() !== 'NaN') {
$game_end_ts = $end_ts->getValue();
$game_end_array = array();
$game_end_array['year'] = gmdate('Y', $game_end_ts);
$game_end_array['mon'] = gmdate('m', $game_end_ts);
$game_end_array['mday'] = gmdate('d', $game_end_ts);
$game_end_array['hours'] = gmdate('H', $game_end_ts);
$game_end_array['minutes'] = gmdate('i', $game_end_ts);
$game_end_array['year'] = date('Y', $game_end_ts);
$game_end_array['mon'] = date('m', $game_end_ts);
$game_end_array['mday'] = date('d', $game_end_ts);
$game_end_array['hours'] = date('H', $game_end_ts);
$game_end_array['minutes'] = date('i', $game_end_ts);
} else {
$game_end_ts = '0';
$game_end_array['year'] = '0';
Expand Down Expand Up @@ -1033,6 +1033,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_start_array['year'])}
name="fb--schedule--start_year"
tabindex="1"
/>
</div>
<div class="form-el el--block-label el--full-text">
Expand All @@ -1041,6 +1042,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_end_array['year'])}
name="fb--schedule--end_year"
tabindex="6"
/>
</div>
</div>
Expand All @@ -1051,6 +1053,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_start_array['mon'])}
name="fb--schedule--start_month"
tabindex="2"
/>
</div>
<div class="form-el el--block-label el--full-text">
Expand All @@ -1059,6 +1062,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_end_array['mon'])}
name="fb--schedule--end_month"
tabindex="7"
/>
</div>
</div>
Expand All @@ -1069,6 +1073,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_start_array['mday'])}
name="fb--schedule--start_day"
tabindex="3"
/>
</div>
<div class="form-el el--block-label el--full-text">
Expand All @@ -1077,6 +1082,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_end_array['mday'])}
name="fb--schedule--end_day"
tabindex="8"
/>
</div>
</div>
Expand All @@ -1087,6 +1093,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_start_array['hours'])}
name="fb--schedule--start_hour"
tabindex="4"
/>
</div>
<div class="form-el el--block-label el--full-text">
Expand All @@ -1095,6 +1102,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_end_array['hours'])}
name="fb--schedule--end_hour"
tabindex="9"
/>
</div>
</div>
Expand All @@ -1105,6 +1113,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_start_array['minutes'])}
name="fb--schedule--start_min"
tabindex="5"
/>
</div>
<div class="form-el el--block-label el--full-text">
Expand All @@ -1113,6 +1122,7 @@ class={strval($game_schedule_reset_class)}
type="number"
value={strval($game_end_array['minutes'])}
name="fb--schedule--end_min"
tabindex="10"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class="fb-cta cta--yellow">
$next_game_text = tr('Soon');
$countdown = array('--', '--', '--', '--');
} else {
$next_game_text = date(tr('date and time format'), $next_game);
$next_game_text = date('H:i:s T D m/d/y', $next_game);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes fbctf less customizable.

if we are not using a translation here, a constant string containing the format should be added to the controller ( e.g IndexController::NEXT_GAME_DATE_FORMAT )

$game_start = new DateTime();
$game_start->setTimestamp(intval($next_game));
$now = new DateTime('now');
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ajax/IndexAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ protected function getActions(): array<string> {
// Check if login is disabled and this isn't an admin
if (($login->getValue() === '0') &&
($team === null || $team->getAdmin() === false)) {
return Utils::error_response('Login failed', 'login');
return Utils::error_response('Login closed', 'login');
}

// Otherwise let's login any valid attempt
Expand Down
30 changes: 9 additions & 21 deletions src/controllers/modals/CountryModalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CountryModalController extends ModalController {
<span class="points-label">{tr('PTS')}</span>
</div>
<div class="country-stats">
<dl>
<dl class="pop-up">
<dt>{tr('type')}</dt>
<dd class="country-type"></dd>
<dt>{tr('category')}</dt>
Expand Down Expand Up @@ -86,7 +86,7 @@ class CountryModalController extends ModalController {
</div>
<form class="fb-form country-capture-form">
<input name="level_id" type="hidden" value="" />
<textarea rows={4} class="capture-text" disabled={true}>
<textarea rows={4} class="capture-text" readonly={true}>
</textarea>
<br />
<div class="capture-links"></div>
Expand Down Expand Up @@ -141,13 +141,13 @@ class=
<footer class="modal-footer fb-column-container">
<div
class=
"col col-1-2 country-capture-stats fb-column-container">
"col country-capture-stats fb-column-container">
<div class="points-display">
<span class="points-number fb-numbers"></span>
<span class="points-label">{tr('PTS')}</span>
</div>
<div class="country-stats">
<dl>
<div class="col country-stats">
<dl class="country-window">
<dt>{tr('type')}</dt>
<dd class="country-type"></dd>

Expand All @@ -159,12 +159,6 @@ class=
</dl>
</div>
</div>
<div
class=
"col col-1-2 country-capture-completed fb-column-container">
<span>{tr('completed_by')} &gt;</span>
<ul class="completed-list"></ul>
</div>
</footer>
</div>;

Expand All @@ -185,7 +179,7 @@ class=
</div>
<form class="fb-form country-capture-form">
<input name="level_id" type="hidden" value="" />
<textarea rows={4} class="capture-text" disabled={true}>
<textarea rows={4} class="capture-text" readonly={true}>
</textarea>
<br />
<div class="capture-links"></div>
Expand Down Expand Up @@ -237,13 +231,13 @@ class=
<footer class="modal-footer fb-column-container">
<div
class=
"col col-1-2 country-capture-stats fb-column-container">
"col country-capture-stats fb-column-container">
<div class="points-display">
<span class="points-number fb-numbers"></span>
<span class="points-label">{tr('PTS')}</span>
</div>
<div class="country-stats">
<dl>
<div class="col country-stats">
<dl class="country-window">
<dt>{tr('type')}</dt>
<dd class="country-type"></dd>

Expand All @@ -255,12 +249,6 @@ class=
</dl>
</div>
</div>
<div
class=
"col col-1-2 country-capture-completed fb-column-container">
<span>{tr('completed_by')} &gt;</span>
<ul class="completed-list"></ul>
</div>
</footer>
</div>;
}
Expand Down
12 changes: 4 additions & 8 deletions src/data/country-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CountryDataController extends DataController {
$level->getId(),
),
'links_list' => Link::genAllLinksValues($level->getId()),
'completed_by' => MultiTeam::genCompletedLevelTeamNames(
'completed' => MultiTeam::genCompletedLevel(
$level->getId(),
),
};
Expand All @@ -41,7 +41,7 @@ class CountryDataController extends DataController {
$category = $awaitables_results['category'];
$attachments_list = $awaitables_results['attachments_list'];
$links_list = $awaitables_results['links_list'];
$completed_by = $awaitables_results['completed_by'];
$completed = $awaitables_results['completed'];

invariant(
$country instanceof Country,
Expand All @@ -52,10 +52,6 @@ class CountryDataController extends DataController {
'category should be of type Category',
);

if (!$country) {
continue;
}

if ($level->getHint() !== '') {
// There is hint, can this team afford it?
if ($level->getPenalty() > $my_team->getPoints()) { // Not enough points
Expand Down Expand Up @@ -89,7 +85,7 @@ class CountryDataController extends DataController {
}

// Who is the first owner of this level
if ($completed_by) {
if ($completed) {
$owner = await MultiTeam::genFirstCapture($level->getId()); // TODO: Combine Awaits
$owner = $owner->getName();
} else {
Expand All @@ -104,7 +100,7 @@ class CountryDataController extends DataController {
'bonus' => $level->getBonus(),
'category' => $category->getCategory(),
'owner' => $owner,
'completed' => $completed_by,
'completed' => $completed,
'hint' => $hint,
'hint_cost' => $hint_cost,
'attachments' => $attachments_list,
Expand Down
2 changes: 1 addition & 1 deletion src/inc/gameboard/modules/leaderboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LeaderboardModuleController extends ModuleController {
$leaderboard_ul = <ul></ul>;

list($my_team, $my_rank, $gameboard) = await \HH\Asio\va(
MultiTeam::genTeam(SessionUtils::sessionTeam()),
MultiTeam::genTeam(SessionUtils::sessionTeam(), TRUE),
Team::genMyRank(SessionUtils::sessionTeam()),
Configuration::gen('gameboard'),
);
Expand Down
Loading