The simplest definition of port scanning is that it is a method used to determine the state of the Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) ports on the target machines. An open port may mean that there is a network service listening on the port and the service is accessible, whereas a closed port means that there is no network service listening on that port.
After getting the port's state, an attacker will then check the version of the software used by the network service and find out the vulnerabilities of that version of software. For example, suppose that server A has web-server software version 1.0. A few days ago, there was a security advisory released. The advisory gave information about the vulnerability in web-server software Version 1.0. If an attacker finds out about server A's web server and is able to...