Skip to content

Commit 12145c3

Browse files
committed
here you all go
0 parents  commit 12145c3

28 files changed

+6108
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Nathan Bolam
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Technicolor OpenWRT Shell Unlocker By BoLaMN
2+
3+
* Connect network cable from your computer to the WAN (red) port of the modem
4+
* Change your computers network card to be a static ip address
5+
6+
IPv4 Address: 58.162.0.1
7+
Subnet Mask: 255.255.255.0
8+
Default Gateway\\Router: 58.162.0.1
9+
10+
License: MIT

dist/cwmp/index.js

+149
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
'use strict';
2+
var createSoapEnv, device, env, files, methods, parse, ref, request, response, set, stage;
3+
4+
ref = require('./xml'), parse = ref.parse, methods = ref.methods, createSoapEnv = ref.createSoapEnv;
5+
6+
files = require('../files');
7+
8+
stage = null;
9+
10+
device = {};
11+
12+
env = [];
13+
14+
set = function(obj, key, value) {
15+
var attr, attrs, i, j, len;
16+
attrs = key.split('.');
17+
for (i = j = 0, len = attrs.length; j < len; i = ++j) {
18+
attr = attrs[i];
19+
if (i === attrs.length - 1) {
20+
obj[attr] = value;
21+
} else {
22+
obj = obj[attr] != null ? obj[attr] : obj[attr] = {};
23+
}
24+
}
25+
return obj;
26+
};
27+
28+
request = function(ip, req, res) {
29+
var DeviceInfo, SoftwareVersion, body, cwmp, cwmpVersion, element, file, header, idElement, input, k, key, params, ref1, ref2, ref3, ref4, ref5, software, str, v, value, version, xml;
30+
if (req.body.length > 0) {
31+
console.log('>>> REQUEST');
32+
console.dir([req.headers, req.body]);
33+
xml = parse(req.body);
34+
element = xml['soapenv:Envelope'];
35+
body = element['soapenv:Body'];
36+
header = element['soapenv:Header'];
37+
ref1 = element.attributes;
38+
for (k in ref1) {
39+
v = ref1[k];
40+
if (!((k != null) && (v != null))) {
41+
return;
42+
}
43+
str = k.replace('soapenv', 'soap-env') + '=\'' + v + '\'';
44+
if (env.indexOf(str) === -1) {
45+
env.push(str);
46+
}
47+
}
48+
res.name = stage = Object.keys(body)[0];
49+
cwmp = (ref2 = element.attributes) != null ? ref2['xmlns:cwmp'] : void 0;
50+
ref3 = /urn:dslforum-org:cwmp-(\d+-\d+)/.exec(cwmp) || [cwmp, '1-2'], input = ref3[0], cwmpVersion = ref3[1];
51+
res.cwmpVersion = cwmpVersion.replace(/-/g, '.');
52+
idElement = header['cwmp:ID'];
53+
if (idElement) {
54+
res.id = req.id = idElement;
55+
}
56+
ref4 = body[stage];
57+
for (key in ref4) {
58+
value = ref4[key];
59+
res[key] = value;
60+
}
61+
if (((ref5 = res.ParameterList) != null ? ref5.ParameterValueStruct : void 0) != null) {
62+
params = res.ParameterList.ParameterValueStruct;
63+
res.params = Object.keys(params).reduce(function(obj, k) {
64+
if (typeof params[k] === 'string') {
65+
set(obj, k, params[k]);
66+
}
67+
return obj;
68+
}, {});
69+
device = res.params.Device || res.params.InternetGatewayDevice || {};
70+
}
71+
res.name += 'Response';
72+
} else if (stage === 'cwmp:Inform') {
73+
console.log('>>> EMPTY REQUEST');
74+
console.dir([req.headers, req.body]);
75+
DeviceInfo = (device || {}).DeviceInfo;
76+
SoftwareVersion = (DeviceInfo || {}).SoftwareVersion;
77+
version = 17;
78+
software = parseInt(SoftwareVersion.substring(0, 2));
79+
if (software < 17) {
80+
version = 16;
81+
}
82+
file = files[version];
83+
res.name = 'cwmp:Download';
84+
res.fileType = '3 Vendor Configuration File';
85+
res.fileSize = file.length;
86+
res.url = "http://" + ip + "/" + version + ".sts";
87+
}
88+
res.env = env.join(' ');
89+
return response(req, res);
90+
};
91+
92+
response = function(req, res) {
93+
var body, code, data, headers;
94+
headers = {
95+
'Content-Type': 'text/xml; charset="utf-8"',
96+
'Server': 'ACSServer',
97+
'SOAPServer': 'ACSServer'
98+
};
99+
if (res.name && (methods[res.name] != null)) {
100+
if (res.name === 'cwmp:InformResponse') {
101+
headers['Set-Cookie'] = "session=7b0fa33078153e5c";
102+
}
103+
if (res.id == null) {
104+
res.id = req.id != null ? req.id : req.id = '1690d26c77f0000';
105+
}
106+
if (methods[res.name] != null) {
107+
body = methods[res.name](res);
108+
}
109+
data = createSoapEnv(res.env, res.id, body);
110+
code = 200;
111+
headers['Content-Length'] = data.length;
112+
console.log('<<< RESPONSE');
113+
console.dir([headers, data]);
114+
} else {
115+
code = 204;
116+
data = null;
117+
headers['Connection'] = "close";
118+
headers['Content-Length'] = 0;
119+
console.log('<<< EMPTY RESPONSE');
120+
console.dir([headers, data]);
121+
}
122+
res.writeHead(code, headers);
123+
res.end(data);
124+
if (res.name === 'cwmp:TransferCompleteResponse') {
125+
console.log("Please try a ssh connection now to " + req.connection.remoteAddress + " with username root and password root (change password immediately with passwd!)");
126+
return setTimeout(function() {
127+
return process.exit(1);
128+
}, 20000);
129+
}
130+
};
131+
132+
module.exports = function(ip) {
133+
return function(req, res) {
134+
var COOKIE_REGEX, match;
135+
COOKIE_REGEX = /\s*([a-zA-Z0-9\-_]+?)\s*=\s*"?([a-zA-Z0-9\-_]*?)"?\s*(,|;|$)/g;
136+
while (match = COOKIE_REGEX.exec(req.headers.cookie)) {
137+
if (match[1] === 'session') {
138+
req.id = res.id = match[2];
139+
}
140+
}
141+
req.body = '';
142+
req.on('data', function(chunk) {
143+
return req.body += chunk;
144+
});
145+
req.on('end', function() {
146+
return request(ip, req, res);
147+
});
148+
};
149+
};

dist/cwmp/xml.js

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
exports.parse = function(xml) {
2+
var attribute, content, declaration, eos, has, match, name, obj, obj1, ref, tag;
3+
declaration = function() {
4+
var attr, m, node;
5+
m = match(/^<\?xml\s*/);
6+
if (!m) {
7+
return;
8+
}
9+
node = {};
10+
while (!(eos() || has('?>'))) {
11+
attr = attribute();
12+
if (!attr) {
13+
return node;
14+
}
15+
if (node.attributes == null) {
16+
node.attributes = {};
17+
}
18+
node.attributes[attr.name] = attr.value;
19+
}
20+
match(/\?>\s*/);
21+
return node;
22+
};
23+
tag = function() {
24+
var attr, c, child, m, name1, node;
25+
m = match(/^<([\w-:.]+)\s*/);
26+
if (!m) {
27+
return;
28+
}
29+
node = {};
30+
while (!(eos() || has('>') || has('?>') || has('/>'))) {
31+
attr = attribute();
32+
if (!attr) {
33+
return [m[1], node];
34+
}
35+
if (node.attributes == null) {
36+
node.attributes = {};
37+
}
38+
node.attributes[attr.name] = attr.value;
39+
}
40+
if (match(/^\s*\/>\s*/)) {
41+
return [m[1], node];
42+
}
43+
match(/\??>\s*/);
44+
c = content();
45+
if (c) {
46+
node = c;
47+
}
48+
while (child = tag()) {
49+
if (child[1].Name && child[1].Value) {
50+
if (node[name1 = child[0]] == null) {
51+
node[name1] = {};
52+
}
53+
node[child[0]][child[1].Name] = child[1].Value;
54+
} else {
55+
node[child[0]] = child[1];
56+
}
57+
}
58+
match(/^<\/[\w-:.]+>\s*/);
59+
return [m[1], node];
60+
};
61+
content = function() {
62+
var m;
63+
m = match(/^([^<]*)/);
64+
return m != null ? m[1] : void 0;
65+
};
66+
attribute = function() {
67+
var m;
68+
m = match(/([\w:-]+)\s*=\s*("[^"]*"|'[^']*'|\w+)\s*/);
69+
if (!m) {
70+
return;
71+
}
72+
return {
73+
name: m[1],
74+
value: m[2].replace(/^['"]|['"]$/g, '')
75+
};
76+
};
77+
match = function(re) {
78+
var m;
79+
m = xml.match(re);
80+
if (!m) {
81+
return;
82+
}
83+
xml = xml.slice(m[0].length);
84+
return m;
85+
};
86+
eos = function() {
87+
return !xml.length;
88+
};
89+
has = function(prefix) {
90+
return 0 === xml.indexOf(prefix);
91+
};
92+
xml = xml.trim();
93+
xml = xml.replace(/<!--[\s\S]*?-->/g, '');
94+
ref = tag(), name = ref[0], obj = ref[1];
95+
return (
96+
obj1 = {},
97+
obj1["" + name] = obj,
98+
obj1
99+
);
100+
};
101+
102+
exports.methods = {
103+
'cwmp:TransferCompleteResponse': function(res) {
104+
return "<cwmp:TransferCompleteResponse/>";
105+
},
106+
'cwmp:Download': function(res) {
107+
return "<cwmp:Download>\n <CommandKey>" + (res.commandKey || res.id) + "</CommandKey>\n <FileType>" + res.fileType + "</FileType>\n <URL>" + res.url + "</URL>\n <FileSize>" + (res.fileSize || 0) + "</FileSize>\n <DelaySeconds>0</DelaySeconds>\n</cwmp:Download>";
108+
},
109+
'cwmp:InformResponse': function(res) {
110+
return "<cwmp:InformResponse>\n <MaxEnvelopes>1</MaxEnvelopes>\n</cwmp:InformResponse>";
111+
}
112+
};
113+
114+
exports.createSoapEnv = function(env, id, body) {
115+
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soap-env:Envelope " + (env || '') + ">\n <soap-env:Header>\n <cwmp:ID soap-env:mustUnderstand=\"1\">" + id + "</cwmp:ID>\n </soap-env:Header>\n <soap-env:Body>\n " + body + "\n </soap-env:Body>\n</soap-env:Envelope>";
116+
};

dist/dhcp/constants.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
DHCPDISCOVER: 1,
3+
DHCPOFFER: 2,
4+
DHCPREQUEST: 3,
5+
DHCPDECLINE: 4,
6+
DHCPACK: 5,
7+
DHCPNAK: 6,
8+
DHCPRELEASE: 7,
9+
DHCPINFORM: 8,
10+
SERVER_PORT: 67,
11+
CLIENT_PORT: 68,
12+
INADDR_ANY: '0.0.0.0',
13+
INADDR_BROADCAST: '255.255.255.255',
14+
BOOTREQUEST: 1,
15+
BOOTREPLY: 2
16+
};

0 commit comments

Comments
 (0)