Question

For this assessment, you will create a simple Python port scanner using Python's built-in functions. You...

For this assessment, you will create a simple Python port scanner using Python's built-in functions. You can use Python's default editor IDLE (Integrated Development and Learning Environment) or a Python editor of your choice to complete this assessment.

  1. Write a simple port scanner program using the built-in Socket module. Test your port scanner by targeting https://www.hackthissite.org
  2. Test your code and document testing by taking screenshots.
  3. Explain the approach taken to complete this assessment and the major decisions made.

Here is the code someone sent me however I get an error in my shell console when running.

import socket

def port_scanner():
    # inclusive range 1 to 1024
    for port in range(1, 1024 + 1):
        socket_obj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        result = socket_obj.connect_ex(("localhost", port))
        # checking for open port
        if result is None:
            print("Port ", port, "open")

        socket_obj.close()

port_scanner()

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

import socket
import sys
# Ask for hostname
host = raw_input("Enter a remote host to scan: ")
host_IP = socket.gethostbyname(remoteServer)

print "Please wait, scanning host", remoteServerIP

# Scan all the ports from 1 t0 1024

try:
for port_no in range(1,1025):
s= socket.socket(socket.AF_INET, socket.SOCK_STREAM)
r = sock.connect_ex((remoteServerIP, port_no))
if r == 0:
print "Port {}:    Open".format(port_no)
s.close()

except socket.gaierror:
print 'Hostname can't be found.'
sys.exit()

except socket.error:
print "Couldn't connect to server"
sys.exit()

NOTE : When it asks for input,input the desired host address and it will show you the port numbers open in your system.Please run it on LINUX based system.

Add a comment
Know the answer?
Add Answer to:
For this assessment, you will create a simple Python port scanner using Python's built-in functions. You...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this assessment, you will continue to use the SQLite3 library to perform common database tasks...

    For this assessment, you will continue to use the SQLite3 library to perform common database tasks using Python. You can use Python's default editor IDLE (Integrated Development and Learning Environment) or a Python editor of your choice to complete this assessment. Note: SQLite is included as part of the Python installation. Your assessment will be scored on the following criteria: Create a SELECT statement that contains only FirstName, LastName, and EmailAddress from the contacts table Create an UPDATE statement that...

  • The instructions for my assignment are below; however I came across this code but when I...

    The instructions for my assignment are below; however I came across this code but when I try to run it, I get nothing but either bugging issues or error in the python shell. Write a simple port scanner program using the built-in Socket module. Test your port scanner by targeting your own computer or you can reference https://www.hackthissite.org Test your code and document testing by taking screenshots.

  • I need help with an assignment, it invovles techniques such as web scraping to retrieve data...

    I need help with an assignment, it invovles techniques such as web scraping to retrieve data from the Internet using both Python built-in functions as well as third-party libraries. You can use Python's default editor IDLE (Integrated Development and Learning Environment) or a Python editor of your choice to complete this assignment. I need to do the  following: Write a program to test if a given page is found or not on the server. Write a Python program to download and...

  • " In the workshop exercises you have used Python's Tkinter module to create simple Graphical User Interfaces. The following code is an incomplete Python program relying on Tkinter (with delib...

    " In the workshop exercises you have used Python's Tkinter module to create simple Graphical User Interfaces. The following code is an incomplete Python program relying on Tkinter (with deliberately unhelpful variable and function names) which you must complete by filling in the blanks. When complete the program should create a window with two buttons, labelled and!!', respectively. When the button la belled'???' is pushed nothing happens. When the button labelled'!!"is pushed both buttons' labels are set to'!!!' from tkinter...

  • In this lab you will write a simple chat application in Python using TCP sockets. The...

    In this lab you will write a simple chat application in Python using TCP sockets. The chat application consists of a chat server and a chat client. At any one time, the chat server is communicating with just one chat client. When the client and the server are done chatting, they exchange end messages which ends the session. The client and server read and write Unicode strings using the readUTF() and writeUTF() methods of DataInputStream and DataOutputStream respectively. After compilation,...

  • Create a simple Air Quality Assessment Tool using the technology of your choice ( java, python)...

    Create a simple Air Quality Assessment Tool using the technology of your choice ( java, python) that utilizes Open AQ Platform API. It will have the ability to compare the Air Quality of two cities. The tool must: Allow the user to input two cities Display the air quality of the corresponding cities, allowing the user to compare the two Gracefully handle any API or user errors Tool should be easily used by the general public

  • Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST b...

    Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function unless the purpose...

  • SMTP Your task is to develop a simple mail client that sends email to any recipient....

    SMTP Your task is to develop a simple mail client that sends email to any recipient. Your client will need to connect to a mail server, dialogue with the mail server using the SMTP protocol, and send an email message to the mail server. Python provides a module, called smtplib, which has built in methods to send mail using SMTP protocol. However, we will not be using this module in this lab, because it hide the details of SMTP and...

  • Using Python, if you could help me with the code # Create a modified version of...

    Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is the index of a word in the text that matches your given # search string. # e.g. if "hatter" occurs at positions 0, 6, 12 then return [ 0, 6, 12] def search_linear_occurrences(xs, target): """ Find and return a list of...

  • Simple python assignment Write a menu-driven program for Food Court. (You need to use functions!) Display...

    Simple python assignment Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses the end order option. (You can pass quantity1, quantity2, quantity3,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT