tirthsaraiya29/Tether

GitHub: tirthsaraiya29/Tether

Tether 通过将 Android 手机作为蓝牙信任锚点,为 Windows 工作站提供自适应近距身份验证、自动解锁与紧急锁定功能。

Stars: 1 | Forks: 0

# Tether Tether 是一个高安全性个人信任平台,专注于自适应身份验证、基于手机的信任验证、紧急锁定系统以及分层恢复机制。 该系统在 Windows 机器与 Android 设备之间建立安全的信任关系,其中手机充当持续验证的信任锚点。 # 功能 ## Android 信任锚点 - 安全的设备配对 - 基于手机的信任验证 - 恢复设备支持 - 近距离身份验证 ## 紧急模式 - 即时锁定触发 - 信任撤销 - 会话失效 - 紧急隔离工作流 ## 持续信任验证 - 连接完整性监控 - 受信任设备验证 - 安全通道验证 - 信任连续性检查 ## 恢复系统 - 多层恢复机制 - 安全的降级处理程序 - 恢复加固逻辑 # 架构 ## Windows 组件 - 核心服务 (`Tether.CommunicationService`) - 身份验证引擎 (`TetherCredentialProvider`) - 覆盖层 UI (`Tether.OverlayUI`) - 桌面配置 UI (`Tether.DesktopUI`) - 信任状态管理器 - 恢复管理器 - 安全通信层 ## Android 组件 - 信任配套应用 (`apps/android-companion/app`) - 安全配对系统 - 近距离验证 - 紧急触发接口 ## 共享组件 - 事件总线 (Event Bus) - 共享 DTO - 共享常量 - IPC 常量 - 日志 # 技术栈 ## Windows - C# (.NET 8) - WPF / XAML - C++ - Windows Credential Provider API - Windows Security APIs - DPAPI (`CryptProtectData`) - 命名管道 (Named Pipes, IPC) ## Android - Kotlin - Jetpack Compose - Android SDK (API 33+) - 蓝牙低功耗 (BLE) - Android Keystore / StrongBox ## 通信 - BLE (GATT) - RSA + AES 加密通信 - 命名管道 (Named Pipes) - 全局事件句柄 # 前置条件 ## Windows 开发 安装: - Visual Studio 2022 - 使用 C++ 的桌面开发 - .NET 桌面开发 - Windows SDK 10.0.22621.0 或更高版本 - .NET 8 SDK - Git ## Android 开发 安装: - Android Studio(最新版) - JDK 17+ - Android SDK API 33+ - 用于 BLE 测试的物理 Android 12+ 设备 ## 构建工具 - CMake - MSBuild # 获取源代码 ``` git clone https://github.com/your-org/Tether.git cd Tether ``` # 构建说明 ## 1. 构建通信服务 ``` cd services/communication-service/Tether.CommunicationService dotnet restore dotnet build --configuration Release dotnet publish \ --configuration Release \ --runtime win-x64 \ --self-contained true ``` 输出: ``` bin/Release/net8.0-windows10.0.22621.0/win-x64/ ``` ## 2. 构建凭据提供程序 打开: ``` TetherCredentialProvider.vcxproj ``` 在 Visual Studio 2022 中 或者从命令行构建: ``` msbuild TetherCredentialProvider.vcxproj ^ /p:Configuration=Release ^ /p:Platform=x64 ``` 输出: ``` x64/Release/TetherCredentialProvider.dll ``` ## 3. 构建桌面 UI ``` cd apps/desktop-ui/Tether.DesktopUI dotnet restore dotnet build --configuration Release ``` 输出: ``` bin/Release/net8.0-windows/ ``` ## 4. 构建覆盖层 UI ``` cd Tether.OverlayUI dotnet restore dotnet build --configuration Release ``` 输出: ``` bin/Release/net8.0-windows/ ``` ## 5. 构建 Android 配套应用 ``` cd apps/android-companion ./gradlew assembleRelease ``` 输出: ``` app/build/outputs/apk/release/app-release.apk ``` 用于开发: ``` ./gradlew assembleDebug ``` ## 6. 构建共享库 ``` cd shared/Tether.Shared dotnet restore dotnet build --configuration Release ``` ``` cd services/event-bus/Tether.EventBus dotnet restore dotnet build --configuration Release ``` 所有 .NET 项目通过 `ProjectReference` 引用这些库,因此构建顺序会自动处理。 # 安装说明 ## 1. 安装 Windows 服务 ``` sc.exe create "TetherCommService" ` binPath= "C:\Dev\Tether\services\communication-service\Tether.CommunicationService\bin\Release\net8.0-windows10.0.22621.0\win-x64\Tether.CommunicationService.exe" ` start= auto ``` 启动服务: ``` sc.exe start "TetherCommService" ``` 验证: ``` sc.exe query "TetherCommService" ``` 该服务需要: - SYSTEM 权限 - BLE 访问权限 - 注册表访问权限 - 命名管道创建权限 ## 2. 注册凭据提供程序 ``` regsvr32.exe C:\Dev\Tether\x64\Release\TetherCredentialProvider.dll ``` 或 ``` regedit.exe /s TetherCredentialProvider\register.reg ``` 注册表位置: ``` HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ Authentication\Credential Providers\ {c8c8d282-f4f1-451d-96fc-a8b1f783117b} ``` 取消注册: ``` regsvr32.exe /u C:\Dev\Tether\x64\Release\TetherCredentialProvider.dll regedit.exe /s TetherCredentialProvider\unregister.reg ``` ## 3. 凭据提供程序配置 注册表: ``` HKLM\SOFTWARE\Tether\CredentialProvider ``` | 值 | 类型 | 描述 | |--------|------|-------------| | `EncryptedPassword` | `REG_BINARY` | DPAPI 加密的 Windows 密码 | | `PasswordHash` | `REG_SZ` | 密码 + salt 的 SHA-256 哈希值 | | `PasswordSalt` | `REG_BINARY` | 64 字节随机 salt | | `TrustedPhonePublicKey` | `REG_SZ` | Base64 X.509 公钥 | | `Provisioned` | `REG_DWORD` | 如果已配对则为 `1` | 自动配置由以下程序执行: - `Tether.DesktopUI` - `Tether.CommunicationService` ## 4. 配对手机 1. 打开 Android 应用。 2. 显示二维码或公钥。 3. 打开 `Tether.DesktopUI`。 4. 将公钥粘贴到 **PHONE PAIRING PROFILE** 中。 5. 选择 **PAIR PROVISIONED PHONE**。 ## 5. 配置密码保险库 1. 打开 `Tether.DesktopUI`。 2. 导航到 **CRYPTOGRAPHIC VAULT CONFIGURATION**。 3. 输入 Windows 密码。 4. 选择 **COMMIT CRYPTOGRAPHIC LSA VAULT**。 密码在存入注册表之前,会使用机器级 DPAPI 进行加密。 # 快速测试 1. 启动 `Tether.CommunicationService`。 2. 启动 `Tether.DesktopUI`。 3. 锁定 Windows (`Win + L`)。 4. 打开 Android 配套应用。 5. 确保已启用蓝牙。 6. 点击 **Unlock**。 如果配置正确,Windows 应该会自动解锁。 # 开发提示 ## 日志 Windows 服务: ``` C:\ProgramData\Tether\Logs\ ``` 凭据提供程序: - DebugView - 事件查看器 - OutputDebugString Android: ``` Logcat Tag: TetherBle ``` ## 注册表 ``` regedit.exe ``` 导航到: ``` HKLM\SOFTWARE\Tether\CredentialProvider ``` ## 命名管道测试 ``` cd tests/PipeTest dotnet run -- "PHONE_UNLOCKED" ``` ## 重新构建所有内容 ``` dotnet build Tether.slnx --configuration Release ``` ``` msbuild TetherCredentialProvider\TetherCredentialProvider.vcxproj ` /p:Configuration=Release ` /p:Platform=x64 ``` ``` cd apps/android-companion ./gradlew assembleRelease ``` # 调试凭据提供程序 凭据提供程序在以下进程中执行: ``` LogonUI.exe ``` 推荐的工作流: 1. 在 Visual Studio 中附加到 `LogonUI.exe`。 2. 以 SYSTEM 身份(或同等提权上下文)运行 Visual Studio。 3. 在 `TetherCredential.cpp` 中设置断点。 4. 锁定工作站。 或者: - 使用 `OutputDebugString()` - 使用 **DebugView** 捕获输出 # 安全提示 Tether 正在积极开发中,**不应**被视为已达到生产就绪状态。 在部署之前,请查阅项目的安全评估和威胁模型。 # 贡献 1. Fork 该仓库。 2. 创建功能分支。 3. 遵循项目的 `.editorconfig`。 4. 运行测试。 5. 提交 pull request。 # 作者 **Tirth Saraiya**
标签:Bash脚本, macOS, Windows凭证提供程序, WPF, 双因素认证, 安卓开发, 物理接近锁定, 蓝牙认证, 跨端通信