![PyPI]()
![Python]()
![CI]()
![Publish]()

String extraction for CTI and malware-analysis workflows: surface URLs, IPs, paths, registry keys, APIs, commands, encoded data, and analyst-ready prompts from binaries and memory artifacts.
Use String Analyzer when a sample or dump needs fast indicator discovery before reverse engineering or sandboxing. The output is designed to feed IOC review, infrastructure pi, YARA/Sigma ideas, and ATT&CK-mapped analyst notes.
| Output | Use |
|---|---|
| Categorized strings | IOC and behavior discovery |
| URLs / IPs / emails | Pivot and enrichment leads |
| Registry / paths / DLLs | Host behavior context |
| API names | Capability triage |
| Decoded candidates | Obfuscation review |
| AI-ready prompt | Structured analyst follow-up |
String Analyzer extracts and analyzes printable strings from binary files. It is designed for malware analysts, reverse engineers, and forensics in who need to quickly surface URLs, IPs, registry keys, API names, and other indicators from executables, memory dumps, or disk images—and optionally generate an AI-ready analysis prompt.
analyze_file() or lower-le in your own scripts.📖 Practical guide (Medium) — step-by-step usage, workflows, and examples.
---
---
| Feature | Description |
|--------|-------------|
| String extraction | ASCII and UTF-16LE (Windows PE); configurable min length and max_bytes; chunked read for large files. |
| Entropy | Shannon entropy (chunked when max_bytes set); high entropy suggests packed/encrypted content. |
| Pattern detection | Strict IPv4 (0–255), IPv6 (full and abbre), URLs (http/https/ftp/file/ws/wss), obfuscated URLs (hxxp, etc.), emails, MAC addresses, registry keys, system paths, DLLs, 300+ Windows APIs, CMD/PowerShell, obfuscation patterns. |
| Embedded extraction | URLs, IPs, emails, MACs found *inside* long strings (not only whole-line matches). |
| Decoding | Base64 (standard and URL-safe) and hex; decoded candidates in report. |
| Suspicious keywords | Extended set: malware, miner, steal, persist, e, etc., plus .NET namespaces. |
| Sensitive mode | --sensitive: lower obfuscation thresholds and more keywords for stricter triage. |
| Output formats | Unfiltered dump, categorized report, or AI-ready markdown prompt. |
| CLI & API | Full CLI (--encoding, --sensitive, --no-embedded); programmatic analyze_file(); no global state. |
---
Requirements: Python 3.8 or newer.
After installation you get the string-analyzer command. From the project root you can also run:
De (optional): pip install -e ".[dev]" adds pytest and ruff for tests and linting.
---
---
| Option | Description |
|--------|-------------|
| file | Path to the binary file. Omit to run interactive mode. |
| -o, --output PATH | Output file (default: <basename>_strings.txt). |
| --min-length N | Minimum string length to extract (default: 4). |
| --max-bytes N | Stop reading after N bytes (safety for very large files). |
| --unfiltered | Output all extracted strings, one per line (no categories). |
| --filtered | Output categorized report (default when not using --unfiltered or --ai-prompt). |
| --ai-prompt | Generate markdown prompt for an AI assistant. |
| --analyze-with {gemini,codex} | Send categorized prompt to gemini-cli or codex-cli and print the AI analysis. Saves the prompt to -o; use --ai-output to save the AI response. |
| --ai-output PATH | Save the AI response to this file (when using --analyze-with). |
| --encoding {ascii,utf16,both} | Extract ASCII only, UTF-16LE only, or both (default: both). |
| --sensitive | Lower obfuscation thresholds; more suspicious keywords. |
| --no-embedded | Do not extract URLs/IPs/emails from inside long strings. |
| -i, --interactive | Force interactive mode (prompt for file and options). |
| -q, --quiet | Suppress non-error messages. |
| -v, -- | logging. |
| -- | Show . |
| --help | Show help. |
1. Unfiltered (--unfiltered): sorted list of all extracted strings. Use for grepping or feeding into other tools.
2. Filtered (default): categorized report with entropy, plus sections such as URLS, IPS, WINDOWS_API_COMMANDS, DLLS, OBFUSCATED, etc.
3. AI prompt (--ai-prompt): same categories in a markdown prompt asking an AI to analyze behavior and functionality (e.g. for malware triage).
--analyze-with)The --analyze-with option sends the categorized string report directly to an AI CLI so you get an analysis in one command instead of copying a prompt by hand.
--ai-prompt, writes it to the path given by -o (so you can keep or reuse it), then pipes that prompt into the chosen CLI. The AI’s reply is printed to the terminal; you can save it with --ai-output PATH.gemini — uses gemini-cli (looks for gemini or gemini-cli on your PATH). codex — uses Codex CLI (codex exec - with the prompt on stdin).npm i -g /generati) or Codex CLI. The tool does not call cloud APIs itself; it only invokes the local CLI, which handles authentication and the model.string-analyzer suspect.exe --analyze-with gemini -o prompt.txt --ai-output analysis.md prompt.txt, sends it to Gemini, and writes the AI’s analysis to analysis.md.Run string-analyzer with no file argument (or use string-analyzer -i). The tool will:
1. Ask for the file path.
2. Ask whether to output all strings (unfiltered) or a filtered report.
3. If filtered: ask whether to generate an AI prompt or a normal report.
4. Ask for the output file path (with a default suggestion).
Interactive mode limits input to 50 MB by default to avoid accidental resource use.
---
Strings are classified into the following categories (empty categories are omitted from output):
| Category | Description |
|----------|-------------|
| WINDOWS_API_COMMANDS | Known Windows API function names (300+). |
| DLLS | Strings matching typical DLL names (e.g. *.dll). |
| URLS | HTTP/HTTPS and similar URLs. |
| IPS | IPv4 addresses. |
| IPV6 | IPv6 addresses. |
| EMAILS | Email-like strings. |
| WINDOWS_REGISTRY_KEYS | Registry path patterns. |
| POWERSHELL_COMMANDS | PowerShell cmdlets/commands. |
| CMD_COMMANDS | CMD shell commands. |
| FILES | File path / filename patterns. |
| SYSTEM_PATHS | System directory paths. |
| OBFUSCATED | Patterns suggesting obfuscation (e.g. h[.]xxp, dotted IPs). |
| DECODED_BASE64 | Strings that successfully decode from Base64 to printable text. |
| DECODED_HEX | Strings that successfully decode from hex to printable text. |
| SUSPICIOUS_KEYWORDS | Substrings associated with malware (e.g. key terms). |
| SUSPICIOUS_DOTNET | .NET-related suspicious namespaces/keywords. |
| MAC_ADDRESSES | MAC addresses (e.g. 00:1A:2B:3C:4D:5E). |
The tool also computes file entropy. Combined with a low count of “useful” patterns (APIs, DLLs, CMD/PowerShell), high entropy can indicate a packed or obfuscated binary; this is noted in the report and in the AI prompt.
---
Use the package in your own Python code:
| Function | Description |
|----------|-------------|
| analyze_file(path, min_length=4, max_bytes=None) | Full analysis; returns dict with file, entropy, strings, patterns, obfuscated. |
| extract_strings(path, min_length=4, max_bytes=None) | Extract unique printable strings; returns set[str]. |
| compute_file_entropy(path) | Shannon entropy of file bytes. |
| shannon_entropy(s) | Shannon entropy of a string. |
| detect_patterns(strings) | Categorize strings; returns new dict[str, set[str]]. |
| is_likely_obfuscated(patterns, file_entropy) | Heuristic: few “useful” patterns and entropy > threshold. |
| generate_normal_output(patterns, entropy, obfuscated) | Formatted filtered report text. |
| generate_ai_prompt(patterns, entropy, obfuscated) | Markdown prompt text for AI analysis. |
| is_mostly_printable(s, threshold=0.9) | Whether the string is mostly printable ASCII. |
| try_base64_decode(s) | Decode Base64 if valid and printable; else None. |
| try_hex_decode(s) | Decode hex if valid and printable; else None. |
---
Malware triage — get an AI prompt for a sample:
Large file — limit read size and get a filtered report:
Script — use API and only print URLs and IPs:
Longer strings only:
Maximum sensitivity (UTF-16 + embedded URLs + lower obfuscation bar):
Send to Gemini or Codex for AI analysis (requires gemini-cli or codex on PATH):
---
--min-length (default 4). Longer reduce noise and speed up analysis.--max-bytes. Omit for no limit; set for very large files to avoid high memory use.MIN_USEFUL_COUNT (default 10) and ENTROPY_THRESHOLD (default 5.0) in string_analyzer.patterns. A file is flagged as likely obfuscated when the number of “useful” patterns (Windows API, DLLs, CMD, PowerShell) is below the count threshold and file entropy is above the entropy threshold.---
--max-bytes (or the max_bytes parameter in the API) to cap how much is read; interactive mode uses a 50 MB default.---
CI runs on push/PR: Ruff lint and pytest on Python 3.8, 3.10, and 3.12.
Documentation: Practical guide (Medium) · docs/DOCUMENTATION.md (patterns, heuristics, workflows)
---
| Resource | Link |
|----------|------|
| String-Analyzer (this repo) | GitHub · Medium: String Analyzer Guide |
| Static-malware-Analysis-Orchestrator | GitHub — one-command pipeline (triage, strings, PE imports, unpack) · Medium: Full workflow |
| PE-Import-Analyzer | GitHub · Medium: PE Import Analyzer Guide |
| Unpacker | GitHub · Medium: Unpacker Guide |
| Basic-File-Information-Gathering-Script | GitHub · Medium: File Metadata & Static Analysis |
| Author | Medium @1200km |
---
Distributed under the GNU General Public License v3.0. See LICENSE for details.
Contributions are welcome; please open an issue or submit a pull request.
This project is part of the 1200km security research ecosystem. Use Ad for CTI-to-detection workflows, ATT&CK/ATLAS mapping, actor relevance, IOC enrichment, and analyst-ready reporting.
开发语言:Python
Star 数:7
该项目属于防护思路方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕String extraction for CTI and malware analysis: URLs, IPs, registry keys, APIs, encoded data, and analyst-ready prompts.展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | String-Analyzer - String extraction for CTI and malware analysis: UR |
| 所属分类 | 防护思路 |
| 发布作者 | admin |
| 发布时间 | 2026-10-06 00:13:40 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 374 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |