Network hacking is the means of exploiting the infrastructure of computers and printers of a given network to gain access to them.
Every program that wants to listen and receive connections needs a port on which the communication must happen over. Ports are they way of identifying where to exactly send the traffic, since there can be many programs on the computers which communicate. For example, the operating system on startup might communicate with internet to view if there are any pending updates, a lot of programs also do this practice, on startup check for updates.
Audience
Usually a big network of computers are targeted, such as those in companies, over households which might have from 2-3 computers. They look for vulnerabilities in the network and not properly configured network settings, such as exposing ports, on which they can communicate.
Attack surface
The attack is on the whole network, tools that discover open ports are used, those open ports can be the printer, or something else, and there are common ports for common programs. For example, for web servers, the default port is 80. After they perform the scan they can start trying if something responds on those ports, of course, just because the ports are open does not mean that you’re getting hacked, rather, if the program allows, they can communicate with the programs and directly command it.
Still, even if everything is open and the programs communicate through the network, this does not guarantee that something will happen, that’s why usually hackers create what’s called trojan horses. This type of malware does not do anything to the computer, like other malware that are often collecting or trying to destroy everything on the computer, they wait until the hacker himself is ready to attack. They usually listen on some port and allow the hacker to connect to this program, and execute any command as he wishes, from creating himself a user on your computer, to modifying and deleting files, to exporting all of your passwords from the browser.
Prevention
There isn’t a comfortable solution other than to close all programs that you do not use, so that if you’re getting hacked there is nothing that the hacker can use to his advantage.