blob: 85ea8b58ccc96bf07520a692a31266b9c0525d45 (
plain)
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
|
(ns ctf-website.views.home
(:require [ctf-website.views.common :as common]
[ctf-website.models.scoreboard :as scoreboard]
[noir.session :as session])
(:use [noir.core :only [defpage defpartial]]
[hiccup.core :only [h]]))
(defn sorted-flags [scores]
(sort (set (mapcat keys (vals scores)))))
(defn sorted-users [scores]
(sort (keys scores)))
(defpartial
table-header [flag]
[:th flag])
(defpartial
table-cell [scores user flag]
[:td (get (get scores user) flag)])
(defpartial
table-row [scores flags user]
[:tr
[:td user]
(map (partial table-cell scores user) flags)])
(defpartial
scoreboard-table [scores]
(let [flags (sorted-flags scores)
users (sorted-users scores)]
[:table {:border "1"}
[:thead
[:th "Competitor"]
(map table-header flags)]
[:tbody
(map (partial table-row scores flags) users)]]))
(defpage
"/" []
(let [username (session/get :user)]
(common/layout
[:h1 "Austin 2600 CTF server"]
(scoreboard-table (scoreboard/get-scores))
(if (nil? username)
[:a {:href "login"} "Compete"]
[:div ;; as apposed to '(do' i guess
[:form {:method "POST"
:action "flag"}
[:p (str "Submit flag as " (h username) ":")
[:input {:type "text"
:name "flag"
:size "40"}]
[:input {:type "submit"
:value "Submit"}]]]
[:h2 "Welcome Grid Warrior"]
[:p "Test your skills with the challenges below:"]
[:ul
(when (not (scoreboard/has username "test"))
[:li "test flag - b46911b2d927d89bc2b1143a7f5d9c20"])
[:li "exec flag - try to read /home/ctf/flags/exec.flag"]]
]))))
|