-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathcpplogging.js
77 lines (65 loc) · 2.16 KB
/
cpplogging.js
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
function LOGGER(name) {
this.name = name;
this.server = "ws://192.168.153.145:8882/fuzz";
this.logData = "";
var logCnt = 0;
var logIdx = 0;
this.log = function(data) {
if (logCnt > 100) {
logIdx++;
logCnt = 0;
}
if (data.substr(0, 2) == "//") {
data = data + "\n";
} else if (data.substr(0, 2) == "/-") {
data = data.substr(2) + "\n";
} else {
data = "try { " + data + " } catch(e){}\n";
}
if (!localStorage[logIdx]) {
localStorage[logIdx] = "";
}
localStorage[logIdx] += data;
logCnt++;
};
this.finished = function() {
};
this.fuzzing = function() {
localStorage.clear();
demiBegin();
};
this.starting = function() {
for (var i = 0; ; i++) {
if (localStorage[i]) {
this.logData += localStorage[i].toString();
} else {
break;
}
}
demicm.websocket = new WebSocket(this.server);
demicm.websocket.onmessage = function(evt) {
console.log("[+] Receive data: " + evt.data);
if (evt.data == "yes" || evt.data == "continue") {
console.log("send log");
if (logger.logData.length > 0) {
var packetLen = 5000;
demicm.websocket.send("logData:" + logger.logData.substr(0, packetLen));
logger.logData = logger.logData.substr(packetLen);
} else {
demicm.websocket.send("logData:" + "end");
}
} else if (evt.data == "no" || evt.data == "finish") {
console.log("start fuzzing");
logger.fuzzing();
} else if (evt.data == "shake") {
demicm.websocket.send("crash?");
} else {
console.log("[*] Warning: websocket onmessage else");
}
};
demicm.websocket.onopen = function(evt) {
console.log("fuzzer name: " + logger.name);
demicm.websocket.send(logger.name);
};
};
}