19
19
</template >
20
20
</countdown >
21
21
</div >
22
- <div class =" text item" ><a :href =" boardLink" >Scoreboard</a ></div >
23
- <div class =" text item" >Username: {{ username }}</div >
24
- <div class =" text item" >Password: {{ password }}</div >
25
- <el-button @click =" downloadKeyFile" >Download key file</el-button >
22
+ <div class =" row2" >
23
+ <div class =" column2" >
24
+ <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 >
38
+ </div >
39
+ </div >
40
+ </div >
26
41
</el-card >
27
42
</el-col >
28
43
<el-col :span =" 6" >
64
79
&rarr ;
65
80
<a :href =" getGoxyLink(vulnbox)" >Goxy</a >
66
81
</div >
67
- <!-- <br /> -->
68
82
<ul >
69
- <li v-for =" (service_name , j) of vulnbox.services" :key =" j" >
70
- {{ service_name }}:
83
+ <li v-for =" (serviceName , j) of vulnbox.services" :key =" j" >
84
+ {{ serviceName }}:
71
85
<a
72
- :href =" getServiceLink(vulnbox, service_name )"
73
- v-if =" service_map[service_name ].proto === 'http'"
74
- >{{ getServiceLink(vulnbox, service_name ) }}</a
86
+ :href =" getServiceLink(vulnbox, serviceName )"
87
+ v-if =" serviceMap[serviceName ].proto === 'http'"
88
+ >{{ getServiceLink(vulnbox, serviceName ) }}</a
75
89
>
76
90
<span
77
91
v-else
78
92
class =" copiable"
79
- @click =" copyText(getServiceLink(vulnbox, service_name ))"
80
- >{{ getServiceLink(vulnbox, service_name ) }}</span
93
+ @click =" copyText(getServiceLink(vulnbox, serviceName ))"
94
+ >{{ getServiceLink(vulnbox, serviceName ) }}</span
81
95
>
82
96
</li >
83
97
</ul >
@@ -98,7 +112,8 @@ export default {
98
112
services: [],
99
113
game: {},
100
114
endTime: {},
101
- service_map: {}
115
+ serviceMap: {},
116
+ keyContent: " "
102
117
};
103
118
},
104
119
@@ -121,16 +136,28 @@ export default {
121
136
122
137
this .services = this .config .services ;
123
138
for (let service of this .services ) {
124
- this .service_map [service .name ] = service;
139
+ this .serviceMap [service .name ] = service;
125
140
}
126
- } catch {
141
+ this .$notify ({
142
+ title: " Config load" ,
143
+ message: " Success" ,
144
+ type: " success" ,
145
+ duration: 1500
146
+ });
147
+ } catch (e) {
127
148
this .config = {};
149
+ this .$notify ({
150
+ title: " Config load" ,
151
+ message: ` Error: ${ e} ` ,
152
+ type: " error" ,
153
+ duration: 10000
154
+ });
128
155
}
129
156
},
130
157
downloadFile : async function (path , name ) {
131
158
this .$http .get (path).then (response => {
132
- var fileURL = window .URL .createObjectURL (new Blob ([response .data ]));
133
- var fileLink = document .createElement (" a" );
159
+ let fileURL = window .URL .createObjectURL (new Blob ([response .data ]));
160
+ let fileLink = document .createElement (" a" );
134
161
135
162
fileLink .href = fileURL;
136
163
fileLink .setAttribute (" download" , name);
@@ -145,14 +172,30 @@ export default {
145
172
downloadStartSploit : async function () {
146
173
await this .downloadFile (" /start_sploit.py" , " start_sploit.py" );
147
174
},
175
+ uploadKeyFile : async function () {
176
+ try {
177
+ await this .$http .post (" /add_ssh_key/" , { key: this .keyContent });
178
+ this .$notify ({
179
+ title: " Key upload" ,
180
+ message: " Success" ,
181
+ type: " success"
182
+ });
183
+ } catch (e) {
184
+ this .$notify ({
185
+ title: " Key upload" ,
186
+ message: ` Error: ${ e} ` ,
187
+ type: " error"
188
+ });
189
+ }
190
+ },
148
191
getGoxyLink : function (vulnbox ) {
149
192
return ` http://${ this .username } :${ this .password } @${ vulnbox .host } :${ vulnbox .goxy_port } ` ;
150
193
},
151
194
getServiceLink : function (vulnbox , service ) {
152
- if (this .service_map [service].proto === " http" ) {
153
- return ` http://${ vulnbox .host } :${ this .service_map [service].port } ` ;
195
+ if (this .serviceMap [service].proto === " http" ) {
196
+ return ` http://${ vulnbox .host } :${ this .serviceMap [service].port } ` ;
154
197
} else {
155
- return ` ${ vulnbox .host } ${ this .service_map [service].port } ` ;
198
+ return ` ${ vulnbox .host } ${ this .serviceMap [service].port } ` ;
156
199
}
157
200
},
158
201
copyText : function (text ) {
@@ -168,13 +211,23 @@ export default {
168
211
textArea .focus ();
169
212
textArea .select ();
170
213
171
- document .body .removeChild (textArea);
214
+ try {
215
+ document .execCommand (" copy" );
216
+ this .$notify ({
217
+ title: " Text copied to clipboard" ,
218
+ message: text,
219
+ type: " success" ,
220
+ duration: 1500
221
+ });
222
+ } catch (err) {
223
+ this .$notify ({
224
+ title: " Text copy failed" ,
225
+ message: ` Error: ${ err} ` ,
226
+ type: " error"
227
+ });
228
+ }
172
229
173
- this .$notify ({
174
- title: " Text copied to clipboard" ,
175
- message: text,
176
- type: " success"
177
- });
230
+ document .body .removeChild (textArea);
178
231
}
179
232
},
180
233
computed: {
@@ -227,4 +280,12 @@ export default {
227
280
cursor : pointer ;
228
281
color : blue ;
229
282
}
283
+
284
+ .row2 {
285
+ display : flex ;
286
+ }
287
+
288
+ .column2 {
289
+ flex : 50% ;
290
+ }
230
291
</style >
0 commit comments