-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTesterInterface.html
executable file
·204 lines (191 loc) · 5.39 KB
/
TesterInterface.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Commander Tester</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css"
integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M"
crossorigin="anonymous"
/>
</head>
<style>
.button-area {
margin-bottom: 10px;
}
.autosize {
height: 350px;
max-height: auto;
}
.area-arjustement {
width : 150px
}
.gen-marg {
margin : 5px;
padding-left: 5px;
}
.column {
float: left;
width: auto;
padding: 5px;
}
.column-adjustement {
width: 100px;
}
.row::after {
content: "";
width: auto;
clear: both;
display: table;
}
</style>
<body>
<div class="container">
<hr/>
<h4>WSFTP Comminication Tester:</h4>
<hr/>
<form id="makeRequest">
<div class="row ">
<div class="column column-adjustement">
<div class="form-group area-arjustement gen-marg" align="left|center">
<h5>Local IP:</h5>
</div>
</div>
<div class="column">
<input
type="text"
id="ip"
class="form-control"
placeholder="URL"
value="192.168.1.108"/>
</div>
<div class="column">
<div class="button-area">
<input
type="button"
class="btn btn-secondary"
value="Connect"
id="conn"/>
</div>
</div>
</div>
<h5>Command:</h5>
<div class="form-group">
<textarea
id="com"
class="form-control"
placeholder="Post"
spellcheck="false">{"event":"cacp","mac":"bc:ae:c5:13:84:f9","dir":"/home/user/Desktop/tbbt.avi","dest":"/home/other/Desktop","uuid":"dummyid","ip":"192.168.1.105","username":"user"}</textarea>
</div>
<div class="button-area">
<input
type="button"
class="btn btn-secondary"
value="Run"
id="run"/>
</div>
<h5>Log:</h5>
<div class="form-group">
<textarea
id="logs"
class="form-control autosize"
placeholder="console log"
spellcheck="false"></textarea>
</div>
</form>
</div>
<script>
let conOn = 0
let ipDone = false
let myIP = ""
let cmd = "";
let hs = "";
let sr = "";
let msg = "";
let sock = null;
hssock = null;
cmdsock = null;
srsock = null;
msgsock = null;
document.getElementById("conn").addEventListener("click", wsConnect);
document.getElementById("run").addEventListener("click", runCommand);
function wsConnect(e) {
// idk what it is.
e.preventDefault();
// ip arrangements
myIP = document.getElementById("ip").value;
cmd = "ws://" + myIP + ":9997/cmd";
hs = "ws://" + myIP + ":10000/hs";
sr = "ws://" + myIP + ":10003/sr";
msg = "ws://" + myIP + ":10004/msg";
// creating websockets
hssock = new WebSocket(hs);
cmdsock = new WebSocket(cmd);
srsock = new WebSocket(sr);
msgsock = new WebSocket(msg);
ipDone = true
// handshake websocket connection functions
hssock.onopen = function() {
print("connected to hs " + hs)
conOn++
}
hssock.onclose = function(e) {
print("connection closed hs (" + e.code + ")")
conOn--
}
hssock.onmessage = function(e) {
print("HS : " + e.data)
}
// Send/Receive websocket connection functions
srsock.onopen = function() {
print("connected to sr " + sr)
conOn++
}
srsock.onclose = function(e) {
print("connection closed sr (" + e.code + ")")
conOn--
}
srsock.onmessage = function(e) {
print("SR : " + e.data)
}
// Message websocket connection functions
msgsock.onopen = function() {
print("connected to msg " + msg)
conOn++
}
msgsock.onclose = function(e) {
print("connection closed msg (" + e.code + ")")
conOn--
}
msgsock.onmessage = function(e) {
print("MSG : " + e.data)
}
// Commander websocket connection functions
cmdsock.onopen = function() {
print("connected to cmd " + cmd)
conOn++
}
cmdsock.onclose = function(e) {
print("connection closed cmd (" + e.code + ")")
conOn--
}
}
function runCommand(e) {
if (conOn == 4){
var msg = document.getElementById('com').value;
cmdsock.send(msg);
}else{
print("Not Connected!")
}
}
function print(msg){
var textarea = document.getElementById("logs");
textarea.value = textarea.value + msg + "\n";
textarea.scrollTop = textarea.scrollHeight;
}
</script>
</body>
</html>