diff --git a/.gitignore b/.gitignore index 527f3261..c9a5d6db 100644 --- a/.gitignore +++ b/.gitignore @@ -368,3 +368,4 @@ FodyWeavers.xsd /zefie_wtvp_minisrv/ServiceLogPost/*.log /zefie_wtvp_minisrv/SessionStore/*.json /zefie_wtvp_minisrv/SessionStore/*/ +/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/viewers/HackTV.zip diff --git a/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js b/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js index 327f090e..f3fe4118 100644 --- a/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js +++ b/zefie_wtvp_minisrv/ServiceVault/http_pc/viewergen/index.js @@ -7,13 +7,27 @@ var viewer = 2 // debug override var viewers = { 0: "WebTVIntel--1.0.exe", 1: "WebTVIntel--1.1.exe", - 2: "WebTVIntel--2.5.exe" + 2: "WebTVIntel--2.5.exe", + 3: "WebTVIntel--1.0-HE.exe", + 4: "WebTVIntel--2.5-HE.exe" +} + +var logos = { + 0: null, + 1: "SuperViewer_Setup.bmp", + 2: "HackersEdition_Setup.bmp" +} + +var disksets = { + 0: null } var viewer_stock_md5s = { "WebTVIntel--1.0.exe": "d7bde1adbe3549f58dd95425d3ac2af9", "WebTVIntel--1.1.exe": "ce7b6d1734b5e3d1cbd5f068609223d1", - "WebTVIntel--2.5.exe": "4c5754bb8b69739b6f414c2d159051da" + "WebTVIntel--2.5.exe": "4c5754bb8b69739b6f414c2d159051da", + "WebTVIntel--1.0-HE.exe": "391f303fd70034e69d3a50583de72c89", + "WebTVIntel--2.5-HE.exe": "f0207865693a45ba76b9057dcb8ea672" } @@ -98,6 +112,16 @@ var patch_data = { 1967856: Buffer.from("\x00".repeat(24), 'ascii'), // remove unwanted headers 2003968: getResData("ResData--1.0.res.gz") }, + "WebTVIntel--1.0-HE.exe": { + 624: { + length: 383, + type: "wtv-incarnation" + }, + 1728624: { + length: 398, + type: "wtv-encryption" + } + }, "WebTVIntel--1.1.exe": { 209: Buffer.from("\xFA", 'ascii'), 257: Buffer.from("\x90", 'ascii'), @@ -152,6 +176,16 @@ var patch_data = { 3826408: Buffer.from("\x00".repeat(66), 'ascii'), // remove unwanted headers 3826356: Buffer.from("\x00".repeat(24), 'ascii'), // remove unwanted headers 3940352: getResData("ResData--2.5.res.gz") + }, + "WebTVIntel--2.5-HE.exe": { + 720: { + length: 3356, + type: "wtv-encryption" + }, + 3173506: { + length: 865, + type: "wtv-incarnation" + } } } @@ -176,7 +210,7 @@ function getPatchData(fname, client_data_obj, start_url = "client:GoToConn", def if (!val.byteLength) { // not a buffer object var block_length = val['length']; - var patch_data = getPatchDataType(val['type'], (fname == "WebTVIntel--2.5.exe")); + var patch_data = getPatchDataType(val['type'], (fname.substr(12,3) == "2.5")); if (patch_data) { var patch_data_array = patch_data.split("\r\n"); var patch_data_string = ""; @@ -210,8 +244,78 @@ function patchBinary(patchDataObject) { return patchDataObject.data; } +function generateSSID() { + var ssid_template = "91xxxY0xx0b002xx"; + var ssid = ssid_template; + while (ssid.indexOf("x") != -1) { + ssid = ssid.replace("x", Math.floor(Math.random() * 16).toString(16)) + } + ssid = ssid.replace("Y", Math.floor(Math.random() * 7)); + return ssid; +} + +function buildProfile(build) { + var buildProfile = null; + switch (build) { + case 1235: + buildProfile = { + "wtv-system-version": build, + "wtv-capability-flags": "1009c93bef", + "wtv-client-bootrom-version": 105, + "wtv-client-rom-type": "bf0app", + "wtv-system-chipversion": 16842752, + "User-Agent": "Mozilla/4.0 WebTV/1.4 (compatible; MSIE 3.0)", + "wtv-system-cpuspeed": 112790760, + "wtv-system-sysconfig": 736935823 + } + break; + + case 7181: + buildProfile = { + "wtv-system-version": build, + "wtv-capability-flags": "10935ffc8f", + "wtv-client-bootrom-version": 2046, + "wtv-client-rom-type": "US-LC2-disk-0MB-8MB", + "wtv-system-chipversion": 51511296, + "User-Agent": "Mozilla/4.0 WebTV/2.2.6.1 (compatible; MSIE 4.0)", + "wtv-system-cpuspeed": 166187148, + "wtv-system-sysconfig": 4163328, + "wtv-disk-size": 8006 + } + break; + + case 16276: + buildProfile = { + "wtv-system-version": build, + "wtv-capability-flags": "1fee0e1d9b1ffdef", + "wtv-client-bootrom-version": 2046, + "wtv-client-rom-type": "US-LC2-disk-0MB-8MB", + "wtv-system-chipversion": 53608448, + "User-Agent": "Mozilla/4.0 WebTV/2.8.2 (compatible; MSIE 4.0)", + "wtv-system-cpuspeed": 166164662, + "wtv-system-sysconfig": 3116068, + "wtv-disk-size": 8006 + } + break; + } + return buildProfile; +} + +var enable_full_hacktv = false; +if (fs.existsSync(cwd + path.sep + "viewers" + path.sep + "HackTV.zip")) { + enable_full_hacktv = true; + disksets['99'] = "HackTV.zip"; +} + if (request_headers.query.viewer && - request_headers.query.client_ssid) { + (request_headers.query.client_ssid || request_headers.query.random_ssid)) { + var client_ssid = null; + if (request_headers.query.client_ssid) + client_ssid = request_headers.query.client_ssid; + + if (request_headers.query.random_ssid) + client_ssid = generateSSID(); + var viewer_file = viewers[request_headers.query.viewer]; if (!viewer_file) { errpage = wtvshared.doErrorPage("500", null, socket.minisrv_pc_mode) @@ -227,18 +331,18 @@ if (request_headers.query.viewer && headers = errpage[0]; data = errpage[1]; } else { - var client_data_obj = { - "wtv-client-serial-number": request_headers.query.client_ssid, - "wtv-system-version": 16276, - "wtv-capability-flags": "1fee0e1d9b1ffdef", - "wtv-client-bootrom-version": 2046, - "wtv-client-rom-type": "US-LC2-disk-0MB-8MB", - "wtv-system-chipversion": 53608448, - "User-Agent": "Mozilla/4.0 WebTV/2.8.2 (compatible; MSIE 4.0)", - "wtv-system-cpuspeed": 166164662, - "wtv-system-sysconfig": 3116068, - "wtv-disk-size": 8006 + var build = request_headers.query.build; + var client_data_obj = null + if (build) { + if (parseInt(build) > 0) { + client_data_obj = buildProfile(parseInt(build)); + } } + // fallback + if (!client_data_obj) + client_data_obj = buildProfile(7181); + + client_data_obj["wtv-client-serial-number"] = client_ssid; var patchDataObject = { data: viewer_data, patch_data: getPatchData(viewer_file, client_data_obj) @@ -254,19 +358,34 @@ Content-Type: application/octet-stream Content-Disposition: attachment; filename="${viewer_file.replace(".exe", ".zip")}"` var AdmZip = require("adm-zip"); var zip = new AdmZip(); - zip.addFile(viewer_file, patched_file, "SSID: " + request_headers.query.client_ssid); + + zip.addZipComment("Viewer SSID: " + client_ssid); + zip.addFile(viewer_file, patched_file); if (!request_headers.query.viewer_only) { - var data_zip = new AdmZip(cwd + "/viewers/" + viewer_file.replace(".exe", "").replace("WebTVIntel", "AppData") + ".zip"); - var zipEntries = data_zip.getEntries(); + var romset_zip = new AdmZip(cwd + "/viewers/" + viewer_file.replace(".exe", "").replace("WebTVIntel", "AppData") + ".zip"); + var zipEntries = romset_zip.getEntries(); zipEntries.forEach(function (zipEntry) { - if (zipEntry.entryName == "Setup.bmp" && request_headers.query.superviewer_logo) { - var logo_gz_data = fs.readFileSync(cwd + "/viewers/SuperViewer_Setup.bmp.gz"); - var logo_data = zlib.gunzipSync(logo_gz_data); - zip.addFile(zipEntry.entryName, logo_data); + if (zipEntry.entryName == "Setup.bmp" && request_headers.query.logo) { + var logo_file = logos[parseInt(request_headers.query.logo) || 0]; + if (logo_file) { + var logo_gz_data = fs.readFileSync(cwd + "/viewers/" + logo_file + ".gz"); + var logo_data = zlib.gunzipSync(logo_gz_data); + zip.addFile(zipEntry.entryName, logo_data); + } else { + zip.addFile(zipEntry.entryName, zipEntry.getData()); + } } else { zip.addFile(zipEntry.entryName, zipEntry.getData()); } }); + if (request_headers.query.diskset) { + var diskset_file = disksets[parseInt(request_headers.query.diskset) || 0]; + var diskset_zip = new AdmZip(cwd + "/viewers/" + diskset_file); + var zipEntries = diskset_zip.getEntries(); + zipEntries.forEach(function (zipEntry) { + zip.addFile("Disk/" + zipEntry.entryName, zipEntry.getData()); + }); + } } data = zip.toBuffer(); } @@ -292,6 +411,10 @@ td {
@@ -338,22 +473,55 @@ Welcome to the zefie minisrv v${minisrv_config.version} PC Services