Skip to content

Commit

Permalink
Merge pull request #8 from vidar-team/dev
Browse files Browse the repository at this point in the history
v0.7.0
  • Loading branch information
wuhan005 authored Aug 13, 2020
2 parents 80191cf + f609696 commit e614802
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 162 deletions.
221 changes: 105 additions & 116 deletions dist/dist_gen.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"rules": {
"no-console": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
Expand Down
16 changes: 14 additions & 2 deletions src/assets/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
"password_empty": "Please input your password"
},
"gamebox": {
"empty": "No Challenge for Now"
"empty": "No Challenge for Now",
"list": "GameBox List",
"team": "Team",
"challenge": "Challenge",
"address": "Address"
},
"flag": {
"submit": "Submit Flag"
"submit_flag": "Submit Flag",
"submit": "Submit",
"input_your_flag": "Please input your flag here..."
},
"log": {
"live_log": "Live Log",
"no_data": "No Data",
"submit_flag": "{to} [ {challenge} ] was attacked by {from}",
"check_down": "{team} [ {challenge} ] down"
},
"timer": {
"not_begin": "The Game is not ready",
Expand Down
16 changes: 14 additions & 2 deletions src/assets/languages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
"password_empty": "请输入密码"
},
"gamebox": {
"empty": "暂时还没有题目哟~"
"empty": "暂时还没有题目哟~",
"list": "所有靶机",
"team": "所属队伍",
"challenge": "所属题目",
"address": "地址"
},
"flag": {
"submit": "提交 Flag"
"submit_flag": "提交 Flag",
"submit": "提交",
"input_your_flag": "请输入你的 Flag"
},
"log": {
"live_log": "实时动态",
"no_data": "暂无动态",
"submit_flag": "{from} 攻陷了 {to} [ {challenge} ]",
"check_down": "{team} [ {challenge} ] 服务宕机"
},
"timer": {
"not_begin": "比赛未开始",
Expand Down
22 changes: 22 additions & 0 deletions src/components/Copyrights.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<v-footer padless>
<v-row justify="center" no-gutters>
<v-col style="font-size: 14px;" class="py-4 text-center white--text" cols="12">
{{ new Date().getFullYear() }} — <strong>Powered by
<a class="white--text" href="https://cardinal.ink/" target="_blank">Cardinal</a>
</strong>
</v-col>
</v-row>
</v-footer>

</template>

<script>
export default {
name: "Copyrights"
}
</script>

<style scoped>
</style>
122 changes: 95 additions & 27 deletions src/components/Info.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,72 @@
<template>
<v-card v-if="info !== null">
<v-list-item two-line>
<v-list-item-content>
<div>
<v-img v-if="info.Logo !== ''" class="logo" :src="`${utils.baseURL}/uploads/${info.Logo}`"></v-img>
<v-list-item-title class="headline">{{info.Name}}</v-list-item-title>
<v-list-item-subtitle>
Token {{ info.Token }}
</v-list-item-subtitle>
</div>
</v-list-item-content>
</v-list-item>

<v-card-text>
<GameBox/>
</v-card-text>
<v-divider/>
<v-card-actions>
<v-list-item>
#{{ info.Rank }} / {{ utils.FormatFloat(info.Score) }} {{$t('general.score')}}
<div>
<v-dialog
v-model="showGameBoxesVisible"
width="700"
>
<v-card>
<v-card-title class="headline">
{{$t('gamebox.list')}}
</v-card-title>

<v-card-text>
<v-simple-table :dense="true">
<template v-slot:default>
<thead>
<tr>
<th class="text-left">{{$t('gamebox.team')}}</th>
<th class="text-left">{{$t('gamebox.challenge')}}</th>
<th class="text-left">{{$t('gamebox.address')}}</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in allGameBoxes" v-bind:key="index">
<td>{{ item.TeamName }}</td>
<td>{{ item.ChallengeName }}</td>
<td>{{ item.IP }}:{{ item.Port }}</td>
</tr>
</tbody>
</template>
</v-simple-table>
</v-card-text>

<v-divider></v-divider>

<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" text @click="showGameBoxesVisible = false">
{{$t('general.close')}}
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>

<v-card v-if="info !== null">
<v-list-item two-line>
<v-list-item-content>
<div>
<v-img v-if="info.Logo !== ''" class="logo"
:src="`${utils.baseURL}/uploads/${info.Logo}`"></v-img>
<v-list-item-title class="headline">{{info.Name}}</v-list-item-title>
<v-list-item-subtitle>
Token {{ info.Token }}
</v-list-item-subtitle>
</div>
</v-list-item-content>
</v-list-item>
<v-btn text/>
</v-card-actions>
</v-card>

<v-card-text>
<GameBox/>
</v-card-text>
<v-divider/>
<v-card-actions>
<v-list-item>
#{{ info.Rank }} / {{ utils.FormatFloat(info.Score) }} {{$t('general.score')}}
</v-list-item>
<v-btn v-if="allGameBoxes !== null" text @click="showGameBoxesVisible = true">靶机列表</v-btn>
</v-card-actions>
</v-card>
</div>
</template>

<script>
Expand All @@ -32,13 +76,37 @@
name: "Info",
data() {
return {
info: null
info: null,
timer: null,
allGameBoxes: null,
showGameBoxesVisible: false,
}
},
mounted() {
this.utils.GET("/team/info").then(res => {
this.info = res
})
this.timer = setInterval(this.getInfo, 5000)
this.getInfo()
this.getAllGameBoxes()
},
beforeDestroy() {
clearInterval(this.timer)
},
methods: {
getInfo() {
this.utils.GET("/team/info").then(res => {
this.info = res
})
},
getAllGameBoxes() {
this.utils.GET("/team/gameboxes/all").then(res => {
this.allGameBoxes = res
}).catch(() => {
this.allGameBoxes = null
})
}
},
components: {GameBox}
}
Expand Down
72 changes: 72 additions & 0 deletions src/components/LiveLog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div>
<v-simple-table :height="200" v-if="logs.length !== 0">
<template v-slot:default>
<tbody>
<tr v-for="(item, index) in logs" v-bind:key="index">
<td>{{ item.message }}</td>
<td width="220px" style="text-align: right;">{{ new Date(item.time * 1000).toLocaleString() }}</td>
</tr>
</tbody>
</template>
</v-simple-table>
<div style="height: 200px;" v-else>
{{$t('log.no_data')}}
</div>
</div>
</template>

<script>
export default {
name: "LiveLog",
data: () => ({
logs: [],
stream: null,
}),
mounted() {
this.getStream()
},
methods: {
getStream() {
this.stream = new EventSource(this.utils.baseURL + '/livelog')
this.stream.onmessage = (event) => {
let data = JSON.parse(event.data)
switch (data['Type']) {
case 'submit_flag':
this.push({
time: data['Time'],
message: this.$t('log.submit_flag', {
'from': data['Message']['From'],
'to': data['Message']['To'],
'challenge': data['Message']['Challenge'],
})
})
break;
case 'check_down':
this.push({
time: data['Time'],
message: this.$t('log.check_down', {
'team': data['Message']['Team'],
'challenge': data['Message']['Challenge'],
})
})
break;
}
};
this.stream.onerror = function (err) {
console.log(err)
};
},
push(data) {
if (this.logs.length > 30) {
this.logs = this.logs.slice(0, 30)
}
this.logs.unshift(data)
}
}
}
</script>

<style scoped>
</style>
61 changes: 52 additions & 9 deletions src/components/SubmitFlag.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
<template>
<v-card class="mx-auto" v-if="info !== null">
<v-card-title>{{$t('flag.submit')}}</v-card-title>
<v-snackbar v-model="snackBarVisible" :color="snackBarColor" :timeout="3000" :top="true">{{ message }}
</v-snackbar>

<v-card-title>
<span style="margin-right: 20px;">{{$t('flag.submit_flag')}}</span>
<v-text-field
@keyup.enter.native="submitFlag"
v-model="inputFlag"
:label="$t('flag.input_your_flag')"
clearable
></v-text-field>
<v-btn style="margin-left: 20px;" @click="submitFlag">
{{$t('flag.submit')}}
</v-btn>
</v-card-title>
<v-card-text>
<h2>POST <code style="background-color: #1c1c1c">/flag</code></h2><br>
<p>Content-Type: application/json</p>
<p>Header:
<pre>Authorization: {{info.Token}}</pre>
</p>
<p>Body:</p>
<span><b>Header</b></span><br>
<span>Content-Type: application/json</span><br>
<span>Authorization: {{info.Token}}</span><br>
<p><b>Body</b></p>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">{"flag":
"your_flag_here"}</code>
<br><br>
<v-divider></v-divider>
<br>
<p>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">curl
-X POST {{baseURL}}/api/flag -H 'Authorization: {{info.Token}}' -d '{ "flag": "your_flag_here" }'</code>
<code class="pa-3" style="width: 100%; background-color: #1c1c1c; color: rgba(255, 255, 255, 0.7);">{{getCurlCommand()}}</code>
</p>
</v-card-text>
</v-card>
</template>

<script>
import axios from "axios";
export default {
name: "SubmitFlag",
data: () => ({
info: null,
baseURL: window.location.origin,
inputFlag: '',
message: '',
snackBarVisible: false,
snackBarColor: 'success',
}),
mounted() {
Expand All @@ -39,6 +57,31 @@
this.utils.GET("/team/info").then(res => {
this.info = res
})
},
submitFlag() {
axios.post(this.utils.baseURL + '/flag', {
'flag': this.inputFlag
}, {
headers: {
'Authorization': this.info.Token
}
}).then(res => {
this.inputFlag = ''
this.message = res.data.data
this.snackBarColor = 'success'
this.snackBarVisible = true
}).catch(err => {
this.message = err.response.data.msg
this.snackBarColor = 'error'
this.snackBarVisible = true
});
},
getCurlCommand() {
// The curl command is different in windows and *nix os.
if ((navigator.platform === "Win32") || (navigator.platform === "Windows")) {
return `curl -X POST ${window.location.origin}/api/flag -H "Authorization: ${this.info.Token}" -d "{ \\"flag\\": \\"your_flag_here\\" }"`
}
return `curl -X POST ${window.location.origin}/api/flag -H 'Authorization: ${this.info.Token}' -d '{ "flag": "your_flag_here" }'`
}
}
}
Expand Down
Loading

0 comments on commit e614802

Please sign in to comment.