gpt4 book ai didi

powershell - REG_BINARY 到 PowerShell 中的 Windows 键

转载 作者:行者123 更新时间:2023-12-03 01:27:34 25 4
gpt4 key购买 nike

我正在尝试从 key 为数字的设备中提取“可读”的 win10 key 。

意义 :(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey没有结果。

我用 reg query HKLM\SOFTWARE\Microsoft\"Windows NT"\CurrentVersion /v DigitalProductId但是我当然得到了 REG_BINARY 输出。

任何人都知道如何将其转换为“普通”win10 key ?

编辑:可读 = 普通 windows 产品 key (通常在贴纸上找到)例如:9JNB6-GWD4G-JQHC7-*****-*****
编辑 2:有效的 VBS 脚本。

    Const KeyOffset = 52
Dim isWin10, Maps, i, j, Current, KeyOutput, Last, keypart1, insert
'Check if OS is Windows 10
isWin10 = (Key(66) \ 6) And 1
Key(66) = (Key(66) And &HF7) Or ((isWin10 And 2) * 4)
i = 24
Maps = "BCDFGHJKMPQRTVWXY2346789"
Do
Current= 0
j = 14
Do
Current = Current* 256
Current = Key(j + KeyOffset) + Current
Key(j + KeyOffset) = (Current \ 24)
Current=Current Mod 24
j = j -1
Loop While j >= 0
i = i -1
KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput
Last = Current
Loop While i >= 0
keypart1 = Mid(KeyOutput, 2, Last)
insert = "N"
KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0)
If Last = 0 Then KeyOutput = insert & KeyOutput
ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5)

最佳答案

这是 PowerShell 中的那个函数。希望它做你想要的:

function Get-ProductKey {
[cmdletbinding()]
Param (
[parameter(ValueFromPipeLine = $true, ValueFromPipeLineByPropertyName = $true)]
[Alias("IPAddress", "Server")]
[string[]]$Computername = $env:COMPUTERNAME
)
Begin {
$map = "BCDFGHJKMPQRTVWXY2346789"
}
Process {
foreach ($Computer in $Computername) {
if (!(Test-Connection -ComputerName $Computer -Count 1 -Quiet)) {
Write-Warning "Computer $Computer is unreachable"
continue
}
# try and determine if this is a 64 or 32 bit machine
try {
$OS = Get-WmiObject -ComputerName $Computer -Class Win32_OperatingSystem -ErrorAction Stop
}
catch {
Write-Warning "Could not retrieve OS version from computer $Computer"
continue
}
# try and read the registry
try {
$remoteReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,$Computer)
$valueName = if ([int]($OS.OSArchitecture -replace '\D') -eq 64) { 'DigitalProductId4' } else { 'DigitalProductId' }
$value = $remoteReg.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue($valueName)[0x34..0x42]
$productKey = for ($i = 24; $i -ge 0; $i--) {
$k = 0
for ($j = 14; $j -ge 0; $j--) {
$k = ($k * 256) -bxor $value[$j]
$value[$j] = [math]::Floor([double]($k/24))
$k = $k % 24
}
# output one character to collect in the $productKey array
$map[$k]
# output a hyphen
if (($i % 5) -eq 0 -and $i -ne 0) { "-" }
}
# reverse the array
[array]::Reverse($productKey)
# output the ProductKey as string
$productKey -join ''
}
catch {
Write-Warning "Could not read registry from computer $Computer"
}
finally {
if ($remoteReg) { $remoteReg.Close() }
}
}
}
}


Get-ProductKey

关于powershell - REG_BINARY 到 PowerShell 中的 Windows 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61156515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com