Skip to content

THM - Advent of Cyber 2022 - Day 17


Difficulty: ⭐⭐
Challenge Link
OS: Linux

Learning Objectives

  • There needs to be more than understanding input validation.
  • Learn the basics of HTML5 and Regex
  • Implement HTML5 and regex to improvise the security of the web application

Filtering for Usernames: How many usernames fit the syntax above?

The fun of regex. You can just try an online RegEx filter to get an idea. But, lets just use egrep and build on it. Format the right Regex then using wc -l to count the amount of matches.

egrep '^[a-zA-Z0-9]{6,12}$' strings
egrep '^[a-zA-Z0-9]{6,12}$' strings | wc -l

Answer

8

Filtering for Usernames: One username consists of a readable word concatenated with a number. What is it?

Not sure if they wanted us to create another filter but, looking at the above regex we can see one of the usernames that matches this.

Answer

User35

Filtering for Emails: How many emails fit the syntax above?

Keep practicing the RegEx. We can use the below to combine filters to match something like an email.

egrep '.+@.+\.com' strings
egrep '.+@.+\.com' strings | wc -l

Answer

11

Filtering for Emails: How many unique domains are there?

Being theres so few we can just visually count this one.

Answer

8

Filtering for Emails: What is the domain of the email with the local-part "lewisham44"?

We can just look in the list above OR use grep to pull out that specific one that matches the user's email front.

Answer

amg.com

Filtering for Emails: What is the domain of the email with the local-part "maxximax"?

Same method as above.

Answer

fedfull.com

Filtering for Emails: What is the local-part of the email with the domain name "hotmail.com"?

Same method as above.

Answer

hussain.volt

Filtering for URLs: How many URLs fit the syntax provided?

We can use the below syntax to match that and count.

egrep '^http(s)?.{3}(www)?.+\..+$' strings
egrep '^http(s)?.{3}(www)?.+\..+$' strings | wc -l

Answer

16

Filtering for URLs: How many of these URLs start with "https"?

Similar to above but, slightly different.

egrep '^https.{3}(www)?.+\..+$' strings
egrep '^https.{3}(www)?.+\..+$' strings | wc -l

Answer

7