SlideShare a Scribd company logo
1 of 17
Download to read offline
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

Reconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessReconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessLeon Teale
 
VAPT PRESENTATION full.pptx
VAPT PRESENTATION full.pptxVAPT PRESENTATION full.pptx
VAPT PRESENTATION full.pptxDARSHANBHAVSAR14
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101Jannis Kirschner
 
WTF is Penetration Testing v.2
WTF is Penetration Testing v.2WTF is Penetration Testing v.2
WTF is Penetration Testing v.2Scott Sutherland
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applicationsNiyas Nazar
 
Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]David Sweigert
 
Vulnerability assessment and penetration testing
Vulnerability assessment and penetration testingVulnerability assessment and penetration testing
Vulnerability assessment and penetration testingAbu Sadat Mohammed Yasin
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Jay Nagar
 
Metasploit framework in Network Security
Metasploit framework in Network SecurityMetasploit framework in Network Security
Metasploit framework in Network SecurityAshok Reddy Medikonda
 
Vulnerability Assessment and Penetration Testing Report
Vulnerability Assessment and Penetration Testing Report Vulnerability Assessment and Penetration Testing Report
Vulnerability Assessment and Penetration Testing Report Rishabh Upadhyay
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and AwarenessAbdul Rahman Sherzad
 
Common malware and countermeasures
Common malware and countermeasuresCommon malware and countermeasures
Common malware and countermeasuresNoushin Ahson
 

What's hot (20)

Reconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awarenessReconnaissance - For pentesting and user awareness
Reconnaissance - For pentesting and user awareness
 
VAPT PRESENTATION full.pptx
VAPT PRESENTATION full.pptxVAPT PRESENTATION full.pptx
VAPT PRESENTATION full.pptx
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
Malware analysis
Malware analysisMalware analysis
Malware analysis
 
WTF is Penetration Testing v.2
WTF is Penetration Testing v.2WTF is Penetration Testing v.2
WTF is Penetration Testing v.2
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]Overview of the Cyber Kill Chain [TM]
Overview of the Cyber Kill Chain [TM]
 
Vulnerability assessment and penetration testing
Vulnerability assessment and penetration testingVulnerability assessment and penetration testing
Vulnerability assessment and penetration testing
 
Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )Website hacking and prevention (All Tools,Topics & Technique )
Website hacking and prevention (All Tools,Topics & Technique )
 
Metasploit framework in Network Security
Metasploit framework in Network SecurityMetasploit framework in Network Security
Metasploit framework in Network Security
 
Vulnerability Assessment and Penetration Testing Report
Vulnerability Assessment and Penetration Testing Report Vulnerability Assessment and Penetration Testing Report
Vulnerability Assessment and Penetration Testing Report
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and Awareness
 
Metaploit
MetaploitMetaploit
Metaploit
 
Common malware and countermeasures
Common malware and countermeasuresCommon malware and countermeasures
Common malware and countermeasures
 
Reconnaissance
ReconnaissanceReconnaissance
Reconnaissance
 
Windows Forensic 101
Windows Forensic 101Windows Forensic 101
Windows Forensic 101
 
THOR Apt Scanner
THOR Apt ScannerTHOR Apt Scanner
THOR Apt Scanner
 
Denial of service
Denial of serviceDenial of service
Denial of service
 
Ceh v5 module 07 sniffers
Ceh v5 module 07 sniffersCeh v5 module 07 sniffers
Ceh v5 module 07 sniffers
 
Sigma and YARA Rules
Sigma and YARA RulesSigma and YARA Rules
Sigma and YARA Rules
 

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.6Vijay Kumar
 
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 typesSasidharaRaoMarrapu
 
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.docxsmile790243
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince 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 REDDYRajeshkumar Reddy
 
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 ScannerEdward Nyang'ali
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingBadar Waseer
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdfGaneshRaghu4
 

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

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
 

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

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

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.