A Python tool that analyzes file hashes using VirusTotal's API and provides both basic threat summaries and AI-powered analysis using OpenAI GPT-4.
- π VirusTotal Integration: Query file reports using SHA256 hashes
- π Basic Threat Summary: Display detection rates, threat levels, and top detections
- π€ AI-Powered Analysis: Use GPT-4 to provide plain English threat intelligence summaries
- π― Interactive Mode: Command-line interface for easy analysis
- π Multiple Usage Options: Use as a library or standalone tool
pip install -r requirements.txt- Go to VirusTotal
- Create an account or sign in
- Go to your profile and get your API key
- Go to OpenAI Platform
- Create an account or sign in
- Generate an API key
# Required for VirusTotal
export VT_API_KEY="your_virustotal_api_key_here"
# Optional for AI analysis
export OPENAI_API_KEY="your_openai_api_key_here"Windows (Command Prompt):
set VT_API_KEY=your_virustotal_api_key_here
set OPENAI_API_KEY=your_openai_api_key_hereWindows (PowerShell):
$env:VT_API_KEY="your_virustotal_api_key_here"
$env:OPENAI_API_KEY="your_openai_api_key_here"Run the script directly:
python main.pyThis will start an interactive session where you can:
- Enter SHA256 hashes to analyze
- Get both basic and AI-powered summaries
- Exit with 'quit', 'exit', or 'q'
from main import get_file_report, print_threat_summary, summarize_with_gpt4, get_file_report_with_ai_summary
# Basic usage
file_hash = "your_sha256_hash_here"
result = get_file_report(file_hash)
print_threat_summary(result)
# AI-powered analysis
ai_summary = summarize_with_gpt4(result)
print(ai_summary)
# Or use the combined function
result = get_file_report_with_ai_summary(file_hash)python -c "
from main import get_file_report_with_ai_summary
get_file_report_with_ai_summary('your_sha256_hash_here')
"π VirusTotal Threat Intelligence Analyzer
==================================================
=== VirusTotal Threat Summary ===
π
Scan Date: 2024-01-15 10:30:45
π Detection Rate: 15/70 (21.4%)
π¨ Status: Medium Risk - Multiple detections
π Top Detections:
β’ Kaspersky: Trojan.Win32.Generic
β’ Avast: Win32:Trojan-gen
β’ Bitdefender: Trojan.Generic.123456
β’ Malwarebytes: Trojan.Malware
β’ Norton: Suspicious.Cloud.5
π Full Report: https://www.virustotal.com/file/...
π€ AI-Powered Threat Analysis:
========================================
This file shows a medium-risk threat profile with 15 out of 70 antivirus engines detecting it as malicious (21.4% detection rate). The threat appears to be a generic Trojan targeting Windows systems, as indicated by multiple major antivirus vendors detecting it as "Trojan.Win32.Generic" or similar variants.
**Severity Assessment:** Medium Risk
**Malware Family:** Generic Trojan
**Key Insights:** This is likely a polymorphic or generic trojan that may perform various malicious activities such as data theft, system compromise, or backdoor functionality.
**Recommended Actions:**
1. Quarantine the file immediately
2. Run a full system scan
3. Monitor for unusual network activity
4. Check for unauthorized system changes
========================================
- Purpose: Get raw VirusTotal report
- Returns: JSON response from VirusTotal API
- Requires: VT_API_KEY
- Purpose: Display formatted threat summary
- Input: VirusTotal API response
- Output: Printed summary to console
- Purpose: Generate AI-powered threat analysis
- Input: VirusTotal API response
- Returns: Plain English summary
- Requires: OPENAI_API_KEY
- Purpose: Complete analysis with both basic and AI summaries
- Returns: VirusTotal API response
- Requires: VT_API_KEY (OPENAI_API_KEY optional)
sha256sum filenameGet-FileHash -Algorithm SHA256 filenamecertutil -hashfile filename SHA256The tool includes comprehensive error handling for:
- Missing API keys
- Invalid file hashes
- Network connectivity issues
- API rate limiting
- Invalid responses
- VirusTotal: 4 requests per minute for public API
- OpenAI: Depends on your plan (typically 3-10 requests per minute for GPT-4)
- Make sure you've set the environment variable correctly
- Restart your terminal after setting the variable
- This is optional - the tool will work without AI analysis
- Set the variable if you want AI-powered summaries
- Check your internet connection
- Verify your VirusTotal API key is correct
- Check if you've hit the rate limit
- Verify your OpenAI API key is correct
- Check your OpenAI account balance
- Ensure you have access to GPT-4 model
This project is open source and available under the MIT License.