The nc (or netcat) binary is useful for a variety of TCP or UDP operations. You can open a listener, proxy connections, open a connection to another device, and port scan a device. And you can do it all through TCP and/or UDP, define ports, and scripting with nc is pretty easy. So in the below code we’ll start a while loop and then execute an echo of a header so a browser knows how to interpret what we’re sharing, which is a cat of our file. Then we’ll pipe that into netcat with a -l option so we can define the port and end the loop. while TRUE; do…
-
-
Network Port Testing With Netcat
You can do some pretty simple testing of ports and network communications using strategies I’ve outlined in the past with tcpdump, trace route, telnet, curl, stroke and of course ping. However, netcat has a few interesting things you can do with it; namely actually run a port super-quickly to test traffic between subnets, forcing scans of ipv6 traffic, debugging sockets, keeping connections alive, parodying through SOCKS 4 and 5 and just checking for daemons that are listening rather than actually sending data to them. In this first example, we’re going to just check that Apple’s web server is accessible (adding -v for verbose output): /usr/bin/nc -v www.apple.com 80 The result would be pretty verbose…