SlideShare a Scribd company logo
Regular Expressions (Regex) Overview
September 24, 2017
Matt Scheurer
@c3rkah
Slides:
https://www.slideshare.net/cerkah
((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4]
[0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-
9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))
About Me
Matt Scheurer
Systems Security Engineer
Working in the Financial Services Industry
Chair for the CiNPA Security SIG
Speaker at DerbyCon 5.0, DerbyCon 7.0, and
the 10th
Annual NKU Cyber Security Symposium
Certifications: CompTIA Security+, MCP, MCPS, MCTS, MCSA,
and MCITP
What Regular Expressions are Not!
● The term “Regular Expressions” or often
simply called “Regex” for short should not be
confused with “Old Sayings”
– Adages, Allegories, Aphorisms, Axioms, Clichés,
Epigrams, Idioms, Hyperboles, Maxims, Platitudes,
Proverbs, Truisms, etc.
When it comes to “Old Sayings”...
You would be hard
pressed to beat the
recollection and
retelling of old
sayings than my own
mother...
What is Regex?
Regex is a common syntax used to match
patterns when parsing text data or output. Regex
capture groups are used to extract strings of
specific data into reference points for retrieval or
processing.
Why learn Regex?
● Regex is a great skill set to have in the back pocket of
nearly any interdisciplinary role across the Information
Technology landscape
● Uses include:
– Application and Software Development
– Database queries
– Linux Administration and power user commands such as
grep, awk, sed, find, etc.
– Searching through any type of text data or system logs
Regex uses in InfoSec
● Content filtering
● Input validation
● NGFW / UTM Layer 7 definitions
● Parsing large volumes of data or system logs to pick out specific
data points of interest
● SIEM systems
– Building or refining entire searches, or performing advanced parsing to
narrow down extraneous information
– Finding specific log events or log event items and sub-data
● Understand the underpinnings of many security products and
utilities
Regex Variations and Variances
Different flavors of Regex
● While all versions of Regex share common
conventions there are proprietary differences
across the various Regex engines
● Popular Regex Engines include:
– Perl, PCRE, PHP, .NET, Java, JavaScript,
XRegExp, VBScript, Python, Ruby, Delphi, R, Tcl,
POSIX, and others
Regex Resources
● Online Learning Site - https://regexone.com/
● Regex Test Site - http://regexr.com/
● Tutorial Site - http://www.rexegg.com/
● Countless Additional Resources -
https://www.google.com/search?q=regex
● Further Reading -
https://en.wikipedia.org/wiki/Regular_expression
Let’s Begin...
Regex Basics – Simple Matching
● Simply type in exactly what you are trying to
match
● Text string pattern matching is case-sensitive!
– NOTE: certain non-alpha-numeric characters may
require an escape prefix to match
●
Regex Basics – Text Matching
● In addition to typing in an exact text string for
an exact match “w” will match a single
alphanumeric character
– Matches any word character (alphanumeric &
underscore)
– Only matches low-ascii characters (no accented or
non-roman characters)
Regex Basics – Number Matching
● In addition to typing in an exact numeric string
for an exact match “d” will match a single digit.
– Matches any digit character (0-9)
Regex Basics – Matching a Space
● In addition to typing in an exact string with a
space included for an exact match “s” will
match a space in text
– Matches any whitespace character (spaces, tabs,
line breaks)
Regex Basics – Matching Opposites
● We just looked at a few character classes
– All character classes are case-sensitive
– Specifying those character classes in upper-case changes
the pattern match to match the opposite
● “W”, “D”, and “S” respectively translate to
– Not a word character
– Not a digit
– Not whitespace
Regex Basics – Quantifiers
● “.” matches any single character
● “+” suffix matches one or more repetitions
● “*” suffix matches zero or more repetitions
● “?” suffix means the character is optional
● “|” is an ‘or’ separator between characters
● “^” is a ‘not’ specifier to exclude a character
– Enclosed in square brackets prefixing the pattern
– [^<pattern>]
Regex Basics – Escaped Characters
● What if I want to match escaped characters such as a
“., +, *, ?, |, ^, etc.” in my pattern against the data?
– Prefix reserved escape characters with a “”
● What if I want to match a “” in my pattern
against the data?
–
Regex Basics – Ranges
● In addition to quantifiers (wild cards), ranges may be
specified with pattern matching
– Characters are enclosed inside of square brackets
“[“ “]” and separated by a hyphen “-”
● Examples:
– [a-z], [A-Z], and [0-9]
Regex Basics – Repetitions
● In addition to a range quantifier, repetitions may be
specified with pattern matching
– The number of character occurrences are specified
inside of curly brackets/braces “{“ “}”, or separated
by a comma “,” for a range of occurrences
● A{4} matches exactly “AAAA”
● A{1,4} matches “A”, “AA”, “AAA”, or “AAAA”
● A{4,} matches four or more consecutive “A’s”
Regex Basics – Line Matching
● The beginning of a line and/or end of a line may be
specified in Regex pattern matching
– “^”, matches the beginning (starts with) of a line
– “$”, matches the end of a line
– “^<pattern>$”, matches when the line begins with
and ends with the specified pattern
Regex Capture Groups
● The true power of Regex is fully realized with
defined capture groups
● These essentially define array like variables to
pattern matched data
– This is how we return the precise data we want,
while ignoring the content we do not care about
● Capture groups are defined by patterns
enclosed inside of parenthesis “(“ “)”
Regex Sub-Capture Groups
● Regex sub-capture groups can be defined by
using nested parenthesis “(“ “)”
– Example:
● “(Pattern (match))”
– First Capture Group = Pattern match
– Second Capture Group = match
Regex Pattern Matching Problems?
Really Stuck? Just Remember...
Regex Example 1
● Threat Feed: malware-domains
– Latest Blackhole-DNS File list
– "BOOT" format
– http://malware-domains.com/files/BOOT.zip
● Objective: Capture a list of FQDN’s
Example 1 – Expression
One Solution:
PRIMARYs(S+)
Regex Example 2
● Threat Feed: malware-domains
– Complete Zone File (bind)
– Spyware Domains
– http://malware-domains.com/files/spywaredomains.zones.zip
● Objective: Capture a list of FQDN’s
Example 2 – Expression
One Solution:
zones"(S+)"
Regex Example 3
● Threat Feed: DNS BlackHole
– IP Blacklist
– http://malc0de.com/bl/IP_Blacklist.txt
● Objective: Capture a list of IP addresses
Example 3 – Expression
One Solution:
(d{1,3}.d{1,3}.d{1,3}.d{1,3})
Regex Example 4
● Threat Feed: SpamCop
– Spam in progress
– Source of Mail
– wget https://www.spamcop.net/w3m?action=inprogress
● Objective: Capture a list of IP addresses
Example 4 – Expression
One Solution:
>(d{1,3}.d{1,3}.d{1,3}.d{1,3})<
Regex Example 5
● Threat Feed: Malware Domain List
– Complete database in CSV format
– http://www.malwaredomainlist.com/mdlcsv.php
● export.csv
● Objective: Capture a list of FQDN’s
Example 5 – Expression
One Solution:
"d{4}/d{2}/d{2}_d{2}:d{2}","(w[.|-|w]+)
Keeping the Regex Saw Sharpened
Upcoming Speaking Engagements
Tuesday 11/14, (ISC)2 Cincinnati Chapter Meeting
Downtown Cincinnati, 11:30 AM – 12:30 PM
“Phishing Forensics – Is it just suspicious, or is it
malicious?”
Wednesday 12/06, CiNPA Hackers Night
Cincinnati State (Evendale Campus), 7:00 PM – 9:00 PM
“Active Defense”
Questions?
The End
Big Thank You and shout
out to my dear sweet
mother! She’s a very
special person in my life,
and a fantastic
Grandmother!
...Plus she endured the
unenviable task of raising me as
a child and teenager. :)
Pictured above: My mom with my son
Love you mom!

More Related Content

ODP
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
PPTX
hands on: Text Mining With R
PDF
Search Engine-Building with Lucene and Solr, Part 1 (SoCal Code Camp LA 2013)
PDF
Text Mining with R
PDF
Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)
PPTX
Java Performance Tips (So Code Camp San Diego 2014)
PPTX
TextMining with R
PDF
Windows Server 2016 Webinar
DerbyCon 7.0 Legacy: Regular Expressions (Regex) Overview
hands on: Text Mining With R
Search Engine-Building with Lucene and Solr, Part 1 (SoCal Code Camp LA 2013)
Text Mining with R
Search Engine-Building with Lucene and Solr, Part 2 (SoCal Code Camp LA 2013)
Java Performance Tips (So Code Camp San Diego 2014)
TextMining with R
Windows Server 2016 Webinar

Viewers also liked (20)

PDF
Role of DNS in Botnet Command and Control
PDF
Scripting and automation with the Men & Mice Suite
PDF
Symantec (ISTR) Internet Security Threat Report Volume 22
ODP
(ISC)2 Cincinnati Tri-State Chapter: Phishing Forensics - Is it just suspicio...
PDF
DNS High-Availability Tools - Open-Source Load Balancing Solutions
PPTX
Cyber Security # Lec 2
PPTX
Tcp udp
PDF
Social Networks And Phishing
PPTX
Cyber crime &amp; security
PDF
Cisco Connect Toronto 2017 - Anatomy-of-attack
PDF
Comodo Multi Domain SSL Certificate: Key Features by CheapSSLsecurity
PDF
Cisco Connect Toronto 2017 - Accelerating Incident Response in Organizations...
PPTX
Phishing Scams: 8 Helpful Tips to Keep You Safe
PPTX
Microsoft Cyber Security IT-Camp
PDF
Dns Hardening Linux Os
PDF
How to send DNS over anything encrypted
PDF
Umbrella Webcast: Redefining Security for the Nomadic Worker
PDF
Cisco umbrella overview
PDF
Cisco Connect Toronto 2017 - NFV/SDN Platform for Orchestrating Cloud and vBr...
PDF
Namespaces for Local Networks
Role of DNS in Botnet Command and Control
Scripting and automation with the Men & Mice Suite
Symantec (ISTR) Internet Security Threat Report Volume 22
(ISC)2 Cincinnati Tri-State Chapter: Phishing Forensics - Is it just suspicio...
DNS High-Availability Tools - Open-Source Load Balancing Solutions
Cyber Security # Lec 2
Tcp udp
Social Networks And Phishing
Cyber crime &amp; security
Cisco Connect Toronto 2017 - Anatomy-of-attack
Comodo Multi Domain SSL Certificate: Key Features by CheapSSLsecurity
Cisco Connect Toronto 2017 - Accelerating Incident Response in Organizations...
Phishing Scams: 8 Helpful Tips to Keep You Safe
Microsoft Cyber Security IT-Camp
Dns Hardening Linux Os
How to send DNS over anything encrypted
Umbrella Webcast: Redefining Security for the Nomadic Worker
Cisco umbrella overview
Cisco Connect Toronto 2017 - NFV/SDN Platform for Orchestrating Cloud and vBr...
Namespaces for Local Networks

Similar to OISF: Regular Expressions (Regex) Overview (20)

ODP
CiNPA Security SIG - Regex Presentation
PDF
Python Programming - XI. String Manipulation and Regular Expressions
PDF
ANOTHER BRICK OFF THE WALL: DECONSTRUCTING WEB APPLICATION FIREWALLS USING AU...
PDF
Regular expression for everyone
PPTX
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
PPT
Extracting data from text documents using the regex
PDF
Introduction to Elasticsearch
PDF
Don't Fear the Regex LSP15
PDF
Basics of R programming for analytics [Autosaved] (1).pdf
PDF
VMworld 2013: Deep Dive into vSphere Log Management with vCenter Log Insight
PDF
How to check valid Email? Find using regex.
PDF
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
PPTX
Introduction to R for Learning Analytics Researchers
PPT
Introduction To PHP
PPTX
MongoDB 3.0
PDF
How to check valid Email? Find using regex.
PPT
SMS Spam Filter Design Using R: A Machine Learning Approach
PDF
Node.js security - JS Day Italy 2018
PPTX
Regular expressions and php
PPTX
Regular expressions
CiNPA Security SIG - Regex Presentation
Python Programming - XI. String Manipulation and Regular Expressions
ANOTHER BRICK OFF THE WALL: DECONSTRUCTING WEB APPLICATION FIREWALLS USING AU...
Regular expression for everyone
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Extracting data from text documents using the regex
Introduction to Elasticsearch
Don't Fear the Regex LSP15
Basics of R programming for analytics [Autosaved] (1).pdf
VMworld 2013: Deep Dive into vSphere Log Management with vCenter Log Insight
How to check valid Email? Find using regex.
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Introduction to R for Learning Analytics Researchers
Introduction To PHP
MongoDB 3.0
How to check valid Email? Find using regex.
SMS Spam Filter Design Using R: A Machine Learning Approach
Node.js security - JS Day Italy 2018
Regular expressions and php
Regular expressions

More from ThreatReel Podcast (20)

PDF
CONHESI 2021 - Exploiting Web APIs
PDF
SecureWV: Exploiting Web APIs
PDF
BSides Columbus - Lend me your IR's!
PDF
PwnSchool: Exploiting Web APIs
PDF
CiNPA Security SIG - Exploiting the Tiredful API
PDF
CCC - Lend me your IR's
PDF
DMA - Stupid Cyber Criminal Tricks
PDF
ISC2: AppSec & OWASP Primer
PDF
OISF - Continuous Skills Improvement for Everyone
PDF
Central Ohio InfoSec Summit: Why Script Kiddies Succeed
PDF
AppSec & OWASP Top 10 Primer
PDF
OISC 2019 - The OWASP Top 10 & AppSec Primer
ODP
Butler Tech - Working in IT and InfoSec
ODP
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
ODP
CiNPA Security SIG - Physical Security
ODP
CiNPA / CiNPA Security SIG History
ODP
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
ODP
BSides Cleveland: Phishing Forensics - Is it just suspicious or is it malicious?
ODP
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
ODP
Circle City Con: Phishing Forensics - Is it just suspicious or is it malicious?
CONHESI 2021 - Exploiting Web APIs
SecureWV: Exploiting Web APIs
BSides Columbus - Lend me your IR's!
PwnSchool: Exploiting Web APIs
CiNPA Security SIG - Exploiting the Tiredful API
CCC - Lend me your IR's
DMA - Stupid Cyber Criminal Tricks
ISC2: AppSec & OWASP Primer
OISF - Continuous Skills Improvement for Everyone
Central Ohio InfoSec Summit: Why Script Kiddies Succeed
AppSec & OWASP Top 10 Primer
OISC 2019 - The OWASP Top 10 & AppSec Primer
Butler Tech - Working in IT and InfoSec
NKU Cybersecurity Symposium: Active Defense - Helping threat actors hack them...
CiNPA Security SIG - Physical Security
CiNPA / CiNPA Security SIG History
OISF Aniversary: Active Defense - Helping threat actors hack themselves!
BSides Cleveland: Phishing Forensics - Is it just suspicious or is it malicious?
BSides Cleveland: Active Defense - Helping threat actors hack themselves!
Circle City Con: Phishing Forensics - Is it just suspicious or is it malicious?

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Electronic commerce courselecture one. Pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
20250228 LYD VKU AI Blended-Learning.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Electronic commerce courselecture one. Pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Programs and apps: productivity, graphics, security and other tools
Spectroscopy.pptx food analysis technology

OISF: Regular Expressions (Regex) Overview

  • 1. Regular Expressions (Regex) Overview September 24, 2017 Matt Scheurer @c3rkah Slides: https://www.slideshare.net/cerkah ((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4] [0-9]|1[0-9][0-9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0- 9]|[1-9]?[0-9]).(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))
  • 2. About Me Matt Scheurer Systems Security Engineer Working in the Financial Services Industry Chair for the CiNPA Security SIG Speaker at DerbyCon 5.0, DerbyCon 7.0, and the 10th Annual NKU Cyber Security Symposium Certifications: CompTIA Security+, MCP, MCPS, MCTS, MCSA, and MCITP
  • 3. What Regular Expressions are Not! ● The term “Regular Expressions” or often simply called “Regex” for short should not be confused with “Old Sayings” – Adages, Allegories, Aphorisms, Axioms, Clichés, Epigrams, Idioms, Hyperboles, Maxims, Platitudes, Proverbs, Truisms, etc.
  • 4. When it comes to “Old Sayings”... You would be hard pressed to beat the recollection and retelling of old sayings than my own mother...
  • 5. What is Regex? Regex is a common syntax used to match patterns when parsing text data or output. Regex capture groups are used to extract strings of specific data into reference points for retrieval or processing.
  • 6. Why learn Regex? ● Regex is a great skill set to have in the back pocket of nearly any interdisciplinary role across the Information Technology landscape ● Uses include: – Application and Software Development – Database queries – Linux Administration and power user commands such as grep, awk, sed, find, etc. – Searching through any type of text data or system logs
  • 7. Regex uses in InfoSec ● Content filtering ● Input validation ● NGFW / UTM Layer 7 definitions ● Parsing large volumes of data or system logs to pick out specific data points of interest ● SIEM systems – Building or refining entire searches, or performing advanced parsing to narrow down extraneous information – Finding specific log events or log event items and sub-data ● Understand the underpinnings of many security products and utilities
  • 9. Different flavors of Regex ● While all versions of Regex share common conventions there are proprietary differences across the various Regex engines ● Popular Regex Engines include: – Perl, PCRE, PHP, .NET, Java, JavaScript, XRegExp, VBScript, Python, Ruby, Delphi, R, Tcl, POSIX, and others
  • 10. Regex Resources ● Online Learning Site - https://regexone.com/ ● Regex Test Site - http://regexr.com/ ● Tutorial Site - http://www.rexegg.com/ ● Countless Additional Resources - https://www.google.com/search?q=regex ● Further Reading - https://en.wikipedia.org/wiki/Regular_expression
  • 12. Regex Basics – Simple Matching ● Simply type in exactly what you are trying to match ● Text string pattern matching is case-sensitive! – NOTE: certain non-alpha-numeric characters may require an escape prefix to match ●
  • 13. Regex Basics – Text Matching ● In addition to typing in an exact text string for an exact match “w” will match a single alphanumeric character – Matches any word character (alphanumeric & underscore) – Only matches low-ascii characters (no accented or non-roman characters)
  • 14. Regex Basics – Number Matching ● In addition to typing in an exact numeric string for an exact match “d” will match a single digit. – Matches any digit character (0-9)
  • 15. Regex Basics – Matching a Space ● In addition to typing in an exact string with a space included for an exact match “s” will match a space in text – Matches any whitespace character (spaces, tabs, line breaks)
  • 16. Regex Basics – Matching Opposites ● We just looked at a few character classes – All character classes are case-sensitive – Specifying those character classes in upper-case changes the pattern match to match the opposite ● “W”, “D”, and “S” respectively translate to – Not a word character – Not a digit – Not whitespace
  • 17. Regex Basics – Quantifiers ● “.” matches any single character ● “+” suffix matches one or more repetitions ● “*” suffix matches zero or more repetitions ● “?” suffix means the character is optional ● “|” is an ‘or’ separator between characters ● “^” is a ‘not’ specifier to exclude a character – Enclosed in square brackets prefixing the pattern – [^<pattern>]
  • 18. Regex Basics – Escaped Characters ● What if I want to match escaped characters such as a “., +, *, ?, |, ^, etc.” in my pattern against the data? – Prefix reserved escape characters with a “” ● What if I want to match a “” in my pattern against the data? –
  • 19. Regex Basics – Ranges ● In addition to quantifiers (wild cards), ranges may be specified with pattern matching – Characters are enclosed inside of square brackets “[“ “]” and separated by a hyphen “-” ● Examples: – [a-z], [A-Z], and [0-9]
  • 20. Regex Basics – Repetitions ● In addition to a range quantifier, repetitions may be specified with pattern matching – The number of character occurrences are specified inside of curly brackets/braces “{“ “}”, or separated by a comma “,” for a range of occurrences ● A{4} matches exactly “AAAA” ● A{1,4} matches “A”, “AA”, “AAA”, or “AAAA” ● A{4,} matches four or more consecutive “A’s”
  • 21. Regex Basics – Line Matching ● The beginning of a line and/or end of a line may be specified in Regex pattern matching – “^”, matches the beginning (starts with) of a line – “$”, matches the end of a line – “^<pattern>$”, matches when the line begins with and ends with the specified pattern
  • 22. Regex Capture Groups ● The true power of Regex is fully realized with defined capture groups ● These essentially define array like variables to pattern matched data – This is how we return the precise data we want, while ignoring the content we do not care about ● Capture groups are defined by patterns enclosed inside of parenthesis “(“ “)”
  • 23. Regex Sub-Capture Groups ● Regex sub-capture groups can be defined by using nested parenthesis “(“ “)” – Example: ● “(Pattern (match))” – First Capture Group = Pattern match – Second Capture Group = match
  • 25. Really Stuck? Just Remember...
  • 26. Regex Example 1 ● Threat Feed: malware-domains – Latest Blackhole-DNS File list – "BOOT" format – http://malware-domains.com/files/BOOT.zip ● Objective: Capture a list of FQDN’s
  • 27. Example 1 – Expression One Solution: PRIMARYs(S+)
  • 28. Regex Example 2 ● Threat Feed: malware-domains – Complete Zone File (bind) – Spyware Domains – http://malware-domains.com/files/spywaredomains.zones.zip ● Objective: Capture a list of FQDN’s
  • 29. Example 2 – Expression One Solution: zones"(S+)"
  • 30. Regex Example 3 ● Threat Feed: DNS BlackHole – IP Blacklist – http://malc0de.com/bl/IP_Blacklist.txt ● Objective: Capture a list of IP addresses
  • 31. Example 3 – Expression One Solution: (d{1,3}.d{1,3}.d{1,3}.d{1,3})
  • 32. Regex Example 4 ● Threat Feed: SpamCop – Spam in progress – Source of Mail – wget https://www.spamcop.net/w3m?action=inprogress ● Objective: Capture a list of IP addresses
  • 33. Example 4 – Expression One Solution: >(d{1,3}.d{1,3}.d{1,3}.d{1,3})<
  • 34. Regex Example 5 ● Threat Feed: Malware Domain List – Complete database in CSV format – http://www.malwaredomainlist.com/mdlcsv.php ● export.csv ● Objective: Capture a list of FQDN’s
  • 35. Example 5 – Expression One Solution: "d{4}/d{2}/d{2}_d{2}:d{2}","(w[.|-|w]+)
  • 36. Keeping the Regex Saw Sharpened
  • 37. Upcoming Speaking Engagements Tuesday 11/14, (ISC)2 Cincinnati Chapter Meeting Downtown Cincinnati, 11:30 AM – 12:30 PM “Phishing Forensics – Is it just suspicious, or is it malicious?” Wednesday 12/06, CiNPA Hackers Night Cincinnati State (Evendale Campus), 7:00 PM – 9:00 PM “Active Defense”
  • 39. The End Big Thank You and shout out to my dear sweet mother! She’s a very special person in my life, and a fantastic Grandmother! ...Plus she endured the unenviable task of raising me as a child and teenager. :) Pictured above: My mom with my son Love you mom!