ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 332 - PT0-002 discussion

Report
Export

Given the following code:

$p = (80, 110, 25)

$network = (192.168.0)

$range = 1 .. 254

$ErrorActionPreference = 'silentlycontinue'

$Foreach ($add in $range)

$Foreach ($x in $p)

{ {$ip = '{0} . {1} -F $network, $add'

If (Test-Connection -BufferSize 32 -Count 1 -quiet -ComputerName $ip)

{$socket = new-object System.Net. Sockets. TcpClient (&ip, $x)

If ($socket. Connected) { $ip $p open'

$socket. Close () }

}

}}

Which of the following tasks could be accomplished with the script?

A.
Reverse shell
Answers
A.
Reverse shell
B.
Ping sweep
Answers
B.
Ping sweep
C.
File download
Answers
C.
File download
D.
Port scan
Answers
D.
Port scan
Suggested answer: D

Explanation:

The script is performing a port scan on the network 192.168.0.0/24, by testing the connectivity of three ports (80, 110, 25) on each IP address in the range 1-254. A port scan is a technique used to identify open ports and services on a target host or network. It can be used for reconnaissance, vulnerability assessment, or penetration testing.

Reference:

* The Official CompTIA PenTest+ Instructor Guide (Exam PT0-002) eBook, Chapter 3, Lesson 3.2, Topic 3.2.2: Perform a port scan

* PowerShell TCP port scanner, Stack Overflow answer by postanote

* PowerShell Basics: How to Scan Open Ports Within a Network, Tech Community blog by Anthony Bartolo

asked 02/10/2024
Princess Sophia Tuazon
41 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first