Concept explainers
penetration
Modify your .sh program to accept an optional command-line argument -t, followed by a space and an additional numerical argument, which sets the timeout value for the echo command in the portcheck function. The argument must come before the hostname and start and stop ports. If the argument is not given, the timeout should remain at a default value of 2. If the argument is given, in addition to changing the timeout, the script should print out an informational message “Timeout changed to <value>”.
For example, ./portscanner.sh -t 3 www.yahoo.com 40 80 should change the default timeout for each write to /dev/tcp to 3 seconds.
Note: adding this feature will also require you to change the way you scan and save the command line arguments for hostnames. The number and place of command line arguments will now vary depending on whether the user uses the ’-t’ option or not. You will have to add program logic to account for this, so that everything works correctly in either case.
.sh program
#!/bin/bash
# bash port scanner
# get the host to scan from the command line
host=$1
startport=$2
stopport=$3
function pingcheck
{
# run a ping command and scrape its output to see if it succeeded
pingresult=$(ping -c 1 $host | grep bytes | wc -l)
if [ "$pingresult" -gt 1 ]
then
echo "$host is up"
else
echo "$host is down, quitting"
exit
fi
}
function portcheck
{
for ((counter=$startport; counter <= $stopport; counter++))
do
if timeout 2 bash -c "echo > /dev/tcp/$host/$counter"
then
echo "$counter is open"
else
echo "$counter is closed"
fi
done
}
pingcheck
portcheck
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images
- ??arrow_forwardDescription i What is timestamp? Note that we have only timestamps, which ALWAYS contain yyyy-mm-dd as a date, hh:mm:ss as a time, and +/-zzzz as a timezone. time 2017-10-14 00:11:20 +0000 date time zone 12345 + timeconverter.py 1 def convert_time(timestamp): #NOTE: COMPLETE THE CODE FROM HERE! 6 #DO NOT MODIFY THE CONTENT HERE: 7 def print_result(hour, minute): 8 9 print("The time is {}:{}".format(hour, minute)) 10 #DO NOT MODIFY THE CONTENT HERE: 11 timestamp_list = ['2017-10-14 00:11:20 +0000', 12 '2022-03-24 07:22:16 -0400' Topic: Timestamp Converter Write a program timeconverter.py that has two functions: 1) The function convert_time : for extracting the hour and minute from a timestamp and 2) The function print_result: for printing the results. Note that the two functions should be called under the loop. 1) The function convert_time should: 1. take the timestamp from the function call, 2. separate time from date and time zone, 3. split it into hour, minute and seconds, 4. extract…arrow_forwardThe Homework aims to implement an Android application for restaurants administrators and customers. Two main actors of the application are the Restaurant administrator and the Restaurant customer. The Restaurant customer should be able to: - Register to the application by creating an account/login/logout - Search for restaurants based on food specialty, nearest location, best ratings, etc. When a restaurant is selected among the result list, the restaurant description page is opened where the customer could browse photos, food menus, prices and customers' comments about the restaurants. - Add comment and rate the restaurant. The restaurant administrator should be able to : - Register to the application by creating an account/login/logout - Add/Edit/Delete the restaurant information/location/photos/food menus and information - Access the customers rates and reviewsarrow_forward
- What will be the contents of DX after the following instructions execute (STC sets theCarry flag)?mov dx,5stc ; set Carry flagmov ax,10hadc dx,axarrow_forwardYou can configure your shell by editing the file~/.bashrc for instance to change the value of$ PS1 and $PAth permenatrly true or falsearrow_forwardWhich Win32 function allows you to modify the color of the text output that follows?arrow_forward
- in linux what command Saves the current prompt string to a variable called first_prompt and then changes the current prompt to show only your username.arrow_forwardAfter executing the following code: LDI R16, 0xFF OUT DDRC, R16 LDI R16, 0x12 OUT PORTC, R16 SBI PORTC, 7 CBI PORTC, 1 What is the value of PORTC?arrow_forwardWhat will be the output from following command? map(160, 10, 550, 0, 1023); A) 284 384 C) 254 210arrow_forward
- 1. When working with characters in HLA, an individual character is a 32-bit value. a True b False 2. Unlike all of the other HLA commands, the MALLOC and FREE instructions are not always guaranteed to run. a True b False 3. Will the following code jump to the label myLabel? mov( iFive, AH );cmp( AH, iSixteen );jna myLabel; if iFive holds the value 5 and iSixteen holds the value 16? a. Yes b. No, because AH cannot hold signed values like 5 or 16 c. No, because jnb should have been used, not jna d. No, because jna is for unsigned valuesarrow_forwardWrite a shell script that prompts the user for a grade between 0 and 100. The shellscript should calculate the corresponding letter for this grade based on the followingcriteria:0–49 = F50–59 =D60–69 = C70–79= B80–100 = AEnsure that the shell script continues to prompt the user for grades until the userchooses to exit the shell script.arrow_forwardYou can use the character pipe(|) to use the output of a command as the input of another command True or Falsearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education