Skip to content

Commit 04545d7

Browse files
Merge pull request #2 from C4T-BuT-S4D/ssh-copy-id
Copy ssh key
2 parents d86c296 + bf8d3a3 commit 04545d7

File tree

11 files changed

+204
-160
lines changed

11 files changed

+204
-160
lines changed

front/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "front",
2+
"name": "cbs-dash",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {

front/public/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
77
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8-
<title><%= htmlWebpackPlugin.options.title %></title>
8+
<title>CBS Dashboard</title>
99
</head>
1010
<body>
1111
<noscript>
12-
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
12+
<strong>We're sorry but CBS Dash doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
1313
</noscript>
1414
<div id="app"></div>
1515
<!-- built files will be auto injected -->

front/src/components/Dashboard.vue

+87-26
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,25 @@
1919
</template>
2020
</countdown>
2121
</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>
2641
</el-card>
2742
</el-col>
2843
<el-col :span="6">
@@ -64,20 +79,19 @@
6479
&rarr;
6580
<a :href="getGoxyLink(vulnbox)">Goxy</a>
6681
</div>
67-
<!-- <br /> -->
6882
<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 }}:
7185
<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
7589
>
7690
<span
7791
v-else
7892
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
8195
>
8296
</li>
8397
</ul>
@@ -98,7 +112,8 @@ export default {
98112
services: [],
99113
game: {},
100114
endTime: {},
101-
service_map: {}
115+
serviceMap: {},
116+
keyContent: ""
102117
};
103118
},
104119
@@ -121,16 +136,28 @@ export default {
121136
122137
this.services = this.config.services;
123138
for (let service of this.services) {
124-
this.service_map[service.name] = service;
139+
this.serviceMap[service.name] = service;
125140
}
126-
} catch {
141+
this.$notify({
142+
title: "Config load",
143+
message: "Success",
144+
type: "success",
145+
duration: 1500
146+
});
147+
} catch (e) {
127148
this.config = {};
149+
this.$notify({
150+
title: "Config load",
151+
message: `Error: ${e}`,
152+
type: "error",
153+
duration: 10000
154+
});
128155
}
129156
},
130157
downloadFile: async function(path, name) {
131158
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");
134161
135162
fileLink.href = fileURL;
136163
fileLink.setAttribute("download", name);
@@ -145,14 +172,30 @@ export default {
145172
downloadStartSploit: async function() {
146173
await this.downloadFile("/start_sploit.py", "start_sploit.py");
147174
},
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+
},
148191
getGoxyLink: function(vulnbox) {
149192
return `http://${this.username}:${this.password}@${vulnbox.host}:${vulnbox.goxy_port}`;
150193
},
151194
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}`;
154197
} else {
155-
return `${vulnbox.host} ${this.service_map[service].port}`;
198+
return `${vulnbox.host} ${this.serviceMap[service].port}`;
156199
}
157200
},
158201
copyText: function(text) {
@@ -168,13 +211,23 @@ export default {
168211
textArea.focus();
169212
textArea.select();
170213
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+
}
172229
173-
this.$notify({
174-
title: "Text copied to clipboard",
175-
message: text,
176-
type: "success"
177-
});
230+
document.body.removeChild(textArea);
178231
}
179232
},
180233
computed: {
@@ -227,4 +280,12 @@ export default {
227280
cursor: pointer;
228281
color: blue;
229282
}
283+
284+
.row2 {
285+
display: flex;
286+
}
287+
288+
.column2 {
289+
flex: 50%;
290+
}
230291
</style>

front/src/components/HelloWorld.vue

-130
This file was deleted.

front/src/plugins/element.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from "vue";
22
import Element from "element-ui";
33
import "element-ui/lib/theme-chalk/index.css";
4-
import { Button, Card, Container, Main, Header, Row } from "element-ui";
4+
import { Button, Card, Container, Main, Header, Row, Input } from "element-ui";
55

66
Vue.use(Element);
77
Vue.use(Button);
@@ -10,3 +10,4 @@ Vue.use(Container);
1010
Vue.use(Main);
1111
Vue.use(Header);
1212
Vue.use(Row);
13+
Vue.use(Input);

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ require (
66
github.com/gin-contrib/cors v1.3.1
77
github.com/gin-contrib/gzip v0.0.3
88
github.com/gin-gonic/gin v1.6.3
9+
github.com/pkg/sftp v1.12.0
910
github.com/sirupsen/logrus v1.7.0
1011
github.com/spf13/pflag v1.0.5
1112
github.com/spf13/viper v1.7.1
13+
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
1214
)

0 commit comments

Comments
 (0)