diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..03cde9bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# /!\ WARNING: the container generated through this Dockerfile is made only for development purpose; it is NOT SAFE or production ready. + +FROM php:5.5-fpm-alpine +MAINTAINER Pierre-Olivier Mercier + +# Install packages #################################################### + +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +RUN chmod +x /usr/local/bin/install-php-extensions && \ + install-php-extensions mysql mcrypt + +# ENVIRONNEMENT ####################################################### + +EXPOSE 80/tcp 443/tcp +VOLUME ["/var/www/fic-server/out","/var/www/fic-server/files","/var/www/fic-server/submission","/var/www/fic-server/shared"] + +WORKDIR /var/www/fic-server + +ENTRYPOINT ["/var/www/fic-server/entrypoint.sh"] + +CMD ["php-fpm"] + +# Copying files ####################################################### + +COPY . /var/www/fic-server/ diff --git a/config.sh b/config.sh new file mode 100644 index 00000000..425da818 --- /dev/null +++ b/config.sh @@ -0,0 +1,16 @@ +# Username of the unpriviledge user that runs scripts +SYNCHRO_USER="synchro" + +BASEDIR="/var/www/fic-server" + +# Directory where backup should be made +if [ -z "$TO_BCKP" ] +then + TO_BCKP="/mnt/backup" +fi + +# Password of the MySQL user backup (with RO rights) +if [ -z "$BCKP_PASS" ] +then + BCKP_PASS="Riuy6of sae^W0Sh" +fi diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 00000000..52b20a95 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# Docker entrypoint + +cd `dirname "$0"` + +. ./config.sh + +# Creating directory and set permissions +mkdir -p ${BASEDIR}/logs ${BASEDIR}/onyx/log +chown -R www-data:www-data ${BASEDIR}/pki ${BASEDIR}/PKI ${BASEDIR}/onyx/log +chown -R ${SYNCHRO_USER}:www-data ${BASEDIR}/submission ${BASEDIR}/logs ${BASEDIR}/out +chmod 770 ${BASEDIR}/submission +chown ${SYNCHRO_USER} ${BASEDIR}/.ssh/id_rsa +chown www-data:www-data ${BASEDIR}/shared ${BASEDIR}/shared/crl.pem + +# Update database profile +cat < ${BASEDIR}/onyx/db/docker.profile.php && +sampledocker0101 /dev/null | grep -oE "/[^/]+/[0-9]+/") + for l in $(curl -k "http://$BASEURL:8080/$SALT_TEAM/" 2> /dev/null | grep -oE "/[^/]+/[0-9]+/") do TEAMS="$TEAMS $l" done @@ -77,24 +77,23 @@ PIDLIST= for l in $TEAMS do ( - if ! wget $WGET_OPT -m "http://$BASEURL/$l" + if ! wget $WGET_OPT -m "http://$BASEURL:8080/$l" then exit 1 fi - for m in $(grep -R "
assign("my_team", $TEAM); @@ -141,6 +141,17 @@ else if ($n && $p[0] == SALT_USER) $page = "teams/lobby"; } + else if (!empty($p[1]) && time() > $VAR["end_challenge"]) + { + $TEAM = new Team($p[1]); + $template->assign("my_team", $TEAM); + $template->assign("themes", Theme::get_themes()); + $template->assign("rank", Team::get_top()); + + require("team/summary.php"); + $page = "teams/end"; + } + else { $TEAM = new Team($p[1]); diff --git a/onyx/include/team/summary.php b/onyx/include/team/summary.php index 556a9298..2e1e36e6 100644 --- a/onyx/include/team/summary.php +++ b/onyx/include/team/summary.php @@ -19,5 +19,6 @@ if (!empty($themes)) $template->assign("themes", Theme::get_themes()); $template->assign("nbExoMax", Exercice::get_nb_exo_max()); $template->assign("percent", $percent); +$template->assign("rank", Team::get_top()); return "teams/summary"; diff --git a/onyx/tpl/bootstrap/admin/exercice.tpl b/onyx/tpl/bootstrap/admin/exercice.tpl index affd82af..cb11fcbe 100644 --- a/onyx/tpl/bootstrap/admin/exercice.tpl +++ b/onyx/tpl/bootstrap/admin/exercice.tpl @@ -3,6 +3,10 @@ {if isset($ex)}

{$theme->name} {$ex->id}

+
+ + +
@@ -85,7 +89,7 @@

diff --git a/onyx/tpl/bootstrap/admin/export_theme.tpl b/onyx/tpl/bootstrap/admin/export_theme.tpl index 208ac16a..5e86eaaa 100644 --- a/onyx/tpl/bootstrap/admin/export_theme.tpl +++ b/onyx/tpl/bootstrap/admin/export_theme.tpl @@ -4,7 +4,7 @@ {if $theme->get_exercices_ordered()} {foreach from=$theme->get_exercices_ordered() item=e} require} depends="{$e->require}"{/if}> - {$e->get_name()} + {$e->get_title()} {$e->points} {$e->statement} {if $e->keys} diff --git a/onyx/tpl/bootstrap/admin/home.tpl b/onyx/tpl/bootstrap/admin/home.tpl index 885c26fe..5ece0731 100644 --- a/onyx/tpl/bootstrap/admin/home.tpl +++ b/onyx/tpl/bootstrap/admin/home.tpl @@ -1,29 +1,55 @@ {extends file="admin/layout.tpl"} {block name=content} -
-
-

Certificat racine

+
+
+
+
+

Certificat racine

+
+
+ {if isset($cert_CA)} +
    + {foreach from=$cert_CA.subject key=k item=crt} +
  • [{$k}] : {$crt}
  • + {/foreach} +
+ Supprimer + {elseif empty($cert_writable)} +
Répertoire non accessible en écriture.
+ Nouveau + {else} + Pas de certificat + Nouveau + {/if} +
+
-
- {if isset($cert)} -
    -
  • [C] : {$cert['subject']['C']}
  • -
  • [ST] : {$cert['subject']['ST']}
  • -
  • [O] : {$cert['subject']['O']}
  • -
  • [OU] : {$cert['subject']['OU']}
  • -
  • [CN] : {$cert['subject']['CN']}
  • -
  • [emailAddress] : {$cert['subject']['emailAddress']}
  • -
- - {elseif isset($cert_writable) && ! $cert_writable} -
Répertoire non accessible en écriture.
- - {else} - Pas de certificat - - {/if} + +
+
+
+

Certificat serveur

+
+
+ {if isset($cert_srv)} +
    + {foreach from=$cert_srv.subject key=k item=crt} +
  • [{$k}] : {$crt}
  • + {/foreach} +
+ Supprimer + {elseif empty($cert_writable)} +
Répertoire non accessible en écriture.
+ Nouveau + {else} + Pas de certificat + Nouveau + {/if} +
+
@@ -36,7 +62,7 @@
- + minutes
@@ -47,4 +73,90 @@
+ +
+
+

Génération

+
+
+
+ + + + + + + + + + + +
File d'attente
Pending...
+
+

+    
+ Complet + Accueil + Pages d'erreurs

+ Synchro légère + Vider la file d'attente

+ Freeze + Unfreeze

+
+
+ + +
+

+
+
+ + +
+
+
+
+
+{/block} +{block name=end2} + {/block} diff --git a/onyx/tpl/bootstrap/admin/import_users.tpl b/onyx/tpl/bootstrap/admin/import_users.tpl index 72ed401c..3ad30fee 100644 --- a/onyx/tpl/bootstrap/admin/import_users.tpl +++ b/onyx/tpl/bootstrap/admin/import_users.tpl @@ -11,8 +11,12 @@ +{if isset($pass)} +

Pass

+
{$pass|escape}
+{/if} {if isset($output)}

Output

-
{$output}
+
{$output|escape}
{/if} {/block} diff --git a/onyx/tpl/bootstrap/admin/layout.tpl b/onyx/tpl/bootstrap/admin/layout.tpl index 05e0b339..ca09d3f0 100644 --- a/onyx/tpl/bootstrap/admin/layout.tpl +++ b/onyx/tpl/bootstrap/admin/layout.tpl @@ -9,13 +9,14 @@ {/block} {block name=end} - + + {block name=end2}{/block} {/block} {block name=body} @@ -39,7 +40,7 @@ {link href_prefix="/{$SALT_ADMIN}/" href="ex/{$t->get_id()}-{$t->get_name()}" class="dropdown-toggle" data-toggle="dropdown" label="{$t->get_name()} "} diff --git a/onyx/tpl/bootstrap/admin/themes.tpl b/onyx/tpl/bootstrap/admin/themes.tpl index 939638d5..be5fa1c7 100644 --- a/onyx/tpl/bootstrap/admin/themes.tpl +++ b/onyx/tpl/bootstrap/admin/themes.tpl @@ -22,7 +22,7 @@ {$t->name} diff --git a/onyx/tpl/bootstrap/admin/users.tpl b/onyx/tpl/bootstrap/admin/users.tpl index 387013bb..65ea20f3 100644 --- a/onyx/tpl/bootstrap/admin/users.tpl +++ b/onyx/tpl/bootstrap/admin/users.tpl @@ -23,7 +23,7 @@ - {if not $t->revoked} + {if not $t->revoked && is_file("{$MISC_DIR}/PKI/pkcs/{$t->team_name}.p12")} diff --git a/onyx/tpl/bootstrap/clock.tpl b/onyx/tpl/bootstrap/clock.tpl index 7cbddfeb..9a4ffb3d 100644 --- a/onyx/tpl/bootstrap/clock.tpl +++ b/onyx/tpl/bootstrap/clock.tpl @@ -1,18 +1,14 @@
    -
  • -
  • :
  • -
  • -
  • :
  • -
  • +
  • Challenge forensic
diff --git a/onyx/tpl/bootstrap/layout.tpl b/onyx/tpl/bootstrap/layout.tpl index 62f5cb44..13b4a6b9 100644 --- a/onyx/tpl/bootstrap/layout.tpl +++ b/onyx/tpl/bootstrap/layout.tpl @@ -4,8 +4,9 @@ {block name=title}Challenge FIC2014{/block} - - + + + - + @@ -40,8 +41,8 @@
--> - - + + {block name=end}{/block} diff --git a/onyx/tpl/bootstrap/public/layout.tpl b/onyx/tpl/bootstrap/public/layout.tpl index 98f98070..917d891e 100644 --- a/onyx/tpl/bootstrap/public/layout.tpl +++ b/onyx/tpl/bootstrap/public/layout.tpl @@ -1,8 +1,7 @@ {extends file="layout.tpl"} {block name=head} - - + {block name=head2}{/block} {/block} @@ -40,7 +39,7 @@ {/block} {block name=end} - + - + + {/block} {block name=body} @@ -28,23 +18,10 @@
- -
{foreach from=$themes item=t key=k} - get_id()}/" href="{$t->get_id()}-{$t->get_name_url()}/"}"> - {$my_team->get_nb_res_exercises_by_theme($t->get_id())}/{$t->get_nb_exercices()} + get_id())}/" href="{$t->get_id()}-{$t->get_name_url()}/"}"> + {$t->get_nb_exercices()} {$t->get_name()} {/foreach} diff --git a/onyx/tpl/bootstrap/teams/list.tpl b/onyx/tpl/bootstrap/teams/list.tpl index d6966738..62735640 100644 --- a/onyx/tpl/bootstrap/teams/list.tpl +++ b/onyx/tpl/bootstrap/teams/list.tpl @@ -4,7 +4,7 @@

Choisissez la team que vous voulez représenter :

{foreach from=$teams item=i}
    -
  • {link href_prefix="/{$SALT_USER}/{$i->id}/" href="" label="{$i->team_name}"}
  • +
  • {link href_prefix="{$SALT_USER}/{$i->id}/" href="" label="{$i->team_name}"}
{/foreach}
diff --git a/onyx/tpl/bootstrap/teams/lobby.tpl b/onyx/tpl/bootstrap/teams/lobby.tpl index 6935b546..039af745 100644 --- a/onyx/tpl/bootstrap/teams/lobby.tpl +++ b/onyx/tpl/bootstrap/teams/lobby.tpl @@ -1,14 +1,13 @@ {extends file="layout.tpl"} {block name=head} - - + {block name=head2}{/block} {/block} {block name=end} - + diff --git a/onyx/tpl/bootstrap/teams/rank.tpl b/onyx/tpl/bootstrap/teams/rank.tpl index b70c546d..5f5c30fc 100644 --- a/onyx/tpl/bootstrap/teams/rank.tpl +++ b/onyx/tpl/bootstrap/teams/rank.tpl @@ -1,24 +1,5 @@ {extends file="teams/layout.tpl"} {block name=content} - - - - - - - - - - - {foreach from=$rank item=t key=k} - id == $my_team->id} class="active" style="font-weight: bold"{/if}> - - - - - - {/foreach} - -
#TeamSloganPoints
{$t->get_rank()}{$t->get_name()}{$t->slogan}{$t->get_pts()}
+ {include file="rank.tpl"} {/block} diff --git a/onyx/tpl/bootstrap/teams/summary.tpl b/onyx/tpl/bootstrap/teams/summary.tpl index cf025cba..78479668 100644 --- a/onyx/tpl/bootstrap/teams/summary.tpl +++ b/onyx/tpl/bootstrap/teams/summary.tpl @@ -1,6 +1,18 @@ {extends file="teams/layout.tpl"} {block name=content} +{if empty($my_team->id)} +
+
+

Challenge forensic Épita 2015

+
+
+ Le challenge s'est déroulé le mardi 20 janvier 2015 lors du Forum International de la Cybercriminalité. Bravo à tous les participants !

+ Consultez la chaîne YouTube d'Épita pour visionner les vidéos de résolutions des exercices. +
+
+{include file="rank.tpl"} +{else} {if isset($percent)}
@@ -17,4 +29,5 @@
{/if} {include file="summary.tpl"} +{/if} {/block} diff --git a/onyx/tpl/bootstrap/teams/theme.tpl b/onyx/tpl/bootstrap/teams/theme.tpl index 14b4052f..1b4cb35e 100644 --- a/onyx/tpl/bootstrap/teams/theme.tpl +++ b/onyx/tpl/bootstrap/teams/theme.tpl @@ -5,12 +5,14 @@

{$cur_theme->get_name()}

{foreach from=$cur_theme->get_exercices_ordered() item=exercice} - {if $exercice->has_solved($my_team)} - {link class="btn btn-success" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}" label="{$exercice->get_name()}"} + {if empty($my_team->id)} + {link class="btn btn-primary" role="button" href_prefix="{$SALT_USER}/{intval($my_team->get_id())}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_name()}"} + {elseif $exercice->has_solved($my_team)} + {link class="btn btn-success" role="button" href_prefix="{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_title(true)}"} {elseif $exercice->is_unlocked($my_team)} - {link class="btn btn-primary" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}" label="{$exercice->get_name()}"} + {link class="btn btn-primary" role="button" href_prefix="{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_title(true)}"} {else} - {$exercice->get_name()} + {$exercice->get_title(true)} {/if} {/foreach}