performing-yara-rule-development-for-detection
ما الذي تفعله
تساعد هذه المهارة على إنشاء قواعد لتحديد البرمجيات الخبيثة. تحلل الملفات لإيجاد أنماط فريدة، مثل نصوص أو تسلسلات بايت، خاصة ببرمجية خبيثة معينة، مما يساعد على كشفها وتجنب الإنذارات الخاطئة.
متى تستخدمها
- ✓عند بناء دفاعات ضد التهديدات الرقمية.
- ✓عند تصنيف أنواع البرمجيات الخبيثة المختلفة.
- ✓عند تحويل المعلومات الاستخبارية عن التهديدات إلى قواعد كشف.
رابط المهارة
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-yara-rule-development-for-detection/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“ساعدني في إنشاء قاعدة YARA لكشف البرمجية الخبيثة التي تستخدم النص « evil_command » وتتصل بالعنوان IP « 192.168.1.100 ».”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تفحص هذه المهارة شيفرة البرنامج بحثاً عن نصوص أو تسلسلات بايت مميزة. تستخدم هذه النتائج لبناء « توقيع » (قاعدة YARA) يمكنه التعرف على ذلك البرنامج تحديداً على أجهزة أخرى.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Performing YARA Rule Development for Detection
Overview
YARA is the pattern matching swiss knife for malware researchers, enabling identification and classification of malware based on textual or binary patterns. Effective YARA rules combine unique string patterns, byte sequences, PE header characteristics, import table analysis, and conditional logic to detect malware families while avoiding false positives. Modern YARA-X (rewritten in Rust, stable since June 2025) brings improved performance and new modules. Rules should target unpacked malware artifacts like hardcoded stack strings, C2 URLs, mutex names, encryption constants, and unique code sequences rather than packer signatures.
When to Use
- When conducting security assessments that involve performing yara rule development for detection
- When following incident response procedures for related security events
- When performing scheduled security testing or auditing activities
- When validating security controls through hands-on testing
Prerequisites
- Python 3.9+ with
yara-pythonlibrary - YARA 4.5+ or YARA-X 0.10+
- PE analysis tools (
pefile,pestudio) - Hex editor for identifying unique byte patterns
- Access to malware samples (VirusTotal, MalwareBazaar)
- Understanding of PE file format, strings, and import tables
Key Concepts
Rule Structure
Every YARA rule consists of three sections: meta (optional descriptive metadata), strings (pattern definitions), and condition (matching logic). String types include text strings (ASCII/wide/nocase), hex patterns with wildcards and jumps, and regular expressions. Conditions combine string matches with file properties using boolean operators.
String Selection Strategy
Effective rules target patterns that are unique to the malware family and survive recompilation. Hardcoded stack strings are excellent choices because compilers embed them consistently. C2 domain patterns, custom encryption routines, unique error messages, and specific API call sequences provide stable detection anchors. Avoid compiler-generated boilerplate and common library strings.
Performance Optimization
YARA evaluates conditions short-circuit style. Place the most discriminating and cheapest-to-evaluate conditions first. Use filesize limits to skip irrelevant files quickly. Minimize regex usage in favor of hex patterns. Use private rules as building blocks for complex detection logic without generating standalone matches.
Workflow
Step 1: Analyze Sample for Unique Patterns
#!/usr/bin/env python3
"""Extract candidate strings and byte patterns for YARA rule creation."""
import pefile
import re
import sys
from collections import Counter
def extract_strings(filepath, min_length=6):
"""Extract ASCII and wide strings from binary."""
with open(filepath, 'rb') as f:
data = f.read()
# ASCII strings
ascii_strings = re.findall(
rb'[\x20-\x7e]{' + str(min_length).encode() + rb',}', data
)
# Wide (UTF-16LE) strings
wide_strings = re.findall(
rb'(?:[\x20-\x7e]\x00){' + str(min_length).encode() + rb',}', data
)
return {
'ascii': [s.decode('ascii') for s in ascii_strings],
'wide': [s.decode('utf-16-le') for s in wide_strings],
}
def analyze_pe_imports(filepath):
"""Extract import table for API-based detection."""
try:
pe = pefile.PE(filepath)
except pefile.PEFormatError:
return []
imports = []
if hasattr(pe, 'DIRECTORY_ENTRY_IMPORT'):
for entry in pe.DIRECTORY_ENTRY_IMPORT:
dll_name = entry.dll.decode('utf-8', errors='replace')
for imp in entry.imports:
if imp.name:
func_name = imp.name.decode('utf-8', errors='replace')
imports.append(f"{dll_name}!{func_name}")
return imports
def find_unique_byte_patterns(filepath, pattern_length=16):
"""Find unique byte sequences suitable for YARA hex patterns."""
with open(filepath, 'rb') as f:
data = f.read()
try:
pe = pefile.PE(filepath)
# Focus on code section
for section in pe.sections:
if section.Characteristics & 0x20000000: # IMAGE_SCN_MEM_EXECUTE
code_start = section.PointerToRawData
code_end = code_start + section.SizeOfRawData
code_data = data[code_start:code_end]
break
else:
code_data = data
…
الأسئلة الشائعة
ما هي قواعد YARA؟
قواعد YARA مثل التوقيعات الرقمية التي تصف أنماطاً في الملفات، وتُستخدم لتحديد البرمجيات الخبيثة وتصنيفها.
ما هي « الإيجابيات الكاذبة »؟
تحدث الإيجابيات الكاذبة عندما تصنّف قاعدة أمنية شيئاً ما على أنه خبيث رغم أنه برنامج غير ضار.
لماذا يُعد تحليل « آثار البرمجيات الخبيثة بعد فك التغليف » مهماً؟
غالباً ما تخفي البرمجيات الخبيثة نفسها (تكون « مغلّفة »). تحليل الشيفرة بعد فك التغليف يكشف خصائصها الحقيقية والفريدة، مما يجعل الكشف أدق.
التفاصيل
الوصف الأصلي من المؤلف
Develops precise YARA and YARA-X rules for malware detection by identifying unique strings, byte sequences, PE header traits, and behavioral indicators in unpacked malware artifacts while minimizing false positives. Use when building detection signatures for threat hunting, classifying malware families, or authoring rules from IOCs such as C2 URLs, mutex names, and encryption constants.
الشعبية
- نجوم GitHub
- 35k
- الترتيب
- #8340
- الترخيص
- Apache-2.0
- آخر تحديث
- 31/8/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
abusing-dpapi-for-credential-access
35kيمنح وكيل الذكاء الاصطناعي تعليمات جاهزة لمهمة محددة، ليؤديها بشكل أفضل وأسرع.
abusing-shadow-credentials-for-privesc
35kيعلّم وكيل الذكاء الاصطناعي لديك كتابة نص واضح ومنظم جيدًا.
achieving-cmmc-level-2-compliance
35kيساعد وكيلك على تجهيز بيئة للامتثال لمستوى CMMC 2. يطبق متطلبات الأمان ويدير الوثائق اللازمة.
acquiring-disk-image-with-dd-and-dcfldd
35kيساعد وكيلك على إنشاء نسخ مطابقة تمامًا لأقراص التخزين. هذا مفيد لضمان عدم فقدان أي معلومات أو تغييرها أثناء التحقيقات.
مهارات مشابهة
add-model-provider
394kتتيح لوكيلك ربط مزوّد نموذج ذكاء اصطناعي جديد بـ OpenClaw باستخدام أوامر إعداد آمنة، وإبقاء مفاتيح API خارج النص العادي، وإجراء اختبار حي.
acp-router
394kيساعد وكيلك على إرسال مهمة إلى مساعد برمجة مثل Claude Code أو Cursor عبر OpenClaw، فيعمل العمل داخل تلك الأداة.
browser-automation
394kتعلّم وكيلك التحكم في صفحات الويب خطوة بخطوة، بما في ذلك تسجيل الدخول والتبويبات والتعافي عندما تتوقف الصفحة عن الاستجابة.