Do: Extend your servicecheck function to receive a list of port/protocol (separated b check whether any open port is clo

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Do: Extend your servicecheck function to receive a list of port/protocol (separated b check whether any open port is clo

Post by answerhappygod »

Do Extend Your Servicecheck Function To Receive A List Of Port Protocol Separated B Check Whether Any Open Port Is Clo 1
Do Extend Your Servicecheck Function To Receive A List Of Port Protocol Separated B Check Whether Any Open Port Is Clo 1 (92.16 KiB) Viewed 32 times
Do: Extend your servicecheck function to receive a list of port/protocol (separated b check whether any open port is closed: servicecheck() { IFS=';' read -r -a arrayports <<< $2 # echo "${arrayports[1]}" nmaplog=`nmap $1` for port in "${arrayports[@]}" do echo $port nmapport=`echo $nmaplog | grep $port` if [ ! "$nmapport" ]; then echo`date`: port $port is expected to be open, but its closed >> $logfile fi done } Do: Extend your code in the following way: You receive a file as input that includes in each line the following: IP address, MAC address, ports
Example 192.168.10.133, 00:0c:29:bc:e8:3b, 135/tcp;139/tcp;445/tcp Building on the above code, your bash script will do the following For every line in input file, it first pings the IP, then checks to make sure that MAC address is valid, and then checks to make sure that ONLY the mentioned ports are open. This means to check that a port that should be open is not closed, and also any port that is not on the list is closed. It will report any other open port in the log file, in addition to the reports mentioned above. As always, your code must be commented out carefully. Respond: Make sure your code runs correctly. Try it with a bunch of inputs. Copy/paste your code in the following textbox. Also, copy/paste your test input file after that. Hint: To read from a file line by line, use the following code: input="/path/to/txt/file" while IFS= read -r line do echo "$line" done "$input"
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply