Nailathalang source
I-download ang source ZIP
CH-J Server Manager
I-browse ang mga direktoryo at file ng isang partikular na release ng application.
CH-J / Server Manager
368 file
core-20261017T201717Z-057348c4a70f
Idinagdag: Hindi naitala ang petsa · Binuo:
1
"use strict";3
const { encodedCommand, parseWindowsOutput } = require("./windowsPrivilegedExec");5
// Detects the remote operating system from system facts, never from prompts or host names.6
// 1) "uname -s" identifies POSIX systems (Linux, BSD, macOS).7
// 2) Otherwise a self-contained encoded PowerShell command reads the Windows version (registry, plus8
// Win32_OperatingSystem when WMI is permitted) and the OpenSSH DefaultShell registry value; it works whether9
// the default shell is cmd.exe, powershell.exe or pwsh.10
const POSIX_KERNELS = /^(Linux|Darwin|FreeBSD|OpenBSD|NetBSD|DragonFly|SunOS|AIX)\b/;11
const WINDOWS_PROBE = String.raw`$ProgressPreference='SilentlyContinue'12
try {13
# Registry first: standard accounts on an SSH network logon are usually denied WMI/CIM access.14
$nt = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -ErrorAction SilentlyContinue15
$shell = (Get-ItemProperty 'HKLM:\SOFTWARE\OpenSSH' -ErrorAction SilentlyContinue).DefaultShell16
$caption = [string]$nt.ProductName; $build = [string]$nt.CurrentBuildNumber17
if ($caption -match '^Windows 10' -and [int]("0$build") -ge 22000) { $caption = $caption -replace '^Windows 10', 'Windows 11' }18
$type = [string](Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\ProductOptions' -ErrorAction SilentlyContinue).ProductType19
$productType = @{ 'WinNT' = 1; 'LanmanNT' = 2; 'ServerNT' = 3 }[$type]20
$version = [Environment]::OSVersion.Version.ToString()21
try { $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop; $caption = $os.Caption; $version = $os.Version; $productType = [int]$os.ProductType } catch {}22
$value = [ordered]@{ caption = $caption; version = $version; build = $build; productType = $productType23
installationType = [string]$nt.InstallationType; defaultShell = [string]$shell; psVersion = $PSVersionTable.PSVersion.ToString()24
is64BitProcess = [Environment]::Is64BitProcess; languageMode = [string]$ExecutionContext.SessionState.LanguageMode25
localAccounts = [bool](Get-Command Get-LocalUser -ErrorAction SilentlyContinue); pwsh = [string](Get-Command pwsh.exe -ErrorAction SilentlyContinue).Source }26
[Console]::Out.WriteLine('CHJ_RESULT:' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(($value | ConvertTo-Json -Compress))))27
} catch { [Console]::Out.WriteLine('CHJ_ERR:PLATFORM_PROBE_FAILED:' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($_.Exception.Message))) }`;29
function shellName(defaultShell) {30
const value = String(defaultShell || "").toLowerCase();31
if (!value) return "cmd.exe";32
if (/pwsh(\.exe)?$/.test(value)) return "pwsh";33
if (/powershell(\.exe)?$/.test(value)) return "powershell";34
if (/cmd(\.exe)?$/.test(value)) return "cmd.exe";35
if (/bash(\.exe)?$/.test(value)) return "bash";36
return value.split(/[\\/]/).pop();37
}39
async function detectPlatform(sessionManager, sessionId, { refresh = false } = {}) {40
const record = sessionManager._requireConnected(sessionId);41
if (record.platform && !refresh) return record.platform;42
const uname = await sessionManager._execStream(record, "uname -s", { timeoutMs: 15000 }).done.catch(() => null);43
const kernel = String(uname?.stdout || "").trim().split(/\r?\n/)[0] || "";44
if (uname?.code === 0 && POSIX_KERNELS.test(kernel)) {45
record.platform = { os: kernel.startsWith("Linux") ? "linux" : "posix", kernel, detectedBy: "uname" };46
return record.platform;47
}48
const probe = await sessionManager._execStream(record, encodedCommand(WINDOWS_PROBE), { timeoutMs: 60000 }).done;49
let info;50
try { info = parseWindowsOutput(probe.stdout, probe.stderr, probe.code, "PLATFORM_"); }51
catch (error) {52
record.platform = { os: "unknown", kernel, detectedBy: "none", reason: error.message };53
return record.platform;54
}55
record.platform = {56
os: "windows",57
detectedBy: "Win32_OperatingSystem",58
caption: String(info.caption || ""),59
version: String(info.version || ""),60
build: String(info.build || ""),61
server: Number(info.productType) !== 1,62
serverCore: /server core/i.test(String(info.installationType || "")),63
installationType: String(info.installationType || ""),64
defaultShell: shellName(info.defaultShell),65
defaultShellPath: String(info.defaultShell || ""),66
powershell: String(info.psVersion || ""),67
is64BitProcess: info.is64BitProcess === true,68
languageMode: String(info.languageMode || ""),69
localAccounts: info.localAccounts === true,70
pwsh: String(info.pwsh || ""),71
unameOutput: kernel72
};73
return record.platform;74
}76
module.exports = { WINDOWS_PROBE, detectPlatform, shellName };SHA-256
c7aca0b0fd5dd2aba1f5d128f3c297f49e9678516f6685325a843442f8d4bf3aCH-J Proprietary Software License 1.14 · Ibinibigay ang source sa ilalim ng CH-J Proprietary Software License 1.14. Hindi binabago ng pagiging available nito ang mga tuntunin ng lisensya at hindi ito nagbibigay ng karagdagang karapatan.
SHA-256 ng archive
cf4455b698f0f28e456a37b1834976a0194d8486acb7101052d59a838745cca3