-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.js
203 lines (197 loc) · 6.36 KB
/
bin.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
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
var bin = new Array();
var helptxt = new Array();
helptxt['about'] = "esage: licence<br><br> Prints information about this system";
helptxt['date'] = "usage: date<br><br> Prints the date and time";
helptxt['eval'] = "usage: eval [expr]<br><br> Prints the result of javascript eval(expr)<br> Prompts for expr if not specified";
//helptxt['fullscreen'] = "usage: fullscreen<br><br> Elarges the browser window to the entire screen";
helptxt['info'] = "usage: info<br><br> Prints information about your browser";
helptxt['open'] = "usage: open [URL]<br><br> Opens the specified URL";
helptxt['random'] = "usage: random [n]<br><br> Prints a random number between 0 and n (default 1)";
helptxt['randint'] = "usage: randint [n]<br><br> Prints a random integer between 0 and n (default 1)";
helptxt['server'] = new Array();
helptxt['server']['date'] = "usage: server date<br><br> Prints the server date and time";
helptxt['server']['md5'] = "usage: server md5 [str]<br><br> Prints the MD5 of the specified string<br> Prompts for string using a password field if not specified";
helptxt['server']['sha256'] = "usage: server sha256 [str]<br><br> Prints the SHA256 of the specified string<br> Prompts for string using a password field if not specified";
helptxt['server']['sha512'] = "usage: server sha512 [str]<br><br> Prints the SHA512 of the specified string<br> Prompts for string using a password field if not specified";
helptxt['server']['myinfo'] = "usage: server myinfo<br><br> Prints information about your connection";
helptxt['server']['test'] = "usage: server test<br><br> Tests server communication";
function Executable(console,cmdline) {
this.cmdline = cmdline;
this.con = console;
this.output=function(txt) {
this.con.output(txt);
}
this.addPrompt=function(txt,onCR,type) {
this.con.addPrompt(txt,onCR,type);
}
this.cmd = cmdargs(cmdline)[0];
this.args = cmdargs(cmdline)[1];
this.start = function() {
if (typeof(bin[this.cmd])==="undefined") {
this.run = undefined;
return null;
} else {
this.run = bin[this.cmd];
this.run.args = this.args;
}
}
}
bin['sh'] = function() {
if (isBad(this.args) || this.args=="") {
this.con.addPrompt("$ ", "sh", "echo");
} else if (this.args=="exit") {
return null;
} else {
sys.exec(this.args);
}
}
bin['clear'] = function() {
this.con.clear();
}
bin['date'] = function() {
this.output(Date());
}
bin['help'] = function() {
var topic;
if (isBad(this.args) || this.args=="") {
topic = "help";
} else if (this.args.indexOf("server")===0) {
topic = "server";
} else {
topic = this.args;
}
switch(topic) {
case 'help':
this.output("Help is available for:");
this.output("");
for (key in helptxt) {
this.output(" "+key);
}
break;
case 'server':
if (sys.server.xmlhttp===null) {
this.output("Server communication unavailable");
break;
}
if (this.args.length>7) {
var servertopic = this.args.slice(7);
if (isBad(helptxt['server'][servertopic])) {
this.output("No help available for server "+servertopic);
} else {
this.output(helptxt['server'][servertopic]);
}
} else {
this.output("Server commands:");
this.output("");
for (key in helptxt['server']) {
this.output(" "+key);
}
}
break;
default:
if (isBad(helptxt[topic])) {
this.output("No help available for "+topic);
break;
} else {
this.output(helptxt[topic]);
}
break;
}
}
bin['about'] = function() {
this.output('wwwsh - The nerdcore.net Web Shell<br><br>' +
'Copyright (c) 2009,2016 Mike Mallett <[email protected]><br><br>' +
'This program is free software; you can redistribute it and/or modify<br>' +
'it under the terms of the GNU General Public License as published by<br>' +
'the Free Software Foundation; either version 2 of the License, or<br>' +
'(at your option) any later version.<br><br>' +
'This program is distributed in the hope that it will be useful,<br>' +
'but WITHOUT ANY WARRANTY; without even the implied warranty of<br>' +
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>' +
'GNU General Public License for more details.');
}
bin['eval'] = function() {
if (isBad(this.args)) {
this.addPrompt("eval: ", "eval", "noecho");
} else {
var o = eval(this.args);
if (!isBad(o)) {
this.output(o);
}
}
}
bin['random'] = function() {
if (isBad(this.args)) {
this.output(Math.random());
} else if (isNaN(this.args)) {
this.output("random: bad argument");
sys.exec("help random");
} else {
this.output(Math.random() * this.args);
}
}
bin['randint'] = function() {
if (isBad(this.args)) {
this.output(Math.round(Math.random()));
} else if (isNaN(this.args)) {
this.output("randomint: bad argument");
this.output("");
sys.exec("help randomint");
} else {
this.output(Math.round(Math.random()*this.args));
}
}
bin['info'] = function() {
this.output("Browser name: "+navigator.appName);
this.output("Browser code name: "+navigator.appCodeName);
this.output("Browser version: "+navigator.appVersion);
this.output("User Agent string: "+navigator.userAgent);
this.output("OS platform: "+navigator.platform);
this.output("Screen size: "+screen.width+"x"+screen.height+" ("+screen.availWidth+"x"+screen.availHeight+" available)");
this.output("Colour depth: "+screen.colorDepth);
}
bin['open'] = function() {
if (isBad(this.args)) {
this.addPrompt("URL: ", "open", "echo");
} else {
window.open(this.args);
}
}
/*
bin['fullscreen'] = function() {
window.resizeTo(screen.availWidth,screen.availHeight);
window.moveTo(0,0);
}
*/
bin['server'] = function() {
if (sys.server.xmlhttp===null) {
this.output("Server communication unavailable");
return false;
}
if (isBad(this.args)) {
this.output("server: missing argument");
return false;
}
var ca = cmdargs(this.args);
switch (ca[0]) {
case 'md5':
if (ca[1]===null) {
this.addPrompt("MD5: ", "server md5", "pw");
return false;
}
break;
case 'sha256':
if (ca[1]===null) {
this.addPrompt("SHA256: ", "server sha256", "pw");
return false;
}
break;
case 'sha512':
if (ca[1]===null) {
this.addPrompt("SHA512: ", "server sha512", "pw");
return false;
}
break;
}
sys.server.requestOutput("cmd="+ca[0]+"&args="+escape(ca[1]));
}