Thank you for your interest in contributing to this repository! This guide will help you understand how to contribute effectively to our collection of Microsoft 365 Defender hunting queries.
- 🔍 New hunting queries - KQL queries for detecting specific threats
- 🎯 Custom detection rules - Ready-to-deploy detection rules
- 🤖 Automation scripts - PowerShell, Python, or other automation tools
- 📚 Documentation improvements - Enhanced guides, examples, and explanations
- 🐛 Bug fixes - Corrections to existing queries or documentation
- 🌍 Regional threat intelligence - MENA-specific IOCs and TTPs
- Search existing issues to avoid duplicates
- Test your queries in a Microsoft 365 Defender environment
- Follow our coding standards outlined below
- Document your contributions thoroughly
- ✅ Query must execute successfully in M365 Defender
- ✅ Performance optimized - include appropriate time filters
- ✅ Results must be actionable - clear indicators of malicious activity
- ✅ Minimize false positives - include appropriate exclusions
- ✅ Clear description of what the query detects
- ✅ MITRE ATT&CK mapping - specify relevant tactics and techniques
- ✅ Use case explanation - when and why to use this query
- ✅ Customization notes - how to adapt for different environments
// [Query Name] - [Brief Description]
// Author: [Your Name] - [Your Role/Organization]
// MITRE ATT&CK: [Tactics/Techniques]
// Last Updated: [Date]
// Use Case: [When to use this query]
// Customization: [How to customize for different environments]
[Your KQL Query Here]
| where Timestamp > ago(24h) // Always include time filters
| where [additional filters] // Performance optimization
| project // Select only necessary columns
Timestamp,
DeviceName,
AccountName,
[other relevant columns]
| order by Timestamp desc// Banking Trojan Process Injection Detection
// Author: Ali AlEnezi
// MITRE ATT&CK: T1055 (Process Injection), T1082 (System Information Discovery)
// Last Updated: September 2025
// Use Case: Detect banking trojans injecting into legitimate banking processes
// Customization: Update banking process names for your organization's software
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (
"bank", "finance", "payment", "trading"
) and InitiatingProcessCommandLine has_any (
"svchost.exe", "explorer.exe", "winlogon.exe"
)
| where ProcessCommandLine has_any (
"inject", "hollow", "dll", "thread"
)
| where not (ProcessCommandLine has_any (
"LegitimateBank.exe", "AuthorizedTrading.exe"
))
| project
Timestamp,
DeviceName,
AccountName,
ProcessCommandLine,
InitiatingProcessCommandLine,
ProcessId
| order by Timestamp desc# [Category Name] Advanced Hunting Queries
## Overview
[Brief description of the threat category and its relevance to MENA region]
**Author**: [Your Name] - [Your Role/Organization]
**Last Updated**: [Date]
**MITRE ATT&CK Coverage**: [List relevant tactics/techniques]
---
## [Subcategory 1]
### [Query Name]
**Description**: [What the query detects]
**MITRE ATT&CK**: [Specific techniques]
**Regional Relevance**: [Why important for MENA]
[Your KQL Query]
### Performance Notes
- [Performance considerations]
- [Recommended time ranges]
- [Expected result volumes]
### Customization Guide
- [How to adapt for different environments]
- [Organization-specific modifications]
----
Fork the Repository
git clone https://github.com/YourUsername/M365-Defender-Hunting-MENA.git cd M365-Defender-Hunting-MENA -
Create a Feature Branch
git checkout -b feature/new-banking-queries
-
Add Your Contribution
- Place queries in appropriate category folders
- Follow naming convention:
ThreatName-Detection.md - Update main README.md if adding new categories
-
Test Your Queries
- Validate syntax in M365 Defender portal
- Test with sample data if available
- Document any limitations or requirements
-
Commit Your Changes
git add . git commit -m "Add banking trojan detection queries"
-
Push to Your Fork
git push origin feature/new-banking-queries
-
Create Pull Request
- Use descriptive title and detailed description
- Reference any related issues
- Include testing results
## Description
[Brief description of changes]
## Type of Change
- [ ] New hunting query
- [ ] Bug fix
- [ ] Documentation update
- [ ] Performance improvement
- [ ] Regional threat intelligence
## Testing
- [ ] Query executes successfully in M365 Defender
- [ ] Results are actionable and relevant
- [ ] Performance is acceptable (< 30 seconds for 24h queries)
- [ ] False positive rate is minimal
## MITRE ATT&CK Mapping
- **Tactics**: [List tactics]
- **Techniques**: [List techniques with IDs]
## Regional Relevance
[Explain why this is relevant for MENA cybersecurity landscape]
## Checklist
- [ ] Code follows repository standards
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Query tested in non-production environment-
Banking and Financial Services
- ATM malware and jackpotting
- SWIFT network attacks
- Mobile banking fraud
- Cryptocurrency threats
-
Government and Critical Infrastructure
- APT groups targeting government
- Energy sector (oil, gas, renewables)
- Telecommunications infrastructure
- Transportation and logistics
-
Geopolitical Cyber Activities
- State-sponsored campaigns
- Regional conflict-related threats
- Influence operations
- Information warfare
-
Regional Malware Families
- Agent Tesla variants
- Lokibot campaigns
- Remote access trojans
- Mobile malware
- GCC CERT - Gulf Cooperation Council Computer Emergency Response Team
- NCSC-Kuwait - Kuwait National Cyber Security Center
- CBK-Kuwait - Central Bank of Kuwait
- NCSC-UAE - UAE National Cyber Security Council
- NCA-KSA - Saudi National Cybersecurity Authority
- Q-CERT - Qatar Computer Emergency Response Team
-
Microsoft 365 Defender Portal Access
- Advanced hunting permissions
- Custom detection rule permissions
- API access (for automation scripts)
-
Development Tools
- VS Code with KQL extension
- Git for version control
- PowerShell 5.1 or 7.x
- Python 3.8+ (for automation scripts)
# Install KQL extension for VS Code
code --install-extension ms-kusto.kusto
# Clone repository
git clone https://github.com/YourUsername/M365-Defender-Hunting-MENA.git
cd M365-Defender-Hunting-MENA
# Set up branch
git checkout -b feature/your-contribution-
Time Range Optimization
// Always specify time ranges | where Timestamp > ago(24h) // For real-time detection | where Timestamp > ago(7d) // For trend analysis
-
Filtering Efficiency
// Filter early and often DeviceProcessEvents | where Timestamp > ago(24h) // Time filter first | where DeviceName has "SERVER" // Device filter second | where ProcessCommandLine has "cmd" // Content filter third
-
Result Set Limitation
// Limit results to prevent timeouts | take 1000 // Limit to 1000 results | top 100 by Timestamp desc // Top 100 most recent
-
Join Optimization
// Use appropriate join types | join kind=inner // When you need matches in both tables | join kind=leftouter // When you need all left table records
Before submitting, test your queries with:
- 24-hour time range - Should complete within 30 seconds
- 7-day time range - Should complete within 2 minutes
- 30-day time range - Should complete within 5 minutes
-
No Sensitive Data in Examples
- Use example.com for domain names
- Use 192.168.1.x for IP addresses
- Use placeholder user names like "user@domain.com"
-
Anonymization Requirements
// Anonymize sensitive information | extend AnonymizedUser = hash_sha256(AccountName) | project-away AccountName // Remove original sensitive field
-
Compliance Considerations
- Ensure queries comply with local data protection laws
- Consider data retention policies
- Respect privacy regulations (GDPR, local equivalents)
- No live malware samples in the repository
- No active C2 domains or IP addresses
- Historical threat indicators only (>30 days old)
- Coordinate with vendors for 0-day disclosures
Contributors will be recognized through:
- Author attribution in query headers
- Contributors section in main README
- Release notes for significant contributions
- LinkedIn recommendations for substantial contributions
Bronze Contributor (1-5 quality queries)
- Queries execute successfully
- Proper documentation
- MITRE ATT&CK mapping
Silver Contributor (6-15 quality queries)
- Performance optimized queries
- Regional threat intelligence integration
- Community feedback incorporation
Gold Contributor (16+ quality queries)
- Innovative detection techniques
- Automation script contributions
- Mentoring other contributors
- GitHub Issues - For bug reports and feature requests
- GitHub Discussions - For questions and community discussion
- Email - site@hotmail.com for direct contact
- LinkedIn - Ali AlEnezi for professional networking
Query Performance Issues
// Add appropriate time filters
| where Timestamp > ago(24h)
// Use efficient filtering
| where DeviceName in ("Server1", "Server2") // Use 'in' for multiple valuesFalse Positive Reduction
// Add exclusion filters
| where not (ProcessCommandLine has_any ("legitimate.exe", "approved.exe"))
// Use statistical thresholds
| where ConnectionCount > 100 // Adjust based on environmentDocumentation Standards
- Always include MITRE ATT&CK mapping
- Provide customization guidance
- Explain regional relevance
- Include performance notes
- Automated testing pipeline for query validation
- Integration with MISP for threat intelligence
- Mobile app for query reference
- Training materials and webinars
- Multi-language support (Arabic documentation)
We're actively seeking contributions in:
- SOAR integration playbooks
- Threat intelligence feed integration
- Compliance mapping (PCI DSS, ISO 27001)
- Regional customization templates
Thank you for contributing to the MENA cybersecurity community! 🛡️
Together, we're building a stronger defense against regional cyber threats.
For questions or support, contact Ali AlEnezi - site@hotmail.com