SlideShare a Scribd company logo
Introduction to
YARA Rules
By: Akshay Jain
Twitter: Akshayjain890
YARA Rules in a Nutshell
Yara is an open source tool utilised by malware researcher to identify
malware and to setup patterns that identify families of malware based on
rules.
It supports multiple platforms , running on Linux, Windows and Mac OS, it
can be used through command line or python scripts.
These rules consist of a set of strings and expression which identifies the
pattern, YARA rules can be used to perform signature based- detection of
malwares.
YARA rules are easy to write and understand, they have similar structure
that looks like c language and it has predefined words in creating YARA
rules
YARA keywords
YARA rules start with the word rule and follows by an identifier name, the
following keywords cant be used as an identifier as they have special
meaning in YARA rules
Strings
YARA Rules are commonly made out of two things: String
definition and condition.
String definition: The strings section is where you declare a variable
and set the rules. Each variable is indicated using the $ sign
followed by the variable name consist of alphanumeric characters
and underscores and it is case sensitive.
String in YARA can be classified in to three types and they are
• Hexadecimal Strings.
• Text strings
• Regular expressions
Hexadecimal Strings
Rules can be set in form of Hexadecimal strings which will match
hexadecimal characters in the sample file. Some of the methods used are as
follow:
• Wildcard: This is represented by a ‘?’ and it indicates that some bytes in the
strings is unknown and should match anything
$hex_example={ B1 B2 ?? B4}
Result: {B1 B2 B3 B4}
• Jumps: In circumstance when we know the values of pattern but their
length varies then we can use jump example:
$jump_example={ 81 12 [2-4] 24 } this indicates that any arbitrary sequence
from 2 bytes to 3 bytes can occupy the sequence
Result: { 81 12 3 24 }
• Infinite: YARA is capable to detect infinite hex value in a strings
Infinte_example={ FE 18 [2-] 89 45 }
{ FE 18 [ - ] 89 45 }
Result: { FE 18 66 89 45 }
• Conditional:You can create 1 to as many statements to provide
different alternative for the hex fragment.
Conditional_example={ F4 23 ( 62 B4 | 56 ) 45 }
Result: { F4 23 62 B4 45 }
{ F4 23 62 56 45 }
Lets add up every thing
Rule rabbithole
{
Strings:
$rule1= { F4 23 [-] (62 45 | 56) [20-40] }
CONDITION:
$rule1
}
Text Strings
Text strings: Text strings are in form of ASCII text which is then
matched up with the condition set. This section also contain further
types
• Case Sensitive Strings
Example= $case_example= “test”
• Case Insensitive String
Example=$nocase_example= “test” nocase
• Wide character string:
Example=$wide_example=“test” wide
The wide modifiers can be used to search for strings encoded with
2 bytes per char
• Fullword: This modifier guarantees that the string will match only
if it appears in the file delimited by non-alphanumeric characters.
Example: $shadow1= “zebra.com” fullword
Condition and Meta
Condition: The condition section is used to express what you want your
rule to detect. This is done by writing an expressing using logical
operator, the condition must include all the strings.
It contains a Boolean expression that determine the result. It contains all
the usual logical and relational operator. You can also include another
rule as part of your condition
Meta: Metadata can be added to help identify the files that were picked
up by a certain rule. The metadata identifier are always followed by an
equal sign and the set value. The assigned values can be strings integer
or a Boolean value.
Counting strings
Counting strings: YARA rules can allow us to count how many times a string
have occurred in the file or process memory. The number of
occurrences of each string is represented by a variable whose
name is same as the string identifier with a ‘#’ instead of $
character.
• rule Count_Example
{
strings:
$a = “remote" $b = “string2"
condition:
#a == 6 and #b > 10
}
Virtual address
String identifier is used to check if the given rule is associated to
any string in the file or sample, we can also detect the string is
present at certain address with in the address space. The at operator
is used to check if the string is at some specific offset.
• Example: rule Count_Example
{
strings:
$a = “string1"
$b = “string2"
condition:
#a at 50 and #b at 10
}
Set of strings and file size
We can check certain number of strings from rule are present from a given list we can
use of operator.
Filesize: The filesize is used to check the file size of a given file or sample.
• Example
Rule HTB
{
strings:
$m1 = “nest”
$m2 = “sniper"
$m3 = “Book“
condition: 2 of ($m1,$m2,$m3) and filesize < 10000KB
}
Demo
Reference:
• https://0x00sec.org/t/tutorial-creating-yara-signatures-for-malware-
detection/5453
• https://github.com/Neo23x0/signaturease/blob/master/yara/crime_wannacry.yar
• https://www.vmray.com/analyses/wannacry-ransomware/report/yara.html
• https://blog.claroty.com/leveraging-yara-rules-for-early-malware-detection
Contact:
LinkedIn: https://www.linkedin.com/in/akshay-
jain-533a79111/
EMail: jraiv02@gmail.com

More Related Content

What's hot

Analysing Ransomware
Analysing RansomwareAnalysing Ransomware
Analysing Ransomware
Napier University
 
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
Michael Gough
 
Burp suite
Burp suiteBurp suite
Burp suite
SOURABH DESHMUKH
 
Remnux tutorial-1 Statically Analyse Portable Executable(PE) Files
Remnux tutorial-1  Statically Analyse Portable Executable(PE) FilesRemnux tutorial-1  Statically Analyse Portable Executable(PE) Files
Remnux tutorial-1 Statically Analyse Portable Executable(PE) Files
Rhydham Joshi
 
Wireshark
WiresharkWireshark
Wireshark
Sourav Roy
 
Ch 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social EngineeringCh 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social Engineering
Sam Bowne
 
Owasp top 10 vulnerabilities
Owasp top 10 vulnerabilitiesOwasp top 10 vulnerabilities
Owasp top 10 vulnerabilities
OWASP Delhi
 
Sandboxing
SandboxingSandboxing
Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
Hossein Yavari
 
Corporate threat vector and landscape
Corporate threat vector and landscapeCorporate threat vector and landscape
Corporate threat vector and landscape
yohansurya2
 
Building the Security Operations and SIEM Use CAse
Building the Security Operations and SIEM Use CAseBuilding the Security Operations and SIEM Use CAse
Building the Security Operations and SIEM Use CAse
Don Murdoch GSE CyberGuardian CISSP
 
SolarWInds-Incident-ppt.pptx
SolarWInds-Incident-ppt.pptxSolarWInds-Incident-ppt.pptx
SolarWInds-Incident-ppt.pptx
TusharPuri20
 
The Rise of Ransomware
The Rise of RansomwareThe Rise of Ransomware
The Rise of Ransomware
Tharindu Edirisinghe
 
Ethical hacking
Ethical hackingEthical hacking
Ethical hacking
Alapan Banerjee
 
malware analysis
malware  analysismalware  analysis
malware analysis
20CS201AkashR
 
Mobile Application Penetration Testing
Mobile Application Penetration TestingMobile Application Penetration Testing
Mobile Application Penetration Testing
BGA Cyber Security
 
Ransomware Attack.pptx
Ransomware Attack.pptxRansomware Attack.pptx
Ransomware Attack.pptx
IkramSabir4
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and You
Kevin Fealey
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
Nezar Alazzabi
 
Web Application Firewall
Web Application FirewallWeb Application Firewall
Web Application Firewall
Chandrapal Badshah
 

What's hot (20)

Analysing Ransomware
Analysing RansomwareAnalysing Ransomware
Analysing Ransomware
 
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
EDR, ETDR, Next Gen AV is all the rage, so why am I ENRAGED?
 
Burp suite
Burp suiteBurp suite
Burp suite
 
Remnux tutorial-1 Statically Analyse Portable Executable(PE) Files
Remnux tutorial-1  Statically Analyse Portable Executable(PE) FilesRemnux tutorial-1  Statically Analyse Portable Executable(PE) Files
Remnux tutorial-1 Statically Analyse Portable Executable(PE) Files
 
Wireshark
WiresharkWireshark
Wireshark
 
Ch 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social EngineeringCh 4: Footprinting and Social Engineering
Ch 4: Footprinting and Social Engineering
 
Owasp top 10 vulnerabilities
Owasp top 10 vulnerabilitiesOwasp top 10 vulnerabilities
Owasp top 10 vulnerabilities
 
Sandboxing
SandboxingSandboxing
Sandboxing
 
Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
 
Corporate threat vector and landscape
Corporate threat vector and landscapeCorporate threat vector and landscape
Corporate threat vector and landscape
 
Building the Security Operations and SIEM Use CAse
Building the Security Operations and SIEM Use CAseBuilding the Security Operations and SIEM Use CAse
Building the Security Operations and SIEM Use CAse
 
SolarWInds-Incident-ppt.pptx
SolarWInds-Incident-ppt.pptxSolarWInds-Incident-ppt.pptx
SolarWInds-Incident-ppt.pptx
 
The Rise of Ransomware
The Rise of RansomwareThe Rise of Ransomware
The Rise of Ransomware
 
Ethical hacking
Ethical hackingEthical hacking
Ethical hacking
 
malware analysis
malware  analysismalware  analysis
malware analysis
 
Mobile Application Penetration Testing
Mobile Application Penetration TestingMobile Application Penetration Testing
Mobile Application Penetration Testing
 
Ransomware Attack.pptx
Ransomware Attack.pptxRansomware Attack.pptx
Ransomware Attack.pptx
 
Static Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and YouStatic Analysis Security Testing for Dummies... and You
Static Analysis Security Testing for Dummies... and You
 
Introduction to penetration testing
Introduction to penetration testingIntroduction to penetration testing
Introduction to penetration testing
 
Web Application Firewall
Web Application FirewallWeb Application Firewall
Web Application Firewall
 

Similar to Introduction to YARA rules

Yara user's manual 1.6
Yara user's manual 1.6Yara user's manual 1.6
Yara user's manual 1.6
Vijay Kumar
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
pramodkumar1804
 
Pj01 3-java-variable and data types
Pj01 3-java-variable and data typesPj01 3-java-variable and data types
Pj01 3-java-variable and data types
SasidharaRaoMarrapu
 
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docxLab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
smile790243
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
Mohammed Khan
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
Eduardo Bergavera
 
LectureNotes-05-DSA
LectureNotes-05-DSALectureNotes-05-DSA
LectureNotes-05-DSA
Haitham El-Ghareeb
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
Vince Vo
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
Rajeshkumar Reddy
 
9
99
Java scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerJava scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java Scanner
Edward Nyang'ali
 
Java Basics
Java BasicsJava Basics
VHDL- data types
VHDL- data typesVHDL- data types
VHDL- data types
VandanaPagar1
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
VimalSangar1
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented Programming
Badar Waseer
 
Md04 flow control
Md04 flow controlMd04 flow control
Md04 flow control
Rakesh Madugula
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
phanleson
 
Sas array statement
Sas array statementSas array statement
Sas array statement
Ravi Mandal, MBA
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdf
GaneshRaghu4
 
Java Programming
Java Programming Java Programming
Java Programming
RubaNagarajan
 

Similar to Introduction to YARA rules (20)

Yara user's manual 1.6
Yara user's manual 1.6Yara user's manual 1.6
Yara user's manual 1.6
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
Pj01 3-java-variable and data types
Pj01 3-java-variable and data typesPj01 3-java-variable and data types
Pj01 3-java-variable and data types
 
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docxLab 1 Recursion  Introduction   Tracery (tracery.io.docx
Lab 1 Recursion  Introduction   Tracery (tracery.io.docx
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
LectureNotes-05-DSA
LectureNotes-05-DSALectureNotes-05-DSA
LectureNotes-05-DSA
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
C UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDYC UNIT-3 PREPARED BY M V B REDDY
C UNIT-3 PREPARED BY M V B REDDY
 
9
99
9
 
Java scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java ScannerJava scanner, everything you need to know about Java Scanner
Java scanner, everything you need to know about Java Scanner
 
Java Basics
Java BasicsJava Basics
Java Basics
 
VHDL- data types
VHDL- data typesVHDL- data types
VHDL- data types
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented Programming
 
Md04 flow control
Md04 flow controlMd04 flow control
Md04 flow control
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
Sas array statement
Sas array statementSas array statement
Sas array statement
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdf
 
Java Programming
Java Programming Java Programming
Java Programming
 

More from n|u - The Open Security Community

Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)
n|u - The Open Security Community
 
Osint primer
Osint primerOsint primer
SSRF exploit the trust relationship
SSRF exploit the trust relationshipSSRF exploit the trust relationship
SSRF exploit the trust relationship
n|u - The Open Security Community
 
Nmap basics
Nmap basicsNmap basics
Metasploit primary
Metasploit primaryMetasploit primary
Api security-testing
Api security-testingApi security-testing
Api security-testing
n|u - The Open Security Community
 
Introduction to TLS 1.3
Introduction to TLS 1.3Introduction to TLS 1.3
Introduction to TLS 1.3
n|u - The Open Security Community
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
n|u - The Open Security Community
 
Talking About SSRF,CRLF
Talking About SSRF,CRLFTalking About SSRF,CRLF
Talking About SSRF,CRLF
n|u - The Open Security Community
 
Building active directory lab for red teaming
Building active directory lab for red teamingBuilding active directory lab for red teaming
Building active directory lab for red teaming
n|u - The Open Security Community
 
Owning a company through their logs
Owning a company through their logsOwning a company through their logs
Owning a company through their logs
n|u - The Open Security Community
 
Introduction to shodan
Introduction to shodanIntroduction to shodan
Introduction to shodan
n|u - The Open Security Community
 
Cloud security
Cloud security Cloud security
Detecting persistence in windows
Detecting persistence in windowsDetecting persistence in windows
Detecting persistence in windows
n|u - The Open Security Community
 
Frida - Objection Tool Usage
Frida - Objection Tool UsageFrida - Objection Tool Usage
Frida - Objection Tool Usage
n|u - The Open Security Community
 
OSQuery - Monitoring System Process
OSQuery - Monitoring System ProcessOSQuery - Monitoring System Process
OSQuery - Monitoring System Process
n|u - The Open Security Community
 
DevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -SecurityDevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -Security
n|u - The Open Security Community
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
n|u - The Open Security Community
 
Linux for hackers
Linux for hackersLinux for hackers
Android Pentesting
Android PentestingAndroid Pentesting

More from n|u - The Open Security Community (20)

Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)Hardware security testing 101 (Null - Delhi Chapter)
Hardware security testing 101 (Null - Delhi Chapter)
 
Osint primer
Osint primerOsint primer
Osint primer
 
SSRF exploit the trust relationship
SSRF exploit the trust relationshipSSRF exploit the trust relationship
SSRF exploit the trust relationship
 
Nmap basics
Nmap basicsNmap basics
Nmap basics
 
Metasploit primary
Metasploit primaryMetasploit primary
Metasploit primary
 
Api security-testing
Api security-testingApi security-testing
Api security-testing
 
Introduction to TLS 1.3
Introduction to TLS 1.3Introduction to TLS 1.3
Introduction to TLS 1.3
 
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
Gibson 101 -quick_introduction_to_hacking_mainframes_in_2020_null_infosec_gir...
 
Talking About SSRF,CRLF
Talking About SSRF,CRLFTalking About SSRF,CRLF
Talking About SSRF,CRLF
 
Building active directory lab for red teaming
Building active directory lab for red teamingBuilding active directory lab for red teaming
Building active directory lab for red teaming
 
Owning a company through their logs
Owning a company through their logsOwning a company through their logs
Owning a company through their logs
 
Introduction to shodan
Introduction to shodanIntroduction to shodan
Introduction to shodan
 
Cloud security
Cloud security Cloud security
Cloud security
 
Detecting persistence in windows
Detecting persistence in windowsDetecting persistence in windows
Detecting persistence in windows
 
Frida - Objection Tool Usage
Frida - Objection Tool UsageFrida - Objection Tool Usage
Frida - Objection Tool Usage
 
OSQuery - Monitoring System Process
OSQuery - Monitoring System ProcessOSQuery - Monitoring System Process
OSQuery - Monitoring System Process
 
DevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -SecurityDevSecOps Jenkins Pipeline -Security
DevSecOps Jenkins Pipeline -Security
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Linux for hackers
Linux for hackersLinux for hackers
Linux for hackers
 
Android Pentesting
Android PentestingAndroid Pentesting
Android Pentesting
 

Recently uploaded

Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

Introduction to YARA rules

  • 1. Introduction to YARA Rules By: Akshay Jain Twitter: Akshayjain890
  • 2. YARA Rules in a Nutshell Yara is an open source tool utilised by malware researcher to identify malware and to setup patterns that identify families of malware based on rules. It supports multiple platforms , running on Linux, Windows and Mac OS, it can be used through command line or python scripts. These rules consist of a set of strings and expression which identifies the pattern, YARA rules can be used to perform signature based- detection of malwares. YARA rules are easy to write and understand, they have similar structure that looks like c language and it has predefined words in creating YARA rules
  • 3. YARA keywords YARA rules start with the word rule and follows by an identifier name, the following keywords cant be used as an identifier as they have special meaning in YARA rules
  • 4. Strings YARA Rules are commonly made out of two things: String definition and condition. String definition: The strings section is where you declare a variable and set the rules. Each variable is indicated using the $ sign followed by the variable name consist of alphanumeric characters and underscores and it is case sensitive. String in YARA can be classified in to three types and they are • Hexadecimal Strings. • Text strings • Regular expressions
  • 5. Hexadecimal Strings Rules can be set in form of Hexadecimal strings which will match hexadecimal characters in the sample file. Some of the methods used are as follow: • Wildcard: This is represented by a ‘?’ and it indicates that some bytes in the strings is unknown and should match anything $hex_example={ B1 B2 ?? B4} Result: {B1 B2 B3 B4} • Jumps: In circumstance when we know the values of pattern but their length varies then we can use jump example: $jump_example={ 81 12 [2-4] 24 } this indicates that any arbitrary sequence from 2 bytes to 3 bytes can occupy the sequence Result: { 81 12 3 24 }
  • 6. • Infinite: YARA is capable to detect infinite hex value in a strings Infinte_example={ FE 18 [2-] 89 45 } { FE 18 [ - ] 89 45 } Result: { FE 18 66 89 45 } • Conditional:You can create 1 to as many statements to provide different alternative for the hex fragment. Conditional_example={ F4 23 ( 62 B4 | 56 ) 45 } Result: { F4 23 62 B4 45 } { F4 23 62 56 45 }
  • 7. Lets add up every thing Rule rabbithole { Strings: $rule1= { F4 23 [-] (62 45 | 56) [20-40] } CONDITION: $rule1 }
  • 8. Text Strings Text strings: Text strings are in form of ASCII text which is then matched up with the condition set. This section also contain further types • Case Sensitive Strings Example= $case_example= “test” • Case Insensitive String Example=$nocase_example= “test” nocase • Wide character string: Example=$wide_example=“test” wide The wide modifiers can be used to search for strings encoded with 2 bytes per char
  • 9. • Fullword: This modifier guarantees that the string will match only if it appears in the file delimited by non-alphanumeric characters. Example: $shadow1= “zebra.com” fullword
  • 10. Condition and Meta Condition: The condition section is used to express what you want your rule to detect. This is done by writing an expressing using logical operator, the condition must include all the strings. It contains a Boolean expression that determine the result. It contains all the usual logical and relational operator. You can also include another rule as part of your condition Meta: Metadata can be added to help identify the files that were picked up by a certain rule. The metadata identifier are always followed by an equal sign and the set value. The assigned values can be strings integer or a Boolean value.
  • 11. Counting strings Counting strings: YARA rules can allow us to count how many times a string have occurred in the file or process memory. The number of occurrences of each string is represented by a variable whose name is same as the string identifier with a ‘#’ instead of $ character. • rule Count_Example { strings: $a = “remote" $b = “string2" condition: #a == 6 and #b > 10 }
  • 12. Virtual address String identifier is used to check if the given rule is associated to any string in the file or sample, we can also detect the string is present at certain address with in the address space. The at operator is used to check if the string is at some specific offset. • Example: rule Count_Example { strings: $a = “string1" $b = “string2" condition: #a at 50 and #b at 10 }
  • 13. Set of strings and file size We can check certain number of strings from rule are present from a given list we can use of operator. Filesize: The filesize is used to check the file size of a given file or sample. • Example Rule HTB { strings: $m1 = “nest” $m2 = “sniper" $m3 = “Book“ condition: 2 of ($m1,$m2,$m3) and filesize < 10000KB }
  • 14. Demo
  • 15. Reference: • https://0x00sec.org/t/tutorial-creating-yara-signatures-for-malware- detection/5453 • https://github.com/Neo23x0/signaturease/blob/master/yara/crime_wannacry.yar • https://www.vmray.com/analyses/wannacry-ransomware/report/yara.html • https://blog.claroty.com/leveraging-yara-rules-for-early-malware-detection
  • 16.