Phone: + 1 507 4052 660

Basic bash port scanner | Computer Science homework help

 In attached File is the starter code 

1 Overview

For this project you will be given a bash script that implements a basic TCP port scanner, which you will improve by adding several features. You will also submit a report documenting your code changes and describing how to use the script.

2 Motivation

This project concerns the scanning phase of penetration testing. A network port scanner is an essential tool for any penetration tester. Finding open ports on hosts is a key first step to finding vulnerabilities.

Though there are already exist full-featured port scanning tools, the ability to script such a tool could be very valuable to a penetration tester, who may wish to scan from an environment where no such tool installed and has no privileges to install one.

More importantly, writing such a tool for yourself in bash is a good way to build your scripting ability and gain an understanding of network and network programming.

3 Required code features

In class, we described the command-line usage of the bash port scanner script distributed with the project. You are to add the following features to the program. All the features described must work correctly, separately and in combination.

3.1 Command-line argument for timeout (25 points)

Modify your 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, ./ -t 3 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.

3.2 Interactive/batch mode (25 points)

Modify the script so that it also works interactively. Specifically, if no hostname is given on the command line, the program should interactively ask for a hostname, starting port, and ending port with three separate prompts, and carry out its scan using those values. After scanning finishes, the program should loop to receive another set of values, stopping only when the user enters a blank host name.

If this feature is implemented properly, it will also allow you to run the script in ’batch’ mode, by “piping in” a plain text file with the hostname on the first line, start port on the second, stop port on the third, and repeating for as many hosts as you wish to scan.

For example, if a file named hosts_to_scan.txt contains a list of hosts and ports in the proper format, the program should now work as follows:

cat hosts_to_scan.txt | ./

The timeout argument should still work in this case as well:

cat hosts_to_scan.txt | ./ -t 3

3.3 Argument number check (15 points)

After correctly implementing the above features, the result will be a script that can be run with either 0, 2, 3, or 5 command-line arguments. As a basic sanity check, Your program should test at the beginning that the number of arguments given is one of these. If not, the user has entered something incorrectly, and the script should output the error message

Usage: ./ [-t timeout] [host startport stopport],

and immediately exit.

4 Required documentation (25 points)

Along with your code, you will submit a plain-text documentation file describing the purpose and function of your program, and with detailed instructions for how to run your program in both interactive and command mode, documenting each of the command-line arguments. You also need to document the format of the input file that the program accepts in batch mode.

You are to write your documentation in the form of a Unix “man” page, with appropriate sections and headers. A template will be given with a suggested format for this. You can also look at some man pages on the Kali VM for inspiration.

If your program has known bugs or limitations, these must also be documented. Clearly documenting any bugs or issues you could not solve may help your grade. However, “I waited until the last minute and ran out of time” is not an acceptable justification.

5 What to turn in

Please submit your project to the Blackboard assignment page as a zip or tar archive containing the following three files:

  • The bash source file for your program, named Below the #!/bin/bash line, the file should have a comment line or lines including your name, the course number, and the submission date.
  • A sample input file hosts_to_scan.txt to run your program in batch mode, containing three different hosts and start/stop port settings.
  • The documentation file README.txt, as described above.

Please do not include any additional files or program versions in your submission.

6 Grading

Your submitted program will be tested for correctness on a Linux virtual machine running the same version of Kali that we installed in class. I will test for correct implementation of the above features by running your script with a variety of command-line and file inputs.

To receive full credit, your program must continue to perform port scanning properly, with the features implemented exactly as described above. Bugs will cause a loss of credit in proportion to how much they affect the running of the program.

Some sample command-lines that I will use to test your program include, but are not limited to, the following:

./ 40 90

./ -t 3 45 85


./ -t 1

cat hosts_to_scan.txt | ./

cat hosts_to_scan.txt | ./ -t 3

If you have any doubts about how the program should behave for any of these inputs, please ask.

As this project is a simple proof-of-concept script, your program is not required to check for every possible error condition or wrong input–only what is implied by the requirements above.

Your documentation will be graded on completeness, organization, and clarity of writing.

Unlock Better Papers
Pages (550 words)
Approximate price: -

Why Hire a Professional Essay Writer from essayprohire

The quality of an essay is important

If you want to be successful in the essay writing world, it’s important to make sure that the quality of your work is high. A professional essay writer from us will be able to provide you with high-quality papers, and they will also have the experience necessary to write effective essays. This means that you won’t have to worry about any errors or problems with your essays – they will be perfect.

Our Customer service is top-notch

If you have a problem with your essay, or if you just need a little help writing it, then you should contact our customer service. Our customer service is always available to help you with whatever you need – from getting your essay correct to helping you with the grammar and punctuation. We’re here to help, so don’t hesitate to call us today!

Our offer on Unlimited Revisions

If you're looking for essaywriting help, then you should definitely consider getting help from a essaywritinghelpnow. However, if you're not sure what you need or whether you have the time or resources to do the research yourself, then you might want to consider getting unlimited revisions done by our team of experts. O

Our guarantee to Confidentiality

We understand the importance of confidentiality, and we will never share your personal information with anyone without your permission. That’s why we offer a one-year guarantee that your essays will remain confidential. If you decide that you no longer want us to write your essays, we will still respect your privacy and will destroy all the evidence that we had of your work.

Our Reliability

We believe that it is important to have a reliable and trustworthy essaywriter. That’s why we offer a 100% satisfaction guarantee on all of our essays. We take the time to get to know our clients, and we will always make sure that our essays are of the highest quality. We understand that not everyone is happy with their first essay, so we want to make sure that you’re always satisfied with the results of our work.

Our punctuality and quality

At our company, we pride ourselves on our punctuality and quality. We understand that it can be difficult to get essays written on time, and we’re here to help you out! Our writers are always available to help you with your essay, and we guarantee that you’ll receive the best possible product. We also have a strict no-nonsense policy when it comes to plagiarism, so you can be sure that your essay will be of the highest quality.


Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.


Our Services

So much stress and so little time? Take care of yourself: let us help you with your tasks. We offer all kinds of writing services.


Custom Essay Writing Services

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.


Admission and Business Papers

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.


Editing and Proofreading

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.


Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.