Question

Write a script for windows command line which will scan the ports for protocols: FTP, SSH,...

Write a script for windows command line which will scan the ports for protocols: FTP, SSH, SMTP, HTTP, for the first 10 hosts in the network 192.168.1.0/24

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

Solution:

#Select port range
$portrange = 20,21,22,25,80

foreach ($r in $range) {

$ip="{0}.{1}" -F $net,$r
write-host $ip

#Open connection for each port from the range
Foreach ($p in $portrange) {

$Socket = New-Object System.Net.Sockets.TcpClient

$ErrorActionPreference = 'SilentlyContinue'

#Connect on the given port
$Socket.Connect($ip, $p)

$ErrorActionPreference = 'Continue'

#Determine if the connection is established
if ($Socket.Connected)
{
Write-Host "Outbound port $p is open." -ForegroundColor Yellow
$Socket.Close()
}
else {
Write-Host "Outbound port $p is closed or filtered."
}

$Socket = $null

}
#end foreach

}

Add a comment
Know the answer?
Add Answer to:
Write a script for windows command line which will scan the ports for protocols: FTP, SSH,...
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
  • Write a Bash script called hello that uses command line arguments to allow the user to...

    Write a Bash script called hello that uses command line arguments to allow the user to put two strings after the command name, when the script is being executed. These strings should represent a first and last name. The script should then write out a greeting to the user that includes the first and last name. Here is an example of how the script might work (the first line represents what the user types to launch the script): [user@HAL] hello...

  • Write a script using simple shell commands. The script takes a command line argument that specifies...

    Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: (a) A line starting “Current date and time: ”. Then on the same line, the current time and date. (b) A line starting “Current directory is : ”. Then, on the same line, the absolute pathname of the current working directory. (c) An empty line (d) The line...

  • 1. Which of the following protocols is used by a client to send an email message?...

    1. Which of the following protocols is used by a client to send an email message? a. HTTP SMTP b. FTP d. RDP 2. What is the most common network topology today? a/Star c. Hub Ring d. Mesh 3. A client/server network is the simplest network model. a/ True O False 4. Which client server application allows an administrator to control a remote computer, but does not encrypt or secure the communication between client and server? A Telnet C. Remote...

  • Using network sockets, write a C program called client that receives three command-line arguments in the...

    Using network sockets, write a C program called client that receives three command-line arguments in the form: client host port file and sends a request to a web server. The command-line arguments are hostRepresents the web server to connect to port Represents the port number where a request is sent. Normally an HTTP request is sent over port 80, but this format allows for custom ports file Represents the file requested from the web server Your program should create a...

  • Write a bash script question.sh that accepts one command line argument which is supposed to be...

    Write a bash script question.sh that accepts one command line argument which is supposed to be a positive integer n. The script should print all odd integers from 1 through n. Write a C or C++ program question.c(pp) to read from stdin as many integers as there are available and then print the squares of all these integers. You should test your code by “./question.sh <n> | ./question” assuming the compiled C/C++ program is question. See the following for a...

  • Instructions: Each line of code is to be explained in a comment. I have provided an...

    Instructions: Each line of code is to be explained in a comment. I have provided an example for the first line of code. I want to know what the statement is doing, i.e. creating a function, using module, assigning a value and specifically what is the variable, function, parameters etc… Answer, What will be printed and What is the output in a comment The use of Python Library 2.7 may necessary to complete the assignment. 1. # port variable is...

  • Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. I...

    Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. It should output a list of integers from 'a' and ending with '1' according to the following iteration rule. ( fx = x/2 if x is even; fx=3x+1 if x is odd )

  • 166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls...

    166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls and Os) goes in and out of a machine physically is through the NIC (network interface card). The way network communication goes in and out of a machine logically though, is through a program or service. A service is a program that runs in the background, independent of a logon, that provides functionalities to a system. Windows client machines, for instance, have a Workstation...

  • Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them....

    Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them. The program should print the result of the comparison. Specifically, it should print “<x> is <comparison> <y>”, where <x> is the first number, <y> is the second number and <comparison> is one of “equal to”, “greater than” or “less than”. If the two numbers are equal, the program should have an exit status of zero. The exit...

  • How to solve Exercises 1? Project Goal The project will give you some hands-on experience with...

    How to solve Exercises 1? Project Goal The project will give you some hands-on experience with Nmap. Nmap is a network tool that allows you to scan live hosts and services (open ports), thus, creating a "map" of the network. You will be using Zenmap, a graphical user interface (GUID of Nmap, to investigate several basic types of networl scanning techniques. You can work in teams of two students or alone. Setup: Installing&Using Zenmap Visit nmap.org/download.html to download and install...

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
ADVERTISEMENT