fix bf0app dynamic OpenISP tellyscript

This commit is contained in:
zefie
2025-02-21 16:44:58 -05:00
parent 67375ce72f
commit 96015288fa
8 changed files with 1640 additions and 22 deletions

View File

@@ -108,7 +108,8 @@ if (session_data.data_store.wtvsec_login) {
case "bf0app":
prereg_contype = "text/tellyscript";
// if wtv-open-access: true then client expects OpenISP
if (session_data.get("wtv-open-access")) file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_OISP.tok", true);
//if (session_data.get("wtv-open-access")) file_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app_OISP.tok", true);
if (session_data.get("wtv-open-access")) template_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.openisp.template.txt", true);
else template_path = wtvshared.getServiceDep("/wtv-1800/tellyscripts/bf0app/bf0app.prereg.template.txt", true);
break;

View File

@@ -44,7 +44,10 @@ const reservedKeywords = new Set([
'setusername', 'setpassword', 'setpapmode', 'startppp', 'getpppresult', 'ticks',
'getpreregnumber', 'getserialnumber', 'getsecret', 'getphonesettings', 'setstatus',
'sprintf', 'setconnectionstats', 'setforcehook', 'waitfor', 'setnameservice',
'getline'
'getline', 'connectingwithvideoad', 'version', 'alert', 'system_getboxfeatureflags',
'parsesystemtime', 'getdatetimelocal', 'getdayofweek', 'gethour', 'getminute',
'getmonth', 'getyear', 'getconnectretrycount', 'dialerror', 'setfullpopnumber',
'setconnectretrycount', 'setani', 'setlocalpopcount', 'computefcs'
]);
@@ -931,6 +934,7 @@ class WTVTellyScriptMinifier {
[/^\d+/, 'NUMBER'],
// String literals (supports escaped quotes)
[/^"([^"\\]|\\.)*"/, 'STRING'],
[/^'([^'\\]|\\.)*'/, 'STRING'],
// Punctuation (parentheses, braces, commas, semicolons, etc.)
[/^[{};,\[\]\(\)]/, 'PUNCTUATION'],
// Operators (covers common operators; adjust as needed)
@@ -969,8 +973,8 @@ class WTVTellyScriptMinifier {
const token = tokens[i];
if (token.type === 'WHITESPACE') {
//token.value = token.value.replaceAll("\r", " ");
if (token.value.indexOf("\n") !== -1) output += token.value.replaceAll("\n\n\n", "\n\n");
token.value = token.value.replaceAll("\r", "\n");
if (token.value.indexOf("\n") !== -1) output += token.value.replaceAll("\n\n", "\n");
else output += " ";
} else {
output += token.value;
@@ -1064,6 +1068,7 @@ class WTVTellyScript {
minify() {
let minifier = new WTVTellyScriptMinifier();
this.raw_data = minifier.minify(this);
this.raw_data = this.raw_data.replaceAll("\n\n\n", "\n");
this.tokenize();
this.pack();
}
@@ -1291,7 +1296,7 @@ class WTVTellyScript {
this.packed_header = {
magic: (this.tellyscript_type === TellyScriptType.DIALSCRIPT) ? "VKAT" : "ANDY",
version_major: (this.packed_header && this.packed_header.version_major) ? this.packed_header.version_major : 1,
version_minor: (this.packed_header && this.packed_header.version_minor) ? this.packed_header.version_minor : 1,
version_minor: (this.packed_header && this.packed_header.version_minor) ? this.packed_header.version_minor : 3,
script_id: script_id,
script_mod: Math.floor(Date.now() / 1000),
compressed_data_length: compressed_data.length,

View File

@@ -22,6 +22,7 @@ wtv-system-version: 7181
wtv-capability-flags: 10935ffc8f
wtv-client-bootrom-version: 2046
wtv-client-rom-type: bf0app
wtv-open-access: true
wtv-system-chipversion: 51511296
User-Agent: Mozilla/4.0 WebTV/2.2.6.1 (compatible; MSIE 4.0)
wtv-encryption: true
@@ -30,6 +31,7 @@ wtv-script-mod: 0
`
//wtv-client-rom-type: US-LC2-disk-0MB-8MB
const net = require('net');

View File

@@ -5,25 +5,18 @@ const classPath = path.resolve(__dirname + path.sep + "includes" + path.sep + "c
const { WTVShared, clientShowAlert } = require(classPath + "/WTVShared.js");
const WTVTellyScript = require(classPath + "/WTVTellyScript.js")
//const bf0app = classPath + "/../ServiceDeps/wtv-1800/tellyscripts/bf0app/bf0app_WTV_18006138199.tok"
//const tokened = fs.readFileSync(bf0app);
//const LC2 = classPath + "/../ServiceDeps/wtv-1800/tellyscripts/LC2/LC2_WTV_18006138199.tok";
//const prereg = fs.readFileSync(LC2);
const LC2 = classPath + "/../ServiceDeps/wtv-1800/tellyscripts/LC2/LC2_WTV_18006138199.tok";
const tokened = fs.readFileSync(LC2);
//const LC2OISP = classPath + "/../ServiceDeps/wtv-1800/tellyscripts/LC2/LC2_OpenISP_56k.tok";
//const isp = fs.readFileSync(LC2OISP);
console.log("OGTOK:", tokened)
var token = new WTVTellyScript(tokened);
//console.log("OGTOK:", tokened)
bf0 = fs.readFileSync(classPath + "/../ServiceDeps/wtv-1800/tellyscripts/bf0app/bf0app_OISP.tok")
var token = new WTVTellyScript(bf0);
//var token2 = new WTVTellyScript(isp);
console.log("OGTOK Header:", token.packed_header);
token.raw_data = token.raw_data.replaceAll("zefie", "testing");
token.tokenize();
retok = token.pack()
retok = Buffer.from(retok)
console.log("Retok:", retok)
var token2 = new WTVTellyScript(retok);
console.log(token.raw_data)
//console.log("OGTOK Header:", token2.packed_header);
console.log("Retok Header:", token2.packed_header);
console.log("Retok detok:", token2.raw_data);