Friday, October 19, 2012

NTSB Aircraft Incidents and Accidents in Google Earth

Unlike the FAA, the NTSB permits anyone on the Internet to download their entire database of aircraft incidents and accidents. The NTSB's file is simple: one table contains all fields, and their data dictionary explains the fields. The URL to the narrative at the NTSB's site is included for quick report access. I downloaded that file and converted it into a KML file for Google Earth. The event icons are color-coded: blue for incidents, orange for non-fatal accidents, and red for fatal accidents. Unknown events get the default GE pushpin.


CLICK ON THE ICONS IN GOOGLE EARTH FOR MORE INFORMATION. (Seriously, a lot of people miss this and don't get most of the information.)



I did not have to do any geographic math on latitude and longitude. It's in decimal format in the NTSB downloadable, unlike the FAA which has at least two different lat/lon formats in every file. Not all location information is correct, but most of it is. (An example is N6ZV.)

Unfortunately, not all events have been geocoded. Twenty-seven percent, or 19,706 of the total 72,571 events in the NTSB database do have latitude and longitude, and those are contained in the KML file along with other details of the event. Please note that in Google Earth, you need to click on the icon to get the details. (Some people just look at all the items but do not click and miss most of the useful information.)

Looking at the file in Google Earth, the obvious becomes apparent: Most incidents and accidents take place at airports. Out west, a planes don't always make it over mountains. Looking at red sites is also a little creepy.

The idea to map aircraft accidents into a KML file grew out of my imperfect recollection of accidents at nearby airports. I remembered one accident at a nearby airport (ANP), but not the details. If you're going to use all available information to brief yourself, then NTSB accident information for an unfamiliar destination airport might prove useful. You don't need this file and Google Earth to do it -- you can use the NTSB's site. Using the GE, however, might help you identify problem areas.

If I update the KML file (NTSB data is updated monthly), it will go into the KML archive.

Wednesday, September 26, 2012

Special Use Airspace and Military Training Routes KML Files Updated

I updated the Military Training Routes KML file as well as the Special Use Areas KML file on the Sept. 20 FAA data cycle. Both are in the KML folder here.

I also found an interesting new site that has more KML files available, as well as an MTR KML file with a different data source. This is the first time I've been able to check my work against anyone else's. In Google Earth, it's very easy to have two layers and compare them.

The source on the other file is the DoD's DAFIF file, which is now FOUO. That's For Official Use Only, as in not for public release.

The BLM (Bureau of Land Management, part of the Department of the Interior) has an inter-agency airspace coordination site to help coordinate flight restrictions around forest fires. Under that site is a directory of KML files.

The MTR information is close on both files, with the exception of "Slow Routes." I guess the DoD's DAFIF files include "Slow Routes" but the FAA's text data has no such type of MTR listed.

Saturday, June 2, 2012

Xtide: Tide Prediction KML File Updated

I use David Flater's Xtide tide prediction software to view tide levels when I go to the beach. His updates the tide database periodically, and when that file is updated, the location numbers can change. Thus, I need to update the Xtide KML file that displays those locations. There are 4,527 locations (both reference and sub) in the latest harmonics file, dated March 2, 2012. The file contains locations both north and south of the equator.

Tuesday, May 29, 2012

New Improved Military Training Routes KML File -- Includes Puppies

After noticing that the FAA had reduced the line length of their Military Training Route text file from 553 characters to 520 characters in their April release, I knew that I had some cleanup work. They also created a new type of record, separating out the agency data from the base MTR record into its own type. Database folks would call these tables. Who says they government can't change? This makes creating the KML a little easier, because I'd rather parse more record types with fewer fields than fewer record types with more fields.



Fun facts:

  • Pretty much everything the FAA writes is in ALL CAPS.

  • There are about 400 "noise-sensitive" areas that our military pilots need to know about, including at least nine chicken farms.

  • There are about 39 "CONGRESSIONAL" noise-sensitive areas, including several "CONGRESSIONAL (EXTREMELY) NOISE SENSITIVE AREA".

  • There is at least one "CONGRESSIONAL NOISE SENSITIVE AREA (CATTLE FARM)" at N36-28.8 W80-27.5. Who knew that sonic booms make milk go sour?

  • Puppies! "ROUTE SEGMENTS A TO B AND B TO C CLOSED 1 MARCH THROUGH 30 MAY ANNUALLY DUE TO NEW BORN SILVER FOX PUPS." We'll forgive the grammar for puppies.


I am working on creating a KML sub-set to include just Congressional noise-sensitive areas, so we can all know which areas to avoid.

File Format Improvements:

  • SOP and other data are not commingled between IR and VR routes with the same number. Route Type and the number are a composite key.

  • Now includes terrain-following operations notes, if applicable

  • When you click on a line, you get a table of data rather than all freeform text.

  • When you click on a waypoint, you can see the Navaid distance and radial.

  • Waypoints are now star shapes instead of the stock pushpins.


The new Military Training Route file is in the KML Archive. The filename starts with "MTR".

NOT FOR NAVIGATION. CONTAINS UNVERIFIED DATA.

Wednesday, May 23, 2012

Not for Navigation: FAA Navaid File for Google Earth KML

I parsed and plotted the FAA's navigation aid file into KML for Google Earth. This includes VORs, VORTACs, and NDBs, among others. Even decommissioned VOTs are listed because they're still in the database. Other VOTs are still listed as operational. I thought they were obsolete. Seeing all the different navaids in Google Earth is pretty impressive. There are a lot of them. (File is in the KML folder if you can't be bothered to read the rest. It's called US_NAVAIDS, but it includes some foreign navaids, too.)

I tried to include as much data as possible about each navaid, but I left out the details on the Fan markers, because there are only eight of them unless there's a bug in my code someplace.

This file has not been checked, so take a look the VORs near your base and let me know if they're off.

Some of you may be thinking that radio navigation is becoming obsolete and that it's expensive to maintain 2,615 ground-based aids to navigation now that we have GPS, GLONASS, and Galileo. Certainly, many pilots rely on GPS exclusively, but I think that's a mistake. GPS signals are extraordinarily easy to jam. Jammers are cheap, but they're generally not strong enough to reach the altitude required.

Traditional radio-navigation has been working for years. It fails well. One NDB or VOR is not linked to any others, so if one fails, all the others still work. Given that there are thousands of them, it's hard to imagine not being able to tune in any VOR/VORTAC/NDB at all but the lowest altitudes.

With GPS, it's a little easier to imagine widespread failures now that incidents have been documented.

NOT FOR NAVIGATION.

Not for Navigation: FAA Parachute Jump Zones KML

I got around to parsing the FAA's parachute file. At first, the data elements looked good enough to do a proper circle in Google Earth. However, most jump zones have a null radius or no radius. Nevertheless, where there is a radius, it's listed in the area comments. There's a similar problem throughout the data -- elements are missing in many records.

Another mystery: Some areas are charted, some are in the A/FD, and some are listed in neither. (FAA's Airport/Facility Directory This link will expire.).

If you've ever wanted to see all the jump zones in the US in Google Earth, the file is in the archive. Hint: It's called dropzones in the kml directory.

Another mystery: Why I can't get the lat/long math correct on multiple hemispheres the first time I try.

NOT FOR NAVIGATION

Thursday, May 17, 2012

Not for Navigation: FAA Communications Outlets

If you've ever wondered where all the FAA Radio communications outlets are located, here you go. These are not tower frequencies, nor ARTCC or TRACON frequencies. These are the ways to connect to Flight Service Stations, that are sometimes co-located with VORs or airports. They are not unique -- outlet stations associated with an FSS can have multiple locations with the same ID. So says the FAA.

The file is in the usual place. I link to the folder rather than a specific file because the filenames will change with each release cycle.

Thanks to Nicolas Mollet for the icons. I was getting sick of the default Google pushpin

NOT FOR NAVIGATION.

Wednesday, May 16, 2012

Not for Navigation: Airports KML File Updated

I updated the Airport KML file with all US Airports. It still needs edits for cleanliness of the comments. The FAA updated the layout of the file back in April (2012) to include more data. The updates moved the location of a lot of data. All my code merely looks at the right place on each line for the data points, so there was some work to be done.

As usual, it's in the KML folder on my webserver.

NOT FOR NAVIGATION

Tuesday, May 8, 2012

Not for Navigation: KML Files Updated Again

I have updated the Special Use Airspace, Military Training Routes, and AWOS KML files. There have been significant changes in the FAA Data Files. It looks like the FAA Airports file is now providing data to other agencies in the Executive Branch, so there are several more record types to sort out. It looks interesting, so I'm going to take a look at it. I need to rewrite a little code and adjust the SQL tables. Thus the airports KML file is not done yet. (It's not a big deal -- the entire codebase is just string manipulation and SQL queries.)

Also, Military Training Routes are still not validated. I have no idea how accurate they are because I can't find the data in other forms.

Finally, the new AWOS file is AWOS data from the AWOS file only. Previously, it had included airports' AWOS data. Now it doesn't. On the upside, it does inlclude previously not-included AWOS-only stations. If you're wondering what those are, open it up and look at the Gulf of Mexico. There are two entries for each comment.

I really need to figure out the new XML airspace schema.

NOT FOR NAVIGATION.

Monday, March 5, 2012

OpenVPN with smart cards: Not just for pfSense

One day I became curious to see if I could use a security token/smart card with pfSense to log into OpenVPN. Why not? It beats storing unencrypted keys and/or passwords on mobile computers. If you can't get users to change their passwords as often as you'd like, smart cards are one kind of mitigation. You'll just need card readers or USB ports on client devices and the open-source pkcs11 dll or shared object. And get your users not to leave the tokens/cards in their computers. (Which is why it's great to also make them proximity cards for doors.) If you needed your smart card to go to the restroom, I'm guessing you wouldn't leave it in the computer.

This does NOT cover Windows domain authentication, or one-time-password tokens such as inSecureID.

It turns out that it is possible -- provided you follow some simple steps. The best part is that smartcard authentication to pfSense's implementation of OpenVPN doesn't require any server-side configuration changes. (Assuming you're already doing certificate-based authentication -- tls key too, if you want.) That's right. If you've got certificate-based authentication working, you don't need to change a single parameter on the pfSense side. You can also use your smart card to log in via SSH with Putty-SC and via https with Firefox.

Smart cards and tokens are often misunderstood. Mention "hardware security module" and people start to think you're a security geek. But smart cards are mini-HSMs. The card stores your certificate and key. It protects your key with a PIN. Some cards can store more certificates and keys than others, but that's the main concept. It separates your private key from the computer and protects it. Get the PIN wrong a few times and your card gets locked. Forget the PIN unlock code (PUK) and you may lock out the card permanently, which is exactly what should happen in a hardware security module.

But this is IT, where simple concepts are blown up by implementations. Every smart card brand and model is different. The middleware is all different. You have to get married to a card and its vendor's middleware to make it work. Even the HSPD-12/PIV standard is a standard for reading cards only. Administration is different for all vendor PIV implementations, creating millions of dollars in opportunities for card middleware vendors. (Hmmm, I wonder what the US national ID card is going to look like.)

Until OpenSC. OpenSC is the Smart Card project that's been open-sourcing card solutions for a number of years, and it pretty much works if you stick to cards they support.

Problem: they don't support that many cards and the cards they do support aren't sold many places. But you can buy ones that work for shipment to the US and Wassenar countries. I chose Aventra and it worked. Gooze's 2003 PKI USB tokens are up next for testing.

One key point: pkcs15 is a file structure for cards. pkcs11 is a software interface for cards. Read the OpenSC documentation twice before starting -- once for concepts and again for details.

When you buy the cards, you'll be offered a proprietary driver and middleware. Don't use it. Everything you need is at OpenSC-project.org. Stick with those drivers and their process. OpenSSL has an engine for cards: the PKCS11 engine. That lets you issue OpenSSL commands to get a CSR from the card's key. The other software component is pkcs11 shared object/dll file, or "driver." You point your smartcard-aware application at that so it knows where to find the software interface, which knows where to find certificates and ask for keys. (In windows, it's c:\windows\system32\opensc-pkcs11.dll; in Linux, it's wherever you stuck opensc-pkcs11.so.)

Once you get the card, install Open-SC, and stick the card in the reader. (You can install Open-SC on Linux or Windows and maybe Mac.)

1. Initialize the card:
pkcs15-init --create-pkcs15 --profile pkcs15 --use-default-transport-key --pin xxxxxxx --puk xxxxxxxxxx --label "larry" --so-pin xxxxx --so-puk xxxxxxx

(There are many different options, you'll need to read the documentation...)

2. Get the certificates on the card:
Method 1: Fast using your existing OpenVPN certificates:
In a nutshell, here's what you do. Take your OpenVPN client certificate and key, (and your CA chain if necessary), and export it using OpenSSL into a pkcs12 file. Then use OpenSC's pkcs15-init tool to get the pkcs12 file onto the card.

The command below exports your certificate and private key in the same form you can get it out of pfSense. It contains your private key, so don't leave it lying around.

openssl pkcs12 -export -out larry.p12 -in larry.pem -inkey larry.key

Once you've got that, get it on the card thus:

pkcs15-init --store-private-key larry.p12 --format pkcs12 --auth-id 01 --pin xxxxx

Method 2: Create a new card-only key, use your own CA
For advanced users with their own CA, there's another way: issue the command to the card to create a private key, then use the OpenSSL pkcs11 engine and the pkcs11 interface to generate a certificate request.

pkcs15-init --generate-key rsa2048 --auth-id 01 --pin xxxxx

This should take about 40 seconds on the MyEID card. Then get the slot ID for the key:
pkcs15-tool --list-keys

Using reader with a card: SCM SCR 3310 [CCID Interface] 00 00
Private RSA Key [Private Key]
Object Flags : [0x3], private, modifiable
Usage : [0x10E], decrypt, sign, signRecover, derive
Access Flags : [0x0]
ModLength : 2048
Key ref : 1 (0x1)
Native : yes
Path : 3f0050154b01
Auth ID : 01
ID : d5e583c9fc7835231e94369f0f066d5ca5039814
GUID : {d5e583c9-fc78-3523-1e94-369f0f066d5c}

The fire up OpenSSL:
openssl
And then load the pkcs11 engine. (This is what requires you to install the extra engine.)
engine dynamic -pre SO_PATH:/usr/lib64/openssl/engines/engine_pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/local/lib/opensc-pkcs11.so

If all is successful, you can forge ahead. If not, figure out what's wrong with your compile.
(dynamic) Dynamic engine loading support
[Success]: SO_PATH:/usr/lib/engines/engine_pkcs11.so
[Success]: ID:pkcs11
[Success]: LIST_ADD:1
[Success]: LOAD
[Success]: MODULE_PATH:opensc-pkcs11.so
Loaded: (pkcs11) pkcs11 engine

Using the key ID from above, you can create a certificate signing request without getting the key off the card. Just put "slot_x-id_" in front of the number.

OpenSSL>req -engine pkcs11 -new -key slot_1-id_d5e583c9fc7835231e94369f0f066d5ca5039814 -keyform engine -out mynewrequest.csr

Then sign the CSR with your CA and import the certificate to the card. If you don't know how to sign a CSR, then Google it... Once you have the certificate, get it onto the card:

pkcs15-init --store-certificate larry.crt --auth-id 01 --id d5e583c9fc7835231e94369f0f066d5ca5039814 --format pem

Notice that the private key never leaves the card. (My dream is to get TinyCA working and store the CA key on a smart card....)

Now you're ready to test using the card:

OpenVPN:
Then change your client OpenVPN configuration file to use pkcs11. One catch is that the OepnVPN client supports pkcs11 but doesn't give you any way to input the PIN. Nor does OpenVPN-GUI. Viscosity does, but it's proprietary. OpenVPN-GUI has a modded version that supports it that I have not tested yet. Thus I use Viscosity. You'll need to load your pkcs11 module. In windows, it's c:\windows\system32\opensc-pkcs11.dll.

Once you get OpenVPN working, you can try using the key to access logins via SSH using Putty's smart card version. To get your public key off the card in ssh form, just try:
ssh-keygen -D /usr/lib/opensc-pkcs11.so

You can also configure Apache's httpd to use client certificates for authentication. Just change your /etc/httpd/conf.d/ssl.conf to include these two lines:
SSLCACertificateFile /etc/httpd/conf.d/mycafile.pem
where mycafile.pem is your cert authority's public cert.
and then
SSLVerifyClient require
And all your SSL connections will then require client certificates. Apache tends to reset the connection when you don't have a client certificate available.

Firefox has security token support built in. Go to options | encryption | security devices, and load your pkcs11 module. In windows it's c:\windows\system32\opensc-pkcs11.dll. Then you'll be able to choose a client certificate from the card.

When you're done configuring and testing the card, issue the following command to finalize the card:
pkcs15-init --finalize

TrueCrypt supports smart cards, but I have not figured out how to store a keyfile on the card. Yet.

And this assumes OpenVPN, Viscosity, and the cards are all engineered secure.


Tuesday, January 24, 2012

Cloud Asterisk 10: Freepbx 2.10, Gtalk. Two open ports. $5.

When Amazon started offering free virtual machines, I jumped and started setting up Asterisk from scratch. You can't just upload an ISO and boot from that. (That would be WAY too easy for an IaaS provider like Amazon to offer free.)

After getting all the prequisites in, (there are only really two you need to build by hand, iksemel and libSRTP. sox is optional. The rest are RPMs.), I started the ./configure. Success. Then make. Halfway through, the machine shuts down because I'm consuming too many resources. The first time I thought it was a fluke, but after the second time, I gave up.

But I was still intrigued to see if I could do it, so I moved to the Rackspace cloud and set up a CentOS 6 virtual machine with 20 GB of virtual drive and 512 MB of RAM. Again, no uploading a boot ISO. This isn't VMWare. The build went a lot faster when installing required RPMs. On CentOS, sox is available in the repo. On Amazon's AMI box, it was not.

However, FreePBX 2.10 won't install with Asterisk 10. You can install Asterisk 1.8, then install FreePBX, and then upgrade Asterisk to 10. So far, it works. I can't do testing of every feature, but it is easier to test in the cloud than building yet another box in my basement. (With the exception of DAHDI, of course.)

Rackspace is nice and conservative with its default CentOS build. Iptables is left open to everyone for one port -- 22 tcp -- for ssh. It responds to ping, too, but you can fix that. There's no way I was going to open up much more to everyone, like https (which works fine for FreePBX 2.10), or SIP, or RTP ephemeral ports.

How I did that: Use iptables to limit SSH to my own IP addresses, including a backup address or two. Then install OpenVPN. Given that I'm already managing certificates for https and Asterisk it's not a stretch. It's a lot easier if you have your own certificate server rather than using the scripts provided with each component. (Rant: Everyone who needs to configure https, ssl, tls, or OpenVPN on live Internet-connected machines should be required to complete a tutorial on the CONCEPTS of PKI before being allowed get access to CA and certificate creation scripts for live Internet boxes. Both Asterisk and OpenVPN ship with them.)

OpenVPN runs on port 1194 udp. So what's the other open port? 5222 for Gtalk. I just wish Google had a list of its public IPs for me to enter into iptables.

To access the box, I dial in to the OpenVPN with my certificate that has a password-protected encrypted key. Then I connect to the web interface via https. Snom phones connect via OpenVPN with a certificate and cleartext key. For backup and remote logging, the Cloud server also connects back to my basement via OpenVPN. OpenVPN is easier to configure and seems to have better uptime than my IPSec tunnels. I just hope it's as secure as IPSec.

Total cost so far: $5. It's running under a dollar a day, which is fine for a test box for a little while. I'm a little worried that I won't be able to let go after tweaking it out just the way I want it.

Downside: if iptables stops, my box is getting hacked. I'm afraid to ask how much a dedicated firewall (virtual or real) would cost.

Bug I haven't been able to fix yet: sometimes Snom can't connect via TLS or TCP after getting there through OpenSSL. UDP always works. I'm still working to figure out why.

I'd like to do an selinux policy, too, but that's going to take some time.

Update: Video calls seem to be working between extensions between a Nortel 1535 and the Bria softphone. Since the Nortel doesn't support TLS/SRTP, I can't test video encryption yet.

Sunday, January 15, 2012

Asterisk 10 Encryption

As a follow-up to my Asterisk 1.8 encryption fun, I wanted to check out Asterisk 10 and see if I could get SIP-S and SRTP working. I fired up an antique Celeron box with 512MB of RAM with the FreePBX distro CD. An hour later, it was running Asterisk 1.8 and I was talking between extensions. No encryption yet.

At this point, I started to appreciate PBX-in-a-Flash a little more because that distro does a full ./configure, make, make install for Asterisk and Dahdi. The stock FreePBX distribution doesn't, but it does get things up and running quick.

After getting FreePBX running, I downloaded libsrtp and Asterisk 10. I had the same trouble with libsrtp in the Asterisk ./configure as before, so Google the error and add -fPIC etc. to the Makefile. After a couple of attempts, Asterisk finished configuring and making and installed and started. I could make calls back and forth.

However, when I first added tlsenable=yes and a path to my certs to my sip_general_custom.conf and restarted Asterisk 10, it did nothing for TLS. Asterisk wasn't even listening on port 5061. And AES encryption on an IAX2 trunk back to my production Asterisk box failed with the following error:

WARNING[1248] /usr/src/asterisk-10.0.0/include/asterisk/crypto.h: AES encryption disabled. Install OpenSSL.

OpenSSL was installed. On further investigation, I discovered that the res_crypto module was not loading or loadable.

OpenSSL-devel was not installed. So I went back and did a yum-install openssl-devel and recompiled and reinstalled Asterisk 10. Then TLS worked fine.

For the record, here are the packages I installed for Asterisk 10 on a FreePBX 2.9.0.9 distro. Dahdi and Asterisk-Add-Ons are not covered here.

zlib-devel-1.2.3-3.i386
libxml2-devel-2.6.26-2.1.2.8.el5_5.1.i386
sqlite-devel-3.3.6-5.i386
doxygen-1.4.7-1.1.i386
keyutils-libs-devel-1.2-1.el5.i386
e2fsprogs-devel-1.39-23.el5_5.1.i386
libsepol-devel-1.15.2-3.el5.i386
libselinux-devel-1.33.4-5.5.el5.i386
krb5-devel-1.6.1-36.el5_5.6.i386
openssl-devel-0.9.8e-12.el5_5.7.i386
mysql-devel-5.0.77-4.el5_5.4.i386

Another thing: You can add your SIP parameters (like tlsenable=yes) to the SIP configuration page that's available in FreePBX now, instead of hand-editing /etc/asterisk/sip_general_custom.conf.

Next: An selinux policy for Asterisk?

Saturday, January 7, 2012

Asterisk Encryption Gotchas

Finally, Asterisk supports encryption of phone calls and signalling in version 1.8. It's about time. So now, those of us running FreePBX can just hit the encryption checkbox and everything will run fine. Not so much. FreePBX 2.9 incorporates encryption options for extensions, but it assumes you've done all the legwork and configured all the prerequisites. (Tested with varying levels of success on Asterisk 1.8.1.1, FreePBX 2.9.0.7, Bria 3.2.1 62387 (iPhone version works fine, too), snom370-SIP 8.4.32, Aastra 57iCT/3.2.2.1136, and Xlite 4.0.9). My Asterisk install is based on PBX in a Flash, but I do my own recompiling, which pretty much voids its warranty and script upgrade functionality. So proceed at your own risk. (Since this is Asterisk, though, you knew that already.)

To get encryption running in Asterisk, take things step by step. Asterisk encryption is really two types of enrcryption: SIP-S, or SIP over TLS for signalling -- traditional PKI using OpenSSL; and SRTP for the voice traffic. Each is configured independently under each extension. Asterisk Encryption is not end-to-end. It is extension-to-Asterisk, and maybe Asterisk-to-Asterisk on trunks. Asterisk encryption is not foolproof, and it will not encrypt calls to the PSTN. It's still vulnerable to MITM attacks with faked certs, and to a compromise of your Asterisk install. Also, just because your connection to Asterisk is encrypted and the lock symbol shows up on your phone doesn't mean the other extension (or trunk) on the other side of Asterisk is also secure.

The key for SRTP is exchanged over the SIP channel, so if SIP's not encrypted, what's the point of bothering with SRTP? If you want to see what you're missing by not using encryption, download Cain from oxid.it and run it while you register the Bria softphone client and make a call from your windows computer. You get hashes of your SIP passwords and recordings of your phone calls, all from a GUI Windows program. If you have a network tap or span port in the right spot, you can intercept every call and signal between your Asterisk server and its SIP endpoints.

To get started, Asterisk 1.8 requires libsrtp. (You can thank Cisco for making it available, too.) You'll need to download, configure, make, make runtest, and make install before you hit ./configure on your Asterisk source. (Yes, recompiling Asterisk is necessary.) Then, when you do ./configure on your Asterisk source, you'll get an error when it finally gets to checking your libsrtp availability. Google the error phrase, and you'll learn what to change in the CFLAGS line of your libsrtp Makefile. Recompile and reinstall libsrtp, then reconfigure Asterisk. Then in your Asterisk source, make menuselect and select libsrtp under resources. Don't forget to make sure your other cool Asterisk features (like gtalk) are still enabled before you save and exit. Then recompile and reinstall Asterisk. There are plenty of tutorials for these steps on the Interwebs.

Once Asterisk is running again, you can start by getting a certificate for TLS. I am not going to do yet another certificate from self-signed CA howto here. There's an excellent one over at madboa. It's nice for Asterisk to now include a CA/Cert script, but you should really understand how SSL works. I know people who send private keys via email.

Another note about certificates: even if all your workstations are in a friendly LAN with the same DNS suffix, use the fully-qualified Domain Name (FQDN) for your Asterisk certificate. Some endpoints (Bria, I'm looking at you) require FQDN and cannot validate the certificate if you're getting to your Asterisk server by a short name. Using IP addresses for the registrar in your endpoints? That won't work either. You'll need the CA cert on some endpoints but not others. (Snom phones like certs in DER format; Asterisk and Aastra like PEM. To copy from PEM to DER, try this:

openssl x509 -in input.crt -inform PEM -out output.crt -outform DER

Once you get your CA and certificate, your sip_general_custom.conf file should have lines as follows. (In FreePBX, sip_general_custom.conf is the one you can hand-edit safely.)

tcpenable=yes ; If you don't have TCP enabled for SIP now, go ahead and enter this and test it.
tlsenable=yes
tlsbindaddr=0.0.0.0
tlsclientmethod=tlsv1
tlscertfile=/etc/asterisk/keys/asterisk.crt ; concatenate the key file to the bottom of the cert file so they're together.
tlscafile=/etc/asterisk/keys/asteriskCA.crt
tlscipher=AES256-SHA:AES128-SHA:RC4-SHA:RC4-MD5;

Some say put "ANY" there for tlscipher. I suggest you want encryption that's strong but compatible with your endpoints. For valid strings, look here: http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS. To see which one your endpoint is using, you'll need to do a network capture via Wireshark. If there's no shared cipher between your endpoint and Asterisk, you'll see something like this in your logs:
/var/log/asterisk/full:[2012-01-03 13:59:30] VERBOSE[29926] tcptls.c: == Problem setting up ssl connection:
error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher

Also, you'll need to trust your self-signed CA in Linux. (Seriously, don't set tlsdontverifyserver=yes -- it's just lame.)

If you're on Fedora or CentOS, the folder is /etc/pki/tls/certs.
# ln -s myAsteriskCA.cer `openssl x509 -hash -noout -in myAsteriskCA.cer`.0
then verify:
# openssl verify -CApath /etc/pki/tls/certs /etc/asterisk/keys/myAsterisk.cer
should get you a:
/etc/asterisk/keys/myAsterisk.cer: OK
Once you have a certificate in place, restart Asterisk and see what comes up:
/var/log/asterisk/full:[2012-01-02 23:37:26] VERBOSE[24700] tcptls.c: SSL certificate ok

Then you can try connecting with TLS. In FreePBX, you go to the particular extension you want to test and select TLS Only and reload. Each endpoint is different. Once TLS is successful, you can try setting the extension to use SRTP encryption in FreePBX.

Notes on Phones:

Each phone is different. Bria was easy, so you may want to start with that to see if Asterisk is working correctly. In account settings, domain needs to be a FQDN that matches what you've assigned the certificate. You also need to import the your CA cert into Windows' CA certificate store. For signaling transport, select TLS. For SRTP, select "Make and accept only encrypted calls" for Media Encryption. With any luck, when you hit the apply button, you should see "All accounts are active." While Bria for Windows validates certificates, it's optional on the Bria for iPhone/iPad.

The other software phone, 3CX, has settings for TLS but gets caught in an SSL handshake loop when trying to register, in spite of a shared cipher suite.

For the SNOM 370 to connect via SRTP successfully, I had to set RTP/SAVP to Mandatory. (Identity | RTP in the Snom Menu.) If you have multiple SIP accounts to the same Asterisk server in your SNOM phone, having any one ID configuration incorrect can break them all (Error message "Not acceptable here" whenever you dial). Also set the SRTP Key to 80-bit; 32-bit is the SNOM default, which doesn't work. (This has changed in Asterisk 10: Add option encryption_taglen to set auth taglen only 32 and 80 are supported currently.)

Also, disable RTCP support in SNOM if you don't want Asterisk to crash when it's doing SRTP.

user_host1!: my.asterisk.net;transport=tls
user_host2!: my.asterisk.net;transport=tls
user_srtp1!: on
user_srtp2!: on
user_symmetrical_rtp1!: off
user_symmetrical_rtp2!: off
user_server_type1!: asterisk
user_server_type2!: asterisk
user_savp1!: mandatory
user_savp2!: mandatory
empty_tls_client_cert!: off
xcap_via_tls!: true
tls_server_authentication!: on
user_auth_tag1!: off
user_auth_tag2!: off
support_rtcp!: off

On Aastra 6757iCT I got TLS working, and SRTP for inbound. Unfortunately, when SRTP is active, dialing out doesn't work at all, with "call failed" every time so far. I've gone through most of the DTMF options, inluding SIP, and still no joy. The difference between CA certs and Trusted Certs on the TLS support page is not clear to me. Aastra says to put your CA root & intermediate certs in CA Certs and Trusted Certs on the TLS support menu. For my mode -- persistent TLS -- I have only trusted certificates, a PEM file with concatenated public certs of my Asterisk server and its issuing CA.) Also, you need to manually set all the ports to 5061 for TLS. The others phones switched ports automatically. Relevant lines:

sip local port: 5061
sip local tls port: 5061
sip proxy port: 5061
sip registrar port: 5061
sip outbound proxy port: 5061
sip srtp mode: 0
(SRTP disabled -- so dialing out can work.)
sip transport protocol: 4
sips trusted certificates: asterisk2.pem
sips persistent tls: 1

I'd like to make more progress on the Aastra, but it requires even more reboots than the Snom.

Finally, run Cain again to see if your phones are encrypted for SIP and Voice. Even when SRTP is encrypting voice traffic, you can tell that a call is happening and how log it lasts. If you can't get a tap, you can do a TCP dump to a .cap file on your Asterisk server and then open it with Wireshark. Then you can take a look to see if the data looks encrypted.

Leftover vulnerabilities: This configuration still uses passwords for client authentication. You can use client-side certs if you want. Certificate Authorities are vulnerable. Bria (at least on Windows) uses the Windows Certificate Authorities that come installed. SNOM phones ship with CA certs aboard. (You still have to upload your own certs to the SNOM phone.) SNOM has no mechanisms for a certificate revocation list, so compromised CAs can be used to impersonate your certificates in a MITM attack. Aastra makes you upload any CA certs for trust.

Finally, for the SNOM phones that have the OpenVPN client, using the OpenVPN connection back to your Asterisk server and encryption within the (encrypted) VPN connection should provide some additional level of security.
(Assuming you haven't left your private keys exposed someplace.)

The secure PBX is not connected to the PSTN. And when you say man-in-the-middle attack, think government-in-the-middle. It's gender neutral.

Wednesday, December 14, 2011

US Airports KML file updated. That's 13,632 airports.

There are 13,632 airports in the FAA database. That does not count balloonports, seaplane bases, gliderports, heliports, or ultralight facilities. That's also a huge number of placemarks for a KML file, so your Google Earth machine will need some processing power.

If you pan out, the placemark icons will cover the continental United States. It also drives home the point that if you're flying high enough and your engine dies, you should be able to glide to an airport.

Improvements: Public airports are in blue; private airports are in red. AWOS data is included where applicable. (If airports have an AWOS, it's included. Note that ATIS is not the same as AWOS.)

Code improvements: All output code is Python. The database is still Microsoft SQL, and the API is adodb for Python. Next: Porting output code to Linux (need a new database connection) and keeping back end MS SQL for now. Long-term: cleaning up and uploading data via python into MySQL.

Random Comments on Python: String manipulation in python is the same as in visual basic script, but different. If statements have no end, just an indent and and end of indent.

The KML file is in the KML archive, as usual. DO NOT USE FOR NAVIGATION.

Friday, December 9, 2011

New KML File: Radiological Air Samples from the US DOE/NNSA Response to the 2011 Fukushima Incident

The US Government makes available many data sets free. This is in contrast to the UK where public government data is the property of the crown and is sold to the public. US citizens still pay for the data in taxes.

One of those data sets is Radiological Air Samples from the US DOE/NNSA Response to the 2011 Fukushima Incident. You can see more free data sets on the Data.Gov web site.

Since the set included latitude and longitude, I created a KML file. I have no idea exactly how dangerous those levels of radiation are, but it's still interesting to see what was found and where they sampled.

Wednesday, December 7, 2011

Tide Prediction Locations in Google Earth and Google Maps

I love xtide, the Unix tide prediction server. I have it serving web pages and serving a telephone dial-in number in Asterisk for the beach I visit. I finally got around to writing the KML file that links placemarks to the URL for my copy of the Xtide web server. Click on the placemark to see the URL for the location's tide prediction page.

Also, you can now view KML files in Google Maps by typing in the URL to the KML file in the search bar. You'll end up with a URL in Google Maps that looks like this: http://www.google.com/maps?q=http%3A%2F%2Fcw.sampas.net%2Fkml%2Fxtide.kml&hl=en&ll=37.439974%2C-131.660156&spn=101.116429%2C158.027344&sll=37.0625%2C-95.677068&sspn=54.357317%2C79.013672&vpsrc=6&t=h&z=3&source=gplus-ogsb .

The xtide.kml file is in the usual place.

Tuesday, December 6, 2011

Military Training Routes KML: Is this really what they look like?

This entry is obsolete. For the latest MTR KML, go here.

I used the same math from previous kml files to create a US master list of Military Training Routes. VFR routes are in green, and IFR routes are in red. Some segments overlap. Overall, they just look weird, so I'm wondering if its at all accurate. (Note: DO NOT USE FOR NAVIGATION.) Placemarks are waypoints that are along the route lines. Line descriptions contain route descriptions, while placemarks contain point lead-in and depart information. I don't think kml has a good way of displaying lines and points as the same object with different descriptions.... but what do I know about KML anyway?

See the KML in the KML Archive. The sheer number of lines and placemarks may use up all your memory.

Thursday, December 1, 2011

Special Use Airspace KML: Boy was my KML invalid!

I have updated my KML output script so that the KML it outputs is valid, thanks to the KML Validator. The latest version of Google Earth is not nearly so tolerant of poorly written KML, which I only recently noticed when I tried to open my KML files that had worked just fine previously.

The main problems were my coordinate lists, where instead of delimiting by a space between tuples, I had delimited with a newline. I also did not close the coordinate sets with the first coordinate. The FAA doesn't either, because it's obvious. You draw a line from the last coordinate to the first. After the loop, I do a recordset.movefirst and write the first coordinate pair AGAIN.

Anyhow, you can see the new file in the KML archive. I may get around to doing more than just the SUA files. I'm also considering migrating the entire codebase to Python for portability. And because all the cool kids are writing in Python, and I can't stay in vbscript forever...

This KML file contains the FAA's special use types of airspace: alert areas, military operations areas, prohibited areas, restricted areas, and warning areas.

Tuesday, November 29, 2011

Snom, pfSense, OpenVPN, and Asterisk: Cheaper than Cisco

VOIP and SIP have made calling cheaper than ever, but security is only just catching up. The idea of a secure, transportable (hard) phone has been around for a while. Just look at the STU-III or the KY-3. Cisco is moving away from the phone proxy on its ASA devices and towards an IPSec client in the phone with its associated licensing. Snom, OpenVPN, and Asterisk can do the same for less. The Snom 370, 800-series, and 7x0 series phones have the OpenVPN client in the firmware.

Asterisk's built-in encryption is only just starting to work in 1.8, and it would require you to open ports to your Asterisk server from the Internet. Enter OpenVPN, an open-source user-space VPN that's lighter weight than IPSec. Better yet, no per-client licensing fees like Cisco. (Unless you want commercially supported OpenVPN @ $10/client.) Asterisk itself isn't quite ready for the enterprise, but we're all hoping Asterisk 10 is ready for prime time.

Using the built-in OpenVPN server in pfSense 2.0, you can connect your Snom phone across the internet to your internal network, and Asterisk securely. (Although it does not do end-to-end encryption, even if you run OpenVPN on your Asterisk server.)

Part 1: pfSense OpenVPN config


In the pfSense OpenVPN server page, choose the following parameters: (DISCLAIMER: this is certainly not the only way to do this, nor the most secure.) I'm also going to assume you've already used the pfSense Cert Manager to create a CA and issue a client certificate for the your Snom phone.

OpenVPN | Server

General
Disabled: Not checked.
Server Mode: Remote Access (SSL/TLS).
Protocol: UDP
Device Mode: tun
Interface: WAN
Local Port: 1194 (default)
Description: SnomPhoneVPN

Crypto Settings:
TLS Authentication: Checked (pfSense should populate the box with an OpenVPN Static Key.)
Peer Certificate Authority: InternalCA (What you set up in pfSense's CA Page.)
Peer Certificate Revocation List: (leave default for now.)
Server Certificate: OpenVPNServer (CA: InternalCA)
DH Params Length: 1024
Encryption Algorithm: AES-256-CBC (256-bit)
Hardware Crypto: No Hardware Crypto (Unless you've got a card...)

Tunnel Settings:
Tunnel Network: Choose a private IP space that's not 192.168.x.x, so it doesn't conflict with every NAT home network. (10.1.0.0/24) should work most places.
Redirect gateway: Checked if you want it to be more secure, but you'll lose local access to the phone.
Local Network: Enter yor local LAN IP space here, e.g. the one you Asterisk server is on.
Concurrent connections: 1 or more.
Compression: unchecked.
Inter-client Communications: not checked.
Duplicate connections: leave this checked for testing only.

Client Settings: The only one that needs to be checked is "Provide a virtual adapater IP addresss to clients."

Advanced: Nothing is required here.

Part 2: Client OpenVPN config

Use the OpenVPN client export utility (0.9.6). Export the Configuration Archive. Unzip the files. Rename the x.ovpn file to vpn.cnf and edit it to add /openvpn/ in front of the cert and key file names. Then place it in a dir/folder called openvpn and tar it from within the folder, per SNOM.

Keep in mind that the two other files in there, the personal certificate (x-.p12) and the OpenVPN TLS key (x-tls.key) are the keys to your network, so protect them. (If your certificate file is compromised, you'll need to create a certificate revocation list pronto.) When we selected Remote Access (SSL/TLS) in step one, that means certificate only, and then added the TLS key. So no username and password required. (You can try adding them, but you'll need to hard-code them in another file in the config tarball, so it won't make much difference.)

vpn.cnf after editing:
#----------
dev tun
persist-tun
persist-key
proto udp
cipher AES-256-CBC
tls-client
client
resolv-retry infinite
remote x.x.x.x 1194
tls-remote OpenVPNServer
pkcs12 /openvpn/pfsense-udp-1194.p12
tls-auth /openvpn/pfsense-udp-1194-tls.key 1
#----------
where x.x.x.x is your WAN IP Address, or preferably, your dynamically updated DNS name if your IP is subject to change.

There should be three files for you to place in the tarball: vpn.cnf, the .p12 certificate (with key), and the xtls.key. Once you have the tarball, follow SNOM's instructions to get it onto the phone. (Hint: you'll need to place it on a webserver, but preferably not one that's publicly available or unauthenticated.)


Gotchas:


  1. This client config leaves you vulnerable to man-in-the-middle attacks where someone says they're your server. I'm still working on server authentication that works with the pfsense openvpn config.

  2. The phone's NTP server needs to be available on whatever network you plug in to.

  3. You need to follow Snom's instructions on how to create the tar file, which may be different than what you're used to.

  4. You need netcat running to see OpenVPN logs. They don't go to the phone's syslog server.

  5. If you blow up your Snom phone (can't connect to it any more), be sure to have the firmware image available on a local tftp server so you can start all over.

  6. Don't forget to add your OpenVPN network to Asterisk's sip_nat.conf or you'll drop calls.

  7. Be aware that the Snom phones can also route packets from devices behind it via the PC port. You'll need to consider how to secure your internal network from the vpn phones.

  8. If your Snom phone doesn't grab the tarball after boot, you'll need to put a dummy file on the webserver that's referenced on the advanced | update | Setting URL: parameter called "snom370.htm". Then the phone should start grabbing the tarball again. This may be a bug in snom370-SIP 8.4.32, the version tested.

  9. You'll need to test on a subnet that doesn't have access to your Asterisk box without the VPN. E.g. not on your internal network.




Friday, May 20, 2011

VBScript: MD5 sum and file details into CSV

Some things are trivial in Linux/Unix and more complex in Windows. In Linux, it's md5sum filename. In Windows, there are free tools from Microsoft (fciv.exe), but no built-in commands that are super-easy to script.

So what are you to do if you need to collect file details and hashes for every folder within the subfolders of a directory? If you're doing it with VBScript, you'll need a free library available from XStandard. Once you register, you'll get a dll that you'll need to register. (It's 32-bit only, so if you're on a 64-bit box, you'll need to do this:
C:\WINDOWS\SysWOW64\regsvr32.exe XMD5.dll
and then to execute the script:
c:\windows\SysWOW64\cscript.exe FolderReportMD5.vbs )

Anyhow, this script is derived from the Sapien sample scripts. (While there are many free editors out there, I think Sapien's PrimalScript is worth every penny if you'll be doing a lot of Windows scripting.)

And since my MT template doesn't handle code well, here's a link to the text file.

'**************************************************************************
' File: FileListMD5.vbs
'
' Comments: This script uses the MD5 library available here:
' http://www.xstandard.com/en/documentation/xmd5/#api1
' This script runs through a directory tree and writes file attributes to a csv file.
' To run on x64 use C:\WINDOWS\SysWOW64\regsvr32.exe XMD5.dll and then execute via
' c:\windows\SysWOW64\cscript.exe FolderReportMD5.vbs
' Based on Sapien's sample script for FolderProperties.
'**************************************************************************
Set objFSO2 = createobject("scripting.filesystemobject")
'where to put the file list?
Set objFile = objFSO2.createtextfile("c:\scripts\" & "FileList" & ".csv")
q = """"
'write the header line of the CSV file.
objFile.WriteLine(q & "FilePath" & q & "," & q & "FileName" & q & "," & q & "DateCreated" & q _
& "," & q & "DateLastAccessed" & q & "," & q & "DateLastModified" & q & "," & q & "FileSize" & q &_
"," & q & "MD5Hash" & q & "," & q & "FileAttributes" & q)

'where to start
strSource="C:\folder"

Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder=objFSO.GetFolder(strSource)

Call ProcessFiles(objFolder)

Sub ProcessFiles(objFolder)
Set colFiles=objFolder.Files


For Each file In colFiles
'it's a good idea to clear out the vars on each loop
strFingerPrint = "blank"
strPath = File.Path
Set objMD5 = CreateObject("XStandard.MD5")
strFingerPrint = objMD5.GetCheckSumFromFile(strPath)
Set objMD5 = Nothing
wscript.Echo strFingerPrint
wscript.Echo "File Name:" & vbTab & File.Name
wscript.Echo "Short File Name:" & vbtab & File.ShortName
wscript.Echo "File Path:" & vbtab & File.Path
wscript.Echo "Date Created:" & vbtab & File.DateCreated
wscript.Echo "Date Last Accessed:" & vbtab & File.DateLastAccessed
wscript.Echo "Date Last Modified:" & vbtab & File.DateLastModified
wscript.Echo "File Size:" & vbtab & File.Size
wscript.Echo "File Attributes:"
strFileAttributes = " "
if File.Attributes AND 0 Then wscript.Echo " Normal"
If File.Attributes And 0 Then strFileAttributes = strFileAttributes & " Normal"
if File.Attributes AND 1 then wscript.Echo " Read-only"
If File.Attributes And 1 Then strFileAttributes = strFileAttributes & " Read-only"
if File.Attributes AND 2 then wscript.Echo " Hidden"
If File.Attributes And 2 Then strFileAttributes = strFileAttributes & " Hidden"
if File.Attributes AND 4 then wscript.Echo " System"
If File.Attributes And 4 Then strFileAttributes = strFileAttributes & " System"
if File.Attributes And 8 Then wscript.Echo " Volume"
If File.Attributes And 8 Then strFileAttributes = strFileAttributes & " Volume"
if File.Attributes AND 16 then wscript.Echo " Directory"
If File.Attributes And 16 Then strFileAttributes = strFileAttributes & " Directory"
if File.Attributes And 32 Then wscript.Echo " Archive Bit is set"
If File.Attributes And 32 Then strFileAttributes = strFileAttributes & " Archive Bit is set"
If File.Attributes AND 1024 then wscript.Echo " Alias"
If File.Attributes And 1024 Then strFileAttributes = strFileAttributes & " Alias"
if File.Attributes AND 2048 then wscript.Echo " Compressed"
If File.Attributes And 2048 Then strFileAttributes = strFileAttributes & " Compressed"

'finally, write the line to the csv file
objFile.WriteLine(q & File.Path & _
q & "," & q & File.Name & q & "," & _
q & File.DateCreated & q & "," & q & File.DateLastAccessed & q & "," & q _
& File.DateLastModified & q & "," & q & File.Size & q & "," & q & strFingerPrint & q & "," & q & strFileAttributes & q)

Next
'process Subfolders
Call ProcessSubFolders(objFolder)

End Sub

Sub ProcessSubFolders(objFolder)
Set colSubs=objFolder.SubFolders
For Each folder In colSubs
ProcessFiles(folder)
Next

End Sub