College Wireless Policy (Part 1)

August 23, 2008

Well, I am back on campus and I have had a bit of time to goof around before classes start. I came here early for marching band camp, which is why I have not had any posts in a little bit even though I have had some free time.

Our college has a very strict wireless policy, which is that you aren’t allowed to have your own wireless access point. Period. So, as a curious computer science student, I wondered how many people actually listened to this policy. I wrote myself a little perl script, which allowed me to simply walk around and it would poll (using iwlist scan) for wireless networks and then record them until I told it to stop. So once I had this all working and tested I spent about 15 minutes walking around picking up wireless signals. The results I found were more surprising than I had anticipated.

Here is a table of the unencrypted wireless networks I found:

#      Network Name                   Encryption
1      "04Z409107113"                 off
2      "alicia"                       off
3      "B2B"                          off
4      "B2B"                          off
5      "belkin54g"                    off
6      "CaptivePortalTemp"            off
7      "CaptivePortalTemp"            off
8      "CaptivePortalTemp"            off
9      "CaptivePortalTemp"            off
10     "CaptivePortalTemp"            off
11     "CaptivePortalTemp"            off
12     "hpsetup"                      off
13     "hpsetup"                      off
14     "linksys"                      off
15     "linksys"                      off
16     "linksys"                      off
17     "linksys"                      off
18     "<College_Name>"               off
19     "print server 053797"          off
20     "print server 075462"          off
21     "Rosa/Vazquez"                 off
22     "Wireless Network"             off
23     "Wireless"                     off

I know this table could look a little prettier, but its not for heavy anaylsis. For all of the networks that say “linksys” I made sure they were unique by using the MAC Address that turns up in the results of an ‘iwlist scan’ So it’s not just the same linksys network that was picked up 4 times πŸ˜‰ .

I am going to guess that the “CaptivePortalTemp” entries are not related to students at my college. Other than that the one entry I changed to say “<College_Name>” was where the person actually named their wireless network to the name of the college, which couldn’t make it any more obvious that they go to the college. The campus is located close to a residential area, but a lot of these networks I picked up way too far away to be from non-college residences. Another point of interest is the unsecured print servers… I’m sure it would be quite easy for anyone to connect to those and, at the very least, waste someone’s paper. However, it might even be possible to get access to someone’s computer (assuming the printer allows more than one computer to connect at once) through the printer. I would hope the software the printer is running wouldn’t allow that, but who knows.

I would argue that there are probably at least 10 wireless networks that students from my college have setup that are unencrypted networks. This is, I believe, exactly what the college was trying to avoid by putting the wireless network policy in place. I can’t say there is really an easy solution to this problem, but I think if the college was willing to allow a wireless network after they educated the student on how to lock it down we would have less of a security problem on our hands than we do now. The best thing might be if the college just put wireless in all of the residences, but that costs money which they may or may not have to spend.

There were some networks that appeared to be run by college students that were encrypted, which is at least better than the unencrypted ones, but it still violates the college policy on wireless networks. I would love to have a wireless network myself because it would be nice for my laptop and for my Wii, but alas I will have to hold back on that. Seeing so many networks makes me wonder if the college actually checks for them because really all you would need is any old laptop that can scan for wireless networks.

People always ask me how easy it would be to scan for wireless networks on campus, and I guess the answer is all you need is ~30 minutes to write a perl script and the time it takes to walk around campus. I will walk around again after everyone has moved in and see if the situation changes at all. It should be interesting to see how many addtional networks I can find. Hopefully I have not given enough data for my college to use this to go after the people with these wireless networks because that was not the point of me doing this. I feel the college has every right to track them down, but they can do this on their own, if they are truly serious about their stance on student run wireless networks πŸ™‚ .

How I Shortened the ‘iwlist scan’ Output

August 4, 2008

Edit [03-04-2012]: I had a request (see comments) to include the channel and frequency. I added them, but unfortunately, I didn’t see a way toΒ  make the script output be 80 characters wide like the original. So, here are the two versions:

Additionally, now that I have looked at the code for the first time in a while, I must apologize for how poorly it is written :). After seeing what a mess I made the first time, I think I’d like to take a stab at cleaning it up and improving it a bit. So, hopefully, I’ll be able to write a more refined version in the coming months.

Edit [09-09-2012]: Updated link to script.

Edit [02-11-2009]: Updated the script to fix a small parsing bug.

In the past few years I have noticed that Linux has come a LONG way in support for wireless cards. I no longer read long stories about how 5 hours and 2 kernel patches later someone finally got their wireless card working.

In fact, I distinctly remember my first experience trying to get my wireless card to connect to a WPA network. It was my freshman year at college, and I spent almost an entire weekend digging through documentation, forum posts, config files, and google search results trying to get my laptop on the campus network through wireless. When all was said and done all I had was a script which was a simple bash script that ran all the commands I needed to connect. It had to be run as root (didn’t know about sudo) and it was a real hack. 3 and 1/2 years later and I simply boot up my laptop and it connects to any network I have predefined in my wpa_supplicant.conf file. I can walk around and it will automatically connect to new network, restores lost connections, etc.

One thing has always been a bit of a bother to me however. That is that the output of ‘iwlist scan‘ is quite lengthy. I can’t ever fit more than 2 wireless networks on a screen (unless I make my terminal super long)! Here is some sample output (MAC Address and actual network name hidden):

Cell 01 - Address: 00:00:00:00:00:00
   Protocol:IEEE 802.11bg
   Frequency:2.462 GHz (Channel 11)
   Encryption key:on
   Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
             11 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
            48 Mb/s; 54 Mb/s
   Quality=33/100  Signal level=-80 dBm
   IE: WPA Version 1
        Group Cipher : CCMP
        Pairwise Ciphers (1) : CCMP
        Authentication Suites (1) : PSK
      Extra: Last beacon: 36ms ago

I am not trying to start a flame war with the writers of iwlist. I think they have a very great tool, but sometimes I just want to know what networks are available in a simple form of output. So, since I had a bit of free time I decided to write a simple little perl script to grab the output of ‘iwlist’ and contort it until I got following output:

+ --- + ---------------------- + ------- + -------- + --- + ------ + --------- +
| #   | Name                   | Quality | Sig Lvl  | Enc | Enc T. | Auth T.   |
+ --- + ---------------------- + ------- + -------- + --- + ------ + --------- +
| 1   | "network 1"            | 39/100  | -77 dBm  | off | WEP    | N/A       |
+ --- + ---------------------- + ------- + -------- + --- + ------ + --------- +
| 2   | "network 2"            | 100/100 + -30 dBm  | on  | WPA v1 | PSK       |
+ --- + ---------------------- + ------- + -------- + --- + ------ + --------- +

So simply running my script will produce that nice, little, easy to read, fits-inside-an-80-character-terminal output. I am not entirely proud of all the perl code I used to write the script, but it works for what it does. I’m sure a true perl expert (which I am anything but) could have written it in under 10 lines, but hey, no one is perfect ;).

I often find myself torn when writing a short little utility script like this. I want to write good code, but I don’t want to spend all day writing a simple little script. I already took shortcuts in the form of using global variables, but I use function calls that only have one line of code in them. In retrospect I think it would have been smarter to just not worry about the functions, but it would take time to go convert it back to be functionless :-P. I will just have to live with the code for now, and be happy that it does what it does.

As another feature of the script it will give you the full output of a single network from the full ‘iwlist scan‘ output if you just specify the number of the network as a command line argument :).

Here is a link to the script, if you are interested: I had to post it as a .html file because apparently my school does not allow you to have perl files accessible from their apache server. No worries though. Some day I will have my own little web setup which I will manage and then I won’t have to worry about things like this πŸ™‚

Anyway, hopefully this perl script will come in handy for one or two people or, at the very least, give the perl guru’s something to make fun of :). That’s all for now!

Sidenote: Since it’s so short I didn’t bother to put it under the GPL, but come on… it’s a small perl script for an open source utility. Obviously for this script to work you must have iwlist on your system, and perl installed πŸ™‚

Python and public/private key encryption

July 5, 2008

Edit (7/20/08): If you are looking to get PyCrypto running under Windows with Python 2.5 I wrote a short guide located here . There are already installers for Python 2.3 and 2.4 on the PyCrypto Homepage

Edit (7/10/08): After noticing that this got some hits on google I rearranged the content so that the first part explains how I got public/private key encryption in python and the second part explains why I wanted encryption in the first place.

I was looking for an easy way to do public/private key encryption in python and I found it!

Enter ezPyCrypto! This package was actually able to generate and export a public key as a string AND import it back in. I should also mention that ezPyCrypto is merely a wrapper for PyCrypto. I have to say ezPyCrypto was quite uh… easy. Here is an example of how you would make a 1024 bit RSA key and export it to a string. It also demonstrates how to import that key and use it to encrypt a message:

from ezPyCrypto import key

myKey = key(1024) #defaults to RSA, 1024 is bits to encrypt with

#Just calling exportKey will export only the public key
publicKey = myKey.exportKey()

#print publicKey  

#Then to load it back in to a new key
myNewKey = key(0)

#Testing time!
testEnc = myNewKey.encString("cheesecake tastes yummy")

#You should see 'cheesecake tastes yummy'
print myKey.decString(testEnc)

Look at how easy that is! I am quite pleased that I will be able to continue my work, and have some good encryption. The one thing I will say is that ezPyCrypto does not seem like it has seen much development in a while, but oh well. As long as it works when it needs to I will not complain πŸ™‚ Also I only tested this with python-2.5 so your mileage may vary. On to the back story…

So today, among other things, I was looking for some good python libraries to do public/private key encryption. I am trying to write a few scripts that help with the administration of the computers I work on for my college’s internet radio station. I started out writing them all in perl, but now I have most of them written in python. Currently I have written a small backend which starts up the basic services that the radio station requires. At present that consists of: shoutcast server, darkice, a script to monitor the listener counts, and lighttpd. This backend is capable of accepting clients over the network and displaying the basic running status of all these services (IE: running or not). Now, I would like to add the ability to remotely control the services. Hence I would have to have some way of authenticating users who want to log in.

Lets take a step back here. Some of you might be wondering why I don’t just administer everything with ssh. Indeed, this is how I did it for a year, and for someone like me (I loves me a good terminal) this was not a problem. However, I have to face the reality that someone will probably take over the station (at some point or another) who is not at one with bash. This is why I decided to start this project to help ease them into administering the servers, which rarely die anyway. Python and the Tkinter libs were great for this because they would be fully cross platform. Although I hate to admit it, I think the next admin will probably be a Windows user. I think being able to run the server from their dorm will go a long way in helping them accept the job.

Back to the main problem. To authenticate I don’t plan to have anything too breathtaking. The backend will be run as a normal user and I plan to use PAM to authenticate against the user that is running the backend. So I need to be able to send the password over the network! There are plenty of guides to public/private key encryption and a quick google search will provide an explanation better than I will ever be able to give as to how they work. I was able to find a few options. The first is the PyCrypto package. This package seemed quite sufficient but the lack of reasonable documentation for it made me have second thoughts. This isn’t something I want to mess up because we are sending sensitive data across the network. I had a look at the source code but got tired of trying to make sense of it.

Next I found a package called yawPyCrypto (yet another wrapper for python crypto). That seemed quite promising. I was able to work out a simple example where it would generate a 1024bit RSA key pair, and I could encrypt and decrypt a string with it. Only one problem… I could not successfully export and import the string from yawPyCrypto. This meant the server would not be able to the send the client its public key… LAME. Again, I poked around the source code, but I didn’t see anything obvious, and I was not about to reinvent the wheel here.

Then I discovered ezPyCrypto, which as you read from above, solved all my problems πŸ™‚ I should also mention that on my Ubuntu machine I had to play around with the source code in ezPyCrypto to get it to import properly (remove references to variables it couldn’t find). Yeah… sounds stupid, but I was confident that what I was playing with was not related to public/private key encryption which is all I wanted.

I already fear that no matter how much I automate things there will be a problem. That is the way it goes however. I am hoping that I can polish off these scripts soon so I will not have to worry about radio station stuff until the beginning of the school year. I will most likely have more to say about these scripts and maybe a summery of everything I have done with them. That’s all for now though πŸ˜€

My first real experience writing user docs

July 4, 2008

So today at 10:00am I embarked upon my first real attempt at writing user documentation. Spheriosity has been long overdue for some good user documentation. After all, the whole purpose of the application is to help people understand spherical geometry, so if they can’t use it then the program is worthless.

I decided that the best choice for writing the documentation was going to be LaTeX my favorite text processing language. I fell in love with LaTeX when I saw how it could format mathematical equations with ease. I use it almost 100% these days and it makes the most beautiful looking documents! It is suited perfectly for a code oriented person like myself as well because at times it feels like I am programing the document more than anything. Perhaps I will write more about LaTeX some other time.

Also because of LaTeX I realized that I might be able to run latex2html on the document and thus have something I could post on the internet. I have never been a complete fan of the output of latex2html mainly because I think it should have an option to let you view an entire section at once. I’m sure that for some things it is quite nice that it splits up into subsections and then subsubsections if you use them, but for this it doesn’t translate well.

I found that I don’t really mind writing user documentation as much as I thought I would. It’s kind of like commenting code to me. I know a lot of people don’t really enjoy commenting, but it never bothered me much. I feel like it is taking the necessary steps to ensure another human, or possibly myself, will be able to some day figure out what I was thinking. After spending lots of time writing a piece of code it seems worth it to put in that extra effort. I feel the same way about documentation. If it is able to help even a few users work with my application then I consider it well worth the effort. So far I have created 28 pages of documentation. Now, it is not solid text because there are pictures of the program as I try to visually walk the user through certain steps.

I spent a good 10 or 11 hours writing the documentation and I need to take a break from it for sure πŸ™‚ Tomorrow will be a new day and I hope to finish the documentation and place the new alpha build on SourceForge. I don’t know if I could write user documentation all day every day, but it is good to know that I can do it when I need to. I admit that I felt a bit bad not writing any code all day (except a small perl script), but it was for a good cause.

I had a bunch of good ideas about things to write about today so hopefully I will have some material for the next few days. That’s it for today though… I need to get some sleep πŸ™‚