Skip to content

Commit 266bb3b

Browse files
Front for Neo integration, minor redesign
1 parent b18b013 commit 266bb3b

File tree

4 files changed

+88
-64
lines changed

4 files changed

+88
-64
lines changed

front/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"axios": "^0.21.0",
1212
"core-js": "^3.6.5",
1313
"element-ui": "^2.14.1",
14+
"moment": "^2.29.1",
1415
"vue": "^2.6.11",
1516
"vue-awesome-countdown": "^1.1.4",
1617
"vue-router": "^3.2.0",

front/src/components/Dashboard.vue

+71-62
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<el-row :gutter="26">
3-
<el-col :span="6">
3+
<el-col :span="8">
44
<el-card>
55
<div slot="header" class="clearfix">
66
<span class="header-text">Game info</span>
@@ -19,52 +19,45 @@
1919
</template>
2020
</countdown>
2121
</div>
22-
<div class="row2">
23-
<div class="column2">
22+
<el-row :gutter="10">
23+
<el-col :span="12">
2424
<div class="text item"><a :href="boardLink">Scoreboard</a></div>
25-
<div class="text item">Username: {{ username }}</div>
26-
<div class="text item">Password: {{ password }}</div>
27-
<el-button @click="downloadKeyFile">Download key file</el-button>
28-
</div>
29-
<div class="column2">
30-
<div>
31-
<el-input
32-
:rows="4"
33-
type="textarea"
34-
placeholder="Enter ssh public key"
35-
v-model="keyContent"
36-
></el-input>
37-
<el-button @click="uploadKeyFile">Upload key</el-button>
25+
<div class="text item"><a :href="mongolLink">MonGol</a></div>
26+
<div class="text item">
27+
Username:
28+
<span class="copiable" @click="copyText(`${username}`)">{{
29+
username
30+
}}</span>
3831
</div>
39-
</div>
40-
</div>
41-
</el-card>
42-
</el-col>
43-
<el-col :span="6">
44-
<el-card>
45-
<div slot="header" class="clearfix">
46-
<span class="header-text">Mongol</span>
47-
<a :href="mongolLink" style="float: right; padding: 3px 0" type="text"
48-
>Open</a
49-
>
50-
</div>
51-
<div class="text item">Credentials are the same</div>
32+
<div class="text item">
33+
Password:
34+
<span class="copiable" @click="copyText(`${password}`)">{{
35+
password
36+
}}</span>
37+
</div>
38+
</el-col>
39+
</el-row>
5240
</el-card>
5341
</el-col>
54-
<el-col :span="6">
42+
<el-col :span="8">
5543
<el-card>
5644
<div slot="header" class="clearfix">
5745
<span class="header-text">Farm</span>
5846
<a :href="farmLink" style="float: right; padding: 3px 0" type="text"
5947
>Open</a
6048
>
6149
</div>
62-
<el-button @click="downloadStartSploit"
63-
>Download start sploit</el-button
64-
>
50+
<el-row justify="space-around" type="flex">
51+
<el-button :span="6" @click="downloadNeoRunner"
52+
>🖨️ Neo runner
53+
</el-button>
54+
<el-button :span="6" @click="downloadStartSploit"
55+
>🖨️ Start sploit
56+
</el-button>
57+
</el-row>
6558
</el-card>
6659
</el-col>
67-
<el-col :span="6">
60+
<el-col :span="8">
6861
<el-card>
6962
<div slot="header" class="clearfix">
7063
<span class="header-text">Vulnboxes</span>
@@ -80,39 +73,56 @@
8073
<a :href="getGoxyLink(vulnbox)">Goxy</a>
8174
</div>
8275
<ul>
83-
<li v-for="(serviceName, j) of vulnbox.services" :key="j">
84-
{{ serviceName }}:
76+
<li v-for="(service, j) of vulnbox.services" :key="j">
77+
{{ service.name }}:
8578
<a
86-
:href="getServiceLink(vulnbox, serviceName)"
87-
v-if="serviceMap[serviceName].proto === 'http'"
88-
>{{ getServiceLink(vulnbox, serviceName) }}</a
79+
v-if="service.proto === 'http'"
80+
:href="getServiceLink(vulnbox, service)"
81+
>{{ getServiceLink(vulnbox, service) }}</a
8982
>
9083
<span
9184
v-else
9285
class="copiable"
93-
@click="copyText(getServiceLink(vulnbox, serviceName))"
94-
>{{ getServiceLink(vulnbox, serviceName) }}</span
86+
@click="copyText(getServiceLink(vulnbox, service))"
87+
>{{ getServiceLink(vulnbox, service) }}</span
9588
>
9689
</li>
9790
</ul>
9891
</div>
92+
<div>
93+
<el-row>
94+
<el-input
95+
v-model="keyContent"
96+
:rows="4"
97+
placeholder="Enter ssh public key"
98+
style="margin-bottom: 10px"
99+
type="textarea"
100+
></el-input>
101+
</el-row>
102+
<el-row justify="center" type="flex">
103+
<el-button :span="8" @click="uploadKeyFile">Upload key</el-button>
104+
<el-button :span="8" @click="downloadKeyFile"
105+
>Download key file
106+
</el-button>
107+
</el-row>
108+
</div>
99109
</el-card>
100110
</el-col>
101111
</el-row>
102112
</template>
103113

104114
<script>
115+
import moment from "moment";
116+
105117
export default {
106118
data: function() {
107119
return {
108120
config: null,
109121
username: "",
110122
password: "",
111123
vulnboxes: [],
112-
services: [],
113124
game: {},
114125
endTime: {},
115-
serviceMap: {},
116126
keyContent: ""
117127
};
118128
},
@@ -131,18 +141,14 @@ export default {
131141
this.vulnboxes = this.config.vulnboxes;
132142
133143
this.game = this.config.game;
134-
this.endTime = new Date(this.game.end);
144+
this.endTime = moment(this.game.end);
135145
console.log(this.endTime);
136146
137-
this.services = this.config.services;
138-
for (let service of this.services) {
139-
this.serviceMap[service.name] = service;
140-
}
141147
this.$notify({
142148
title: "Config load",
143149
message: "Success",
144150
type: "success",
145-
duration: 1500
151+
duration: 1000
146152
});
147153
} catch (e) {
148154
this.config = {};
@@ -155,7 +161,8 @@ export default {
155161
}
156162
},
157163
downloadFile: async function(path, name) {
158-
this.$http.get(path).then(response => {
164+
try {
165+
const response = await this.$http.get(path);
159166
let fileURL = window.URL.createObjectURL(new Blob([response.data]));
160167
let fileLink = document.createElement("a");
161168
@@ -164,14 +171,24 @@ export default {
164171
document.body.appendChild(fileLink);
165172
166173
fileLink.click();
167-
});
174+
} catch (e) {
175+
this.$notify({
176+
title: "Download file",
177+
message: `Error downloading ${name}: ${e}`,
178+
type: "error",
179+
duration: 3000
180+
});
181+
}
168182
},
169183
downloadKeyFile: async function() {
170184
await this.downloadFile("/key_file", "ssh_key");
171185
},
172186
downloadStartSploit: async function() {
173187
await this.downloadFile("/start_sploit.py", "start_sploit.py");
174188
},
189+
downloadNeoRunner: async function() {
190+
await this.downloadFile("/run_neo.sh", "run_neo.sh");
191+
},
175192
uploadKeyFile: async function() {
176193
try {
177194
await this.$http.post("/add_ssh_key/", { key: this.keyContent });
@@ -192,10 +209,10 @@ export default {
192209
return `http://${this.username}:${this.password}@${vulnbox.host}:${vulnbox.goxy_port}`;
193210
},
194211
getServiceLink: function(vulnbox, service) {
195-
if (this.serviceMap[service].proto === "http") {
196-
return `http://${vulnbox.host}:${this.serviceMap[service].port}`;
212+
if (service.proto === "http") {
213+
return `http://${vulnbox.host}:${service.port}`;
197214
} else {
198-
return `${vulnbox.host} ${this.serviceMap[service].port}`;
215+
return `${vulnbox.host} ${service.port}`;
199216
}
200217
},
201218
copyText: function(text) {
@@ -280,12 +297,4 @@ export default {
280297
cursor: pointer;
281298
color: blue;
282299
}
283-
284-
.row2 {
285-
display: flex;
286-
}
287-
288-
.column2 {
289-
flex: 50%;
290-
}
291300
</style>

front/src/plugins/element.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import Vue from "vue";
2-
import Element from "element-ui";
2+
import Element, {
3+
Button,
4+
Card,
5+
Col,
6+
Container,
7+
Header,
8+
Input,
9+
Main,
10+
Row
11+
} from "element-ui";
312
import "element-ui/lib/theme-chalk/index.css";
4-
import { Button, Card, Container, Main, Header, Row, Input } from "element-ui";
513

614
Vue.use(Element);
715
Vue.use(Button);
@@ -10,4 +18,5 @@ Vue.use(Container);
1018
Vue.use(Main);
1119
Vue.use(Header);
1220
Vue.use(Row);
21+
Vue.use(Col);
1322
Vue.use(Input);

front/yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -5516,6 +5516,11 @@ mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1:
55165516
dependencies:
55175517
minimist "^1.2.5"
55185518

5519+
moment@^2.29.1:
5520+
version "2.29.1"
5521+
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
5522+
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==
5523+
55195524
move-concurrently@^1.0.1:
55205525
version "1.0.1"
55215526
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"

0 commit comments

Comments
 (0)