Advent Of Cyber 2022 | Day 17 | TryHackMe

Advent Of Cyber 2022 | Day 17 | TryHackMe

Hello beautiful People! Welcome to yet another blog with another task. We are already on day 17 and we have covered 16 tasks till now. So what are you waiting for? Let's add one more task to our list today. Without any further delay, let's move to today's task.

Filtering for Order Amidst Chaos

So this task is mainly focusing on filtration and regular expression. Well! I had a really bad experience with regular expression in my Formal theory class. You must have guessed I don't have much knowledge about regex(Regular expression) but still, I will try my best. Before this let's first understand what is regular expression. A regular expression is a sequence of characters that specifies a search pattern in text. Suppose you have a string file which has thousands of entries. In that case, you will use a regular expression to find the results of your input. Let's understand the syntax of regex.

[a-zA-Z]: It means you want to match any character from the English alphabet regardless of the case.

[a-z0-9]: It means you want to match any lowercase alphanumeric character.

. : Dot symbol means regex will match any character.

*: The asterisk or star operator is used if you don't care if the preceding token matches anything or not.

+: plus operator is used if you want to make sure that it matches at least once.

{min, max}: The curly braces operator specifies the number of characters you want to match.

^: Anchor Beginning: specifies that the consequent token is at the beginning of the string

$: Anchor Ending: specifies that the preceding token is at the end of the string

\: Escape: escapes the regex operator so it can be matched

[a-zA-Z0-9]+: To match a string that is alphanumeric and case insensitive. The plus operator means that we want to match a string, and we don't care how long it is, as long as it's composed of letters and numbers regardless of their case.

Now let's move to today's task.

Question1

First of all, open your attackbox and go to Desktop. After that change your directory to RegExPractice.

We are going to use strings file.

The syntax will be : egrep '^[a-zA-Z0-9]{6,12}$' strings

Let me explain this. ^ means that the token is at the start of the string. [a-zA-Z0-9] means it is alphanumeric regardless of case. {6,12} means minimum length 6 and maximum length is 12. $ means the ending of the string.

Got the result? There are 8 usernames.

Question2

The only readable word here is User35.

Question3

The syntax here will be : egrep '.+@.+\.com' strings.

Let's imagine a gmail account. For example . Dot means any character can come xyz or akatsuki , lalit anything. +@ means @ is necessary to come. Again dot means anything can come like gmail, yahoo or hotmail. +\.com means .com is necessary to come. Here \ is escape character. Use this syntax and see the results.

There are 11 emails.

Question4

Domain means gmail , hotmail tryhackme etc. So the domains here are gmail,amg,yahoo,fedfull,tryhackme,canary,hotmail,alfa. There are 8 unique domains.

Question5

See the results again. You can see an email . So the answer is amg.com.

Question6

Just like the previous question. Got the answer? Yes! it is fedfull.com

Question7

Check the hotmail.com. You can see it's hussain.volt.

Question8

Now we need to find the URL:

Use this syntax: egrep '^http(s)?.{3}(www)?.+\..+$' strings

It means at first http or https will come. ? means here or . After that .{3} means any three character which is ://. After that www will come but it is not necessary so we put ? here. After that .+ means anything can come and then will will force it to have .+ at last which means .com or anything.

There are 16 URLs here .

Question9

There are 7 https URLs.

Question10

They are recommending you to complete Linux Fundamentals module.

Congratulations !! we completed this task. New task will be added tomorrow. Till then you can follow me here for upcoming blogs on the advent of cyber 2022. In the end, you will get a certificate from tryhackme for completing this challenge.

Keep learning and keep spreading Knowledge.

Did you find this article valuable?

Support Tanya Goyal by becoming a sponsor. Any amount is appreciated!