Sponsor

Security Videos
« Tektip ep22 - Helge's Switchblade Portable Malware Analysis | Main | Tektip ep21 - Drive Traffic to your Honeypot »
Sunday
Feb102013

Regex Practice Quiz 1 - Understanding Patterns

I created a quick Regular Expressions (Regex) quiz to help students with a basic understanding of Regex begin to understand patterns that it can be applied to.  You can find the google doc version of this quiz here. If you are not familiar with Regex already you can view a tutorial here.

For those who prefer to see the questions directly on TekDefense, here they are:

1. Write a Regular Expression that will match a date that follows the following standard “YYYY-MM-DD”.

2. Write a Regular Expression that will match a traditional SSN.

3. Write a Regular Expression that will match an IPv4 address.

4. Write a Regular Expression that will match an email address.

5. Given the example text that follows, which of the Regular Expressions will match only the MD5 hashes. Circle all that apply.

785158d78c22517b8f16dcf55b36668f  ./bombed.prt.1
db9118916aa2fe73bf3b35eadc19b728  ./YHM Phantom.JPG
8aaf18163366f4e950b43868f630a360  ./Sound_Moderator_MK2.stl
91997d2b885ac0116e3e4188c5f5706f  ./AR-15.Flash.Suppressor.Helical_Flute.stp
df15f45f8fcc56c0a3b56e9e59f263de  ./45_ammo_box.STL
ba0b20b7ebbbfcfd7f822a4c13fa080e  ./223_Round.stl
21667be06c1274fc460f9999054977f9  ./Fit Tester.JPG
9f823495a72bf9dd57c46c1516a8ada7  ./Simple22 - FCGPins^gen2-1.STL
3a78812c085baedad73cdb0223a1b6ef  ./BARREL - 5in (.40 S+W)(SPRINGFIELD XD TACTICAL
8ce382837a30b8c72c29a0096e851b33  ./lts-take-on-the-yhm-phantom-flash-hider.zip
b3e24968e7c53e07fcc1294ce01025ae  ./Silencer.stl
6457743d2008849a2251d79350e60eef  ./Renderings/MAC 10 SMG 001.JPG
1086eff0e881ad35e672f1db83b490c7  ./Renderings/Glock-22 Suppressor.JPG
48ac39a820cea6e7c35deecaff6f945b  ./Renderings/Flash Hider.JPG
cc096e493a1551dd5a58df524163fded  ./Renderings/22LR.JPG
60135661c95ee2f9e50a4516b0781c66  ./Renderings/Magazine view 420120101-16245-1yqg4mg.jpg
b0e15afe4cfaf31ccedefdb570c15c52  ./Renderings/f-120111026-21312-1hx76q3.png

A. \w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w\w
B. \w{32}
C. [a-f0-9]{32}
D. [a-f0-9]+

6.  From your answer to question 5 which of the valid Regular Expressions for an MD5 hash is the most specific and reusable for finding MD5 hashes in the future.

** Warning Answers below this line **

--------------------------------------------

Answers: Keep in mind that as this is Regex, there are many right answers.  If you have something different than what I have below it may still be right.  The best way to check is to test it out. You can test with Notepad++ or take a different route such as RegExr.  The answer to the fourth question will not work with all email addresses.  There are much more complex expressions that will catch a greater sum of the email addresses.  This one is focused on the format of john@example.com.

1. \d{4}\-\d{2}\-\d{2}

2. \d{3}\-\d{2}\-\d{4}

3. \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}

4. .+\@\w+\.\w{2,3}

5. A,B, and C

6. C

Reader Comments (3)

Thank you! nice practice

July 15, 2014 | Unregistered CommenterNegin

Your answer for 5 is not correct, all 4 (ABCD) match the md5sum.

August 17, 2014 | Unregistered CommenterGregg Leventhal

Gregg,
While all 4 will math an MD5, the questions was for which match on "only the MD5 hashes". "[a-f0-9]+" will match on any letter and number combinations that are 1 character or more (pretty much everything in the sample).
-Ian

August 29, 2014 | Registered CommenterAdmin

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>