google/magika
GitHub: google/magika
一款基于深度学习的 AI 文件类型检测工具,以高精度与低延迟识别海量文件格式。
Stars: 14110 | Forks: 739
# Magika
[](https://pypi.python.org/pypi/magika)
[](https://npmjs.com/package/magika)
[](https://pypi.python.org/pypi/magika)
[](https://pypi.python.org/pypi/magika)
[](https://pkg.go.dev/github.com/google/magika/go)
[](https://www.bestpractices.dev/en/projects/8706)

[](https://github.com/google/magika/actions)
[](https://pepy.tech/projects/magika)
[](https://pepy.tech/projects/magika)
Magika 是一款新型的人工智能文件类型检测工具,依赖深度学习的最新进展提供准确的检测。在底层,Magika 采用了一个经过高度优化的模型,重量仅为几 MB,能够在毫秒级实现精确的文件识别,即使仅运行在单个 CPU 上。Magika 已在约 1 亿个样本、涵盖 200 多种内容类型(包括二进制和文本文件格式)的数据集上进行了训练和评估,并在测试集上实现了约 99% 的平均准确率。
以下是 Magika 命令行输出的示例:
Prints using a custom format (use --help for details).
The following placeholders are supported:
%p The file path
%l The unique label identifying the content type
%d The description of the content type
%g The group of the content type
%m The MIME type of the content type
%e Possible file extensions for the content type
%s The score of the content type for the file
%S The score of the content type for the file in percent
%b The model output if overruled (empty otherwise)
%% A literal %
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
```
有关 CLI 的更多示例和文档,请参见 https://crates.io/crates/magika-cli。
### Python 示例
```
>>> from magika import Magika
>>> m = Magika()
>>> res = m.identify_bytes(b'function log(msg) {console.log(msg);}')
>>> print(res.output.label)
javascript
```
```
>>> from magika import Magika
>>> m = Magika()
>>> res = m.identify_path('./tests_data/basic/ini/doc.ini')
>>> print(res.output.label)
ini
```
```
>>> from magika import Magika
>>> m = Magika()
>>> with open('./tests_data/basic/ini/doc.ini', 'rb') as f:
>>> res = m.identify_stream(f)
>>> print(res.output.label)
ini
```
有关 Python 模块更多示例和文档,请参见 [Python `Magika` 模块](https://securityresearch.google/magika/cli-and-bindings/python/) 部分。
# 文档
请查阅 [Magika 的官方网站](https://securityresearch.google/magika) 以获取关于以下内容的详细文档:
- 核心概念
- Magika 的工作原理
- 模型与内容类型
- 预测模式
- 理解输出
- CLI 与绑定(Python 模块、JavaScript 模块、…)
- 贡献指南
- 常见问题解答
- …
# 安全漏洞
请直接联系我们:magika-dev@google.com。
# 许可证
Apache 2.0;详细信息请参见 [`LICENSE`](LICENSE)。
# 免责声明
本项目不是 Google 的官方项目。
它不受 Google 支持,
Google 明确声明不对其质量、
商业适用性或特定用途的适用性提供任何担保。
标签:AI安全工具, AI文件类型检测, Cilium, Go语言, Magika, NPM, PyPI, Python包, 二进制发布, 低延迟文件识别, 单CPU推理, 可视化界面, 多格式支持, 安全文件检测, 实时文件检测, 开源工具, 快速文件识别, 批量文件识别, 数据分类, 数据可视化, 文件MIME类型, 文件内容分析, 文件内容检测, 文件取证, 文件完整性验证, 文件扩展名检测, 文件格式识别, 文件格式验证, 文件签名识别, 文件类型分类, 文件类型识别, 文件类型识别库, 日志审计, 机器学习文件分类, 模型轻量化, 深度学习的文件检测, 程序破解, 自动化文件识别, 跨平台文件检测, 逆向工具, 高精度文件类型