If you can see this check that

Main Page


GREP and Regular Expressions

User:
Password:

Objectives

In this session you will be covering the basics file content searching and regular expressions.

To reset all the check buttons from a previous attempt click here

Question 1: GREP and regexp

Using a combination of grep, regular expressions, and wc via a pipe count how many words in the /usr/share/dict/words dictionary starts with "anti" and ends with an "n".
Number of words:

Tests - not attempted
Word count UNTESTED

Using grep and regular expressions, create a file /home/caine/aword which contains all the words which start with "tele" from /usr/share/dict/words, and which are exactly 7 characters long.

Tests - not attempted
/home/caine/aword exists UNTESTED
Words correct UNTESTED

How many words have the string "ra" in them twice in /usr/share/dict/words?
Number of words:

Tests - not attempted
Word count UNTESTED

How many words are in /usr/share/dict/words which contains "ice" then an "s" or a "d" (i.e. ices or iced). Use square brackets to form a set in your regular expression.
Number of words:

Tests - not attempted
Word count UNTESTED

Use grep on words to find a word that contains each of the vowels in alphabetical (i.e first an A, then an E, etc) order in /usr/share/dict/words. How many such words are there? (you may include words with extra vowels such as adventitious. A vowel is one of A,E,I,O,U.
Number of words:

Tests - not attempted
all vowels in order UNTESTED

The word interlinking includes the same two characters (e.g. "in") which appear three times. The word "priestessess" also contains the same two characters repeated three time (e.g. "es").

How many words can you find which contain any two characters repeated three times, like the examples "interlinking" and "priestessess". Use /usr/share/dict/words as your list of possible words and grep to find the answer.
Number of words:

Note. Do a case sensitive match, so do not use "-i".

Tests - not attempted
Two character string appears 3 times (takes a few seconds) UNTESTED

Challenge Question: This is a tricky question. Just give it 10 minutes before moving onto the next question!

How many words are 5 character palindromes? A palindrome is a word spelled the same way forward and backwards, such as "sagas". Use /usr/share/dict/words. Hint: Use multiple groups and backreferences.
Number of words:

Tests - not attempted
Number of 5 character palindromes UNTESTED

Using the command below piped with grep ('|') answer the following questions:

icat -o 300255 /images/DoublePartitionRegLinux.dd 94 | grep ...


How many POST request are made to the server?

What page was requested at 13:58?

How many requests have the letters 'rbs' in the requested page?

CHALLENGE - Write a regex that will extact ANY ip address (you can google the answer if you are struggling!). Count how many VALID Ip addresses there are...

Tests - not attempted
Question 1 UNTESTED
Question 2 INCLUDE ENTIRE FILE NAME UNTESTED
Question 3 UNTESTED
Question 4 UNTESTED

Use the following commands to analyse a file used by the suspect to store credit card details:

icat -o 300255 /images/DoublePartitionRegLinux.dd 113 | grep ... 

Post the entire card number where the card ends in the numbers '8162':

Post the entire card number where the middle number of the CVV is 4 (Consider 'w' option ... CVV Format: 111):

Tests - not attempted
Question 1 UNTESTED
Question 2 UNTESTED

Use the following command to analyse the list of target countries the suspect has on their machine

icat -o 300255 /images/DoublePartitionRegLinux.dd 114 | grep ... 

How many countries have the word united in them?

How many countries END with 'ia'?

How many countries are five characters long?

Tests - not attempted
Question 1 UNTESTED
Question 2 UNTESTED
Question 3 UNTESTED


Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
Caine 13.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2024 Edinburgh Napier University