Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
fjh658 committed Sep 10, 2024
0 parents commit 53cf7c7
Show file tree
Hide file tree
Showing 7 changed files with 677 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
48 changes: 48 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[package]
# Basic package metadata
name = "SignalDecryption" # The name of your Rust package
version = "0.1.0" # The version of your package
edition = "2021" # The Rust edition your package is using (2024 is a placeholder, replace with "2021" if needed)
authors = ["Your Name <[email protected]>"] # Author information
description = "A tool for encrypting and decrypting Signal keys" # A short description of your package

[dependencies]
# Dependency on AES for encryption
aes = "0.7.5" # The AES crate, version 0.7.5

# Dependency on block-modes for using block cipher modes of operation like CBC
block-modes = "0.8.1" # The block-modes crate, version 0.8.1

# Dependency on PBKDF2 for key derivation
pbkdf2 = { version = "0.10", features = ["std"] } # The pbkdf2 crate, version 0.10 with the "std" feature enabled

# Dependency on SHA1 for hashing
sha1 = "0.10.1" # The sha1 crate, version 0.10.1

# Dependency on hex for encoding and decoding hexadecimal strings
hex = "0.4.3" # The hex crate, version 0.4.3

# Dependency on serde_json for JSON handling
serde_json = { version = "1.0.79", default-features = false, features = ["std"] } # Enable `std` feature explicitly

# Dependency on keyring for accessing the system keyring
keyring = "1.2.0" # The keyring crate, version 1.2.0

# Dependency on HMAC for creating message authentication codes
hmac = "0.12.1" # The hmac crate, version 0.12.1

rand = "0.8" # Specify the version you want to use

winapi = { version = "0.3", features = ["wincrypt", "dpapi", "winbase"] }

[profile.release]
# Release profile optimizations

opt-level = 3 # Maximum optimization level for performance
lto = "fat" # Use "fat" link-time optimization for better performance at the cost of longer compile times
codegen-units = 1 # Set to 1 to allow the compiler to optimize across the entire crate, improving performance but increasing compile time
panic = 'abort' # Abort on panic to reduce binary size by not including unwinding code
strip = true # Remove symbols from the final binary to reduce size
debug = false # Disable debug information to reduce binary size and remove source file references
incremental = false # Disable incremental compilation for release builds to improve runtime performance at the cost of longer compile times
overflow-checks = false # Disable overflow checks in release builds to improve performance; this should only be done if you're sure overflows won't occur
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 John Feng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Signal Decryption Tool for macOS 🔐

English | [中文](README_zh.md)

## Overview 🌟

This Signal Decryption Tool is a Rust-based command-line utility designed specifically for macOS to handle the encryption and decryption of Signal keys. It provides a secure way to manage Signal's encrypted configuration on macOS systems.

## Features ✨

- 🔓 Decrypt Signal's encrypted keys stored in the macOS keychain
- 📁 Support for custom configuration file paths
- 🔑 Option to directly input encrypted keys
- 🛡️ Secure handling of sensitive information
- 💻 Command-line interface for easy integration into scripts or manual use
- 🍎 Universal binary support for both Intel and Apple Silicon Macs

## Prerequisites 📋

- 🖥️ macOS operating system
- 🦀 Rust programming language (latest stable version)
- 📦 Cargo package manager

## Installation 🛠️

1. Clone this repository:

```
git clone https://github.com/fjh658/signal-decryption-tool.git
cd signal-decryption-tool
```

2. Build the project using Cargo:

```
cargo build --release
```

3. The compiled binary will be available in `target/release/signal_decryption`

### Building a Universal Binary 🏗️

To create a universal binary that runs on both Intel and Apple Silicon Macs:

1. Ensure you have the necessary Rust targets installed:

```
rustup target add x86_64-apple-darwin aarch64-apple-darwin
```

2. Run the provided build script:

```
./build_universal_mac.sh
```

3. The universal binary will be created at `target/universal/SignalDecryption`

This script performs the following actions:

- Builds the project for both x86_64 and aarch64 architectures
- Strips debug symbols to reduce binary size
- Uses `lipo` to combine the binaries into a universal binary

## Usage 📝

Run the tool from the command line with the following options:

```
SignalDecryption [options]
Options:
-h, --help Show this help message
-c, --config PATH Specify the path to the config.json file
-k, --key KEY Provide an encrypted key directly
-p, --print-key Print the secure storage key (use with caution)
--version Show the tool version
```

### Examples 🌈

1. Decrypt using the default configuration:

```
./SignalDecryption
```

2. Use a custom configuration file:

```
./SignalDecryption -c /path/to/custom/config.json
```

3. Provide an encrypted key directly:

```
./SignalDecryption -k "your_encrypted_key_here"
```

4. Print the secure storage key (use with caution):

```
./SignalDecryption -p
```

## Security Considerations 🔒

- ⚠️ This tool handles sensitive encryption keys. Use it in a secure environment.
- 🚨 The `-p` option prints sensitive information. Use it only when necessary and in a secure setting.
- 🔐 Ensure you have the necessary permissions to access Signal's configuration on your system.

## Limitations and Future Development 🚀

* 📱 This tool is currently designed for macOS. However, users can develop similar tools for other operating systems based on the following resources:

- For Windows implementation: [Chromium OS Crypt for Windows](https://chromium.googlesource.com/chromium/src/+/refs/tags/130.0.6686.2/components/os_crypt/sync/os_crypt_win.cc)
- For cross-platform implementation in Electron: [Electron Safe Storage API](https://github.com/electron/electron/blob/41b8fdca5c53a41eabdad9a6a75b45bda4a6f37b/shell/browser/api/electron_api_safe_storage.cc)
- For macOS specific implementation (current approach): [Chromium OS Crypt for macOS](https://chromium.googlesource.com/chromium/src/+/refs/tags/130.0.6686.2/components/os_crypt/sync/os_crypt_mac.mm)
- Additional resource: [Electron macOS Keychain Patch](https://github.dev/electron/electron/blob/41b8fdca5c53a41eabdad9a6a75b45bda4a6f37b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch)

* 👨‍💻 While this tool is primarily intended for advanced users familiar with encryption key handling, we encourage developers of all levels to explore and contribute to cross-platform solutions.

* 🌍 If you develop a version for another operating system, please consider contributing it back to the community or linking it here as a related project.

## Contributing 🤝

Contributions to improve the tool or extend its functionality to other operating systems are welcome. Please feel free to submit pull requests or create issues for bugs and feature requests. If you're working on a version for another OS, you can open an issue to discuss your approach or seek guidance.

## License 📄

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Disclaimer ⚖️

This tool is not officially associated with Signal. Use at your own risk. Always ensure you comply with relevant laws and Signal's terms of service when using this tool.
135 changes: 135 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# macOS Signal 解密工具 🔐

[English](README.md) | 中文

## 概述 🌟

这个 Signal 解密工具是一个专为 macOS 设计的基于 Rust 的命令行工具,用于处理 Signal 密钥的加密和解密。它提供了一种安全的方式来管理 macOS 系统上 Signal 的加密配置。

## 特性 ✨

- 🔓 解密存储在 macOS 钥匙串中的 Signal 加密密钥
- 📁 支持自定义配置文件路径
- 🔑 可以直接输入加密密钥
- 🛡️ 安全处理敏感信息
- 💻 命令行界面,易于集成到脚本或手动使用
- 🍎 支持 Intel 和 Apple Silicon Mac 的通用二进制文件

## 前提条件 📋

- 🖥️ macOS 操作系统
- 🦀 Rust 编程语言(最新稳定版)
- 📦 Cargo 包管理器

## 安装 🛠️

1. 克隆此仓库:

```
git clone https://github.com/fjh658/signal-decryption-tool.git
cd signal-decryption-tool
```

2. 使用 Cargo 构建项目:

```
cargo build --release
```

3. 编译后的二进制文件将位于 `target/release/signal_decryption`

### 构建通用二进制文件 🏗️

要创建同时适用于 Intel 和 Apple Silicon Mac 的通用二进制文件:

1. 确保已安装必要的 Rust 目标:

```
rustup target add x86_64-apple-darwin aarch64-apple-darwin
```

2. 运行提供的构建脚本:

```
./build_universal_mac.sh
```

3. 通用二进制文件将创建在 `target/universal/SignalDecryption`

此脚本执行以下操作:

- 为 x86_64 和 aarch64 架构构建项目
- 剥离调试符号以减小二进制文件大小
- 使用 `lipo` 将二进制文件合并为通用二进制文件

## 使用方法 📝

从命令行运行工具,使用以下选项:

```
SignalDecryption [选项]
选项:
-h, --help 显示帮助信息
-c, --config PATH 指定 config.json 文件的路径
-k, --key KEY 直接提供加密密钥
-p, --print-key 打印安全存储密钥(谨慎使用)
--version 显示工具版本
```

### 示例 🌈

1. 使用默认配置进行解密:

```
./SignalDecryption
```

2. 使用自定义配置文件:

```
./SignalDecryption -c /path/to/custom/config.json
```

3. 直接提供加密密钥:

```
./SignalDecryption -k "your_encrypted_key_here"
```

4. 打印安全存储密钥(谨慎使用):

```
./SignalDecryption -p
```

## 安全考虑 🔒

- ⚠️ 此工具处理敏感的加密密钥。请在安全的环境中使用。
- 🚨 `-p` 选项会打印敏感信息。仅在必要时在安全的环境中使用。
- 🔐 确保您有必要的权限来访问系统上的 Signal 配置。

## 局限性和未来发展 🚀

* 📱 此工具目前专为 macOS 设计。然而,用户可以基于以下资源为其他操作系统开发类似的工具:

- Windows 实现: [Chromium OS Crypt for Windows](https://chromium.googlesource.com/chromium/src/+/refs/tags/130.0.6686.2/components/os_crypt/sync/os_crypt_win.cc)
- Electron 中的跨平台实现: [Electron Safe Storage API](https://github.com/electron/electron/blob/41b8fdca5c53a41eabdad9a6a75b45bda4a6f37b/shell/browser/api/electron_api_safe_storage.cc)
- macOS 特定实现(当前方法): [Chromium OS Crypt for macOS](https://chromium.googlesource.com/chromium/src/+/refs/tags/130.0.6686.2/components/os_crypt/sync/os_crypt_mac.mm)
- 额外资源: [Electron macOS Keychain Patch](https://github.dev/electron/electron/blob/41b8fdca5c53a41eabdad9a6a75b45bda4a6f37b/patches/chromium/mas_avoid_private_macos_api_usage.patch.patch)

* 👨‍💻 虽然此工具主要面向熟悉加密密钥处理的高级用户,但我们鼓励各级开发者探索并贡献跨平台解决方案。

* 🌍 如果您为其他操作系统开发了版本,请考虑将其贡献回社区或在此处链接作为相关项目。

## 贡献 🤝

欢迎贡献以改进工具或扩展其功能到其他操作系统。请随时提交拉取请求或创建问题以报告错误和功能请求。如果您正在为其他操作系统开发版本,可以开启一个问题来讨论您的方法或寻求指导。

## 许可证 📄

本项目采用 MIT 许可证 - 有关详细信息,请查看 [LICENSE](LICENSE) 文件。

## 免责声明 ⚖️

此工具与 Signal 官方无关。使用风险自负。使用此工具时,请始终确保遵守相关法律和 Signal 的服务条款。
Loading

0 comments on commit 53cf7c7

Please sign in to comment.