projectz

Tech, Gadgets, Photography, Social Media and Poor Spelling

Watch All Open Network Connections in Mac OS X with Open_Ports

Watch All Open Network Connections in Mac OS X with Open_Ports


Showing open ports on the Mac desktop

You can watch all open network connections for both incoming and outgoing transfers using a free command line utility called open_ports.sh. Open_Ports is much more useful than using lsof to list open internet connectionsbecause it provides extensive network information in a very easy to read format, including what program or process is opening the connection, which port and user, the number of connections per process, the hostname being connected to, the country, and even the city.

Additionally, open_ports shows you all of your open ports listening for connections, again with information about the application, user, port number and name, and even the service IP range. All of the output is color coded, a red background signifies the process is owned by root, red text means the IP address doesn’t correspond to a domain name, blue means the IP matches several domain names, and green text means the protocol is encrypted.

Installation requires some experience with the command line, but chances are if you want an application like this then that won’t be an issue. Here we go…

Installing Open_Ports in Mac OS X

These are are the installation instructions directly from the developers page at Lunds University in Sweden, they have been verified to work in Mac OS X 10.6.8:

Warning: This is a bash script that runs as root that downloads other scripts from the web. This has obvious potential security issues and if you are not comfortable with that or you are in a delicate network environment, this is not recommended to use. The script works as intended, and you can verify the source of the bash script yourself if you want, but if you have any questions or hesitation about running a third party script as root then you may want to use an alternate method to watch open connections, using lsof for example. Proceed at your own risk.

  1. Fetch the install-script from
    http://fileadmin.cs.lth.se/cs/Personal/Peter_Moller/scripts/open_ports_install.sh
  2. Start a terminal
  3. Become root: if you are a normal user, typesudo adminusernamneand thensudo -iif you are an admin-user, typesudo -i
  4. Set access rights for the install script:
    chmod 755 open_ports_install.sh(you must locate it)
  5. Run the script:
    ./open_ports_install.sh
  6. The installation is normally quick. For Linux, that all. On a Mac it ands with GeekTool being opened. To install it, double-click it’s .PrefPane
  7. In GeekTool: click the icon named ”Shell” and drag it to an empty part of the desktop (must be free of windows). Size it as well.
  8. A ”Properties”-window opens. What you need to enter is:
    • Command: open_ports.sh
    • Refresh every: 120 s
    • Change font to a monospace-one (I’m using Menlo and white font color)
  9. Now you may close GeekTool

The other great thing about open_ports is that the Mac OS X version is built to be used in GeekTool, so you can display the output on your Mac desktop. If you’re going to use it through GeekTool, I would suggest using a more plain background picture otherwise the text is hard to read, this is how it looks against the OS X Lion Galaxy wallpaper.

Show open network connections on the Mac OS X Desktop

If you want to unintsall open_ports from Mac OS X, use the following commands as root:
launchctl stop se.lth.cs.open_ports

launchctl unload /Library/LaunchDaemons/se.lth.cs.open_ports.plist

Then you can delete the scripts:
rm -rf /usr/bin/open_ports.sh (the script)

rm -rf /Library/LaunchDaemons/se.lth.cs.open_ports.plist (the gather control)

rm -rf /Library/cs.lth.se/OpenPorts (the data files)

In case you were wondering, there is also a Linux version available. I came across this awesome utility on MacWorld, but MacWorld didn’t actually test the script to verify that it works, but I can confirm that it definitely does.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on July 10, 2011 by in link and tagged , , , , , , .
%d bloggers like this: