feat(dcauth): 新增后台手机号与设备认证登录
登录链路改为账号密码 + 短信验证码 + DCAuth 设备签名,并新增后台手机号绑定、 登录日志、设备绑定与重置接口。
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func collectHardwareComponents() (map[string]string, error) {
|
||||
components := map[string]string{}
|
||||
|
||||
script := `
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
$cs = Get-CimInstance Win32_ComputerSystemProduct
|
||||
$bb = Get-CimInstance Win32_BaseBoard
|
||||
$bios = Get-CimInstance Win32_BIOS
|
||||
$cpu = Get-CimInstance Win32_Processor | Select-Object -First 1
|
||||
$disk = Get-CimInstance Win32_DiskDrive | Where-Object { $_.Index -eq 0 } | Select-Object -First 1
|
||||
[pscustomobject]@{
|
||||
smbiosUuid = [string]$cs.UUID
|
||||
baseboardSerial = [string]$bb.SerialNumber
|
||||
biosSerial = [string]$bios.SerialNumber
|
||||
cpuId = [string]$cpu.ProcessorId
|
||||
systemDiskSerial = [string]$disk.SerialNumber
|
||||
} | ConvertTo-Json -Compress
|
||||
`
|
||||
output, err := exec.Command(
|
||||
"powershell.exe",
|
||||
"-NoProfile",
|
||||
"-NonInteractive",
|
||||
"-ExecutionPolicy", "Bypass",
|
||||
"-Command", script,
|
||||
).Output()
|
||||
if err == nil {
|
||||
var payload map[string]string
|
||||
if json.Unmarshal([]byte(strings.TrimSpace(string(output))), &payload) == nil {
|
||||
for key, value := range payload {
|
||||
if normalized := normalizeComponent(value); normalized != "" {
|
||||
components[key] = normalized
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if machineGUID := readMachineGUID(); machineGUID != "" {
|
||||
components["machineGuid"] = machineGUID
|
||||
}
|
||||
if err := ensureNotEmpty(components); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return components, nil
|
||||
}
|
||||
|
||||
func readMachineGUID() string {
|
||||
output, err := exec.Command(
|
||||
"reg", "query", `HKLM\SOFTWARE\Microsoft\Cryptography`, "/v", "MachineGuid",
|
||||
).Output()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
line := strings.TrimSpace(string(output))
|
||||
for _, candidate := range strings.Split(line, "\n") {
|
||||
fields := strings.Fields(strings.TrimSpace(candidate))
|
||||
if len(fields) >= 3 && strings.EqualFold(fields[0], "MachineGuid") {
|
||||
return normalizeComponent(strings.Join(fields[2:], " "))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user