Bash Scripting Task Assignment Brief
Answered
Please read this brief in full and watch all the videos.
Complete the following tasks using Bash. The skeleton template, id-cyberops.sh, has been provided for you. Replace ‘id’ in the filename with YOUR student ID.
You must follow the formatting requested for input and output within your scripts. Failure to do this will mean your script will fail those elements.
Videos are also provided that show expected input and output for Tasks 1 and 2.
Ensure you place your code in the correct function, which have been provided for you in the script template provided. For example, Task 1 Question 1, place the code in task1_q1 function, etc. Please watch this video for further clarification.
Please ask all questions in the Assessment 1 discussion thread.
- Display to standard output the String: Hello everyone!(1 mark)
- Prompt the user to enter their name and display to standard output: Welcome, <name>, to my Cyber Operations assessment(2 marks)
- Prompt the user to enter two integers (you can assume the user will enter two valid integers) and multiply the inputs together. Display the result to standard output (2 marks)
- Prompt the user to enter a value between 1 and 100. If the value is less than 50, display to standard output Failedelse display to standard output Passed. You can assume the user will enter a value between 1 and 100. (2 marks)
- Prompt the user to enter a file name then create and save this file with the given name to the present working directory. If the file already exists, echo to standard output The file already exists. (3 marks)
- For a given directory, which is provided by the user via standard input, iterate and list only the files that have a file extension of .txt to standard output. You can assume the provided directory does not contain any sub-directories. (3 marks)
- Using grep, cutand sed write a script that uses the txt as input (provided) to display to standard output the server IP address, in this case, 192.168.1.1#53 but it must work for any IPv4 address with a port number. You will need to use the specified commands and answers that do not use the commands specified will score 0. (3 marks)
- Write a script that uses the txtfile as input (provided) to display to the user a prompt to whether they wish to save a URL within a file. If the user wishes to save a URL by entering ‘y’, it is appended to a file called saved_domains.txt otherwise the user enters ‘n’ and the next URL is shown. (6 marks)
- Using the provided txtfile, parse and save only the unique loopback IPs to a file called loopback_ips.txt in ascending numerical order (loopback addresses start with 127). Additionally, parse and save all unique IP addresses in the range of 162.*.*.* and 175.*.*.* to a file called suspect_ips.txt sorted in ascending numerical order. (8 marks)
No video is needed for this task as all outputs are text files and no direct user input is required. Example output files for this task are available below.
Write a script that scrapes all the e-mail addresses and telephone numbers from the htmlfile provided. Place all unique e-mail addresses in a file called emails.txt which is then sorted in alphabetical order (A-Z). Place all unique telephone numbers in a file called numbers.txt which is then sorted in ascending numerical order. (10 marks)