We’ll grab the Banner from the SSH port (usually port 22)
Determine if it’s an OpenSSH banner
Map out the SSH Comment to a list of banners we have and determine the FreeBSD version.
The big difference from the Ubuntu post is how to map the FreeBSD banners. I’ll explain that next.
Translate Banners to FreeBSD Versions
OpenSSH FreeBSD banners look like “SSH-2.0-OpenSSH_7.3 FreeBSD-20170902”, “SSH-2.0-OpenSSH_5.4p1_hpn13v11 FreeBSD-20100308”, etc. It’s not easy to determine the FreeBSD version from the banner.
I did some research, but I could not find a resource similar to Ubuntu’s Launchpad entries, with information that could allow me to determine the relationship between OpenSSH version, build version, patch version and FreeBSD version or something similar.
However, I was able to find that FreeBSD’s man page does have the default value in the “VersionAddendum” section. For example, FreeBSD 10.0-Release has the default value of FreeBSD-20131111.
Using a small script or a web proxy, we can get a list of all the default values and the FreeBSD version. I used Burp to obtain the valid FreeBSD versions from the man page and then used them as payload as shown in Figure 1.
Figure 1. Payloads configured
After launching the script, we get these results:
Figure 2. Results and list of FreeBSD version and FreeBSD banner
Those results could be saved in a CSV file and then analyzed. It is also important to mention that old versions of OpenSSH (for example, FreeBSD 4.7 and earlier) did not include the parameter and were not included for review. However, those versions have been end-of-life for a few years now.
Comparing the list of banners vs banners in the wild
Now that we have a list of banners and the corresponding FreeBSD version, we should check that we have a match for most of the banners out "in the wild".
It is not required to authenticate to the device in order to get the banner. A simple TCP connection is the only thing needed. This means, that this information is available for any FreeBSD machine on the Internet running OpenSSH.
I used Shodan to get a list of banners so we can verify we’re catching most of them. There are a couple of ways to do the next query. One option is to query by port (the default port of SSH is 22):
Figure 3. Total results of Shodan search by port and Freebsd text
Another option is by product (“OpenSSH”):
Figure 4. Total results of Shodan search by OpenSSH and Freebsd text
In both cases, I added “freebsd” to only show banners that are related to FreeBSD.
I exported 50,000 results in JSON format for analysis. I grouped the results by unique banner, and I got about 180 unique banners. Over 90% of them were matched with the fingerprint information I generated earlier. Most of the non-matching banners are edge cases, either someone who modified the banner or an OS that uses FreeBSD as a base (for example TrustOS). Figure 3 shows a graph of the exported results.
Figure 5. Graph of FreeBSD versions based on how common it was in the banners analyzed
We have updated TrustKeeper scan engine’s operating system fingerprint with the data obtained.