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 the bash script Write a script compress_large_files.sh. This script accepts one or more command line...

    write the bash script Write a script compress_large_files.sh. This script accepts one or more command line arguments. The first argument has to be an integer; let’s call it size. If this is the only command line argument, compress_large_files.sh inspects all files in the current working directory and compresses every file of size at least size. If there is more than one command line argument, all arguments except the first one must be valid directories. In this case, compress_large_files.sh inspects the...

  • 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 PowerShell script which takes 6 command-line arguments, reverses the digits in each, and then...

    Write a PowerShell script which takes 6 command-line arguments, reverses the digits in each, and then sorts the results.

  • 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...

    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 )

  • 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 )

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