Welcome!

Hello! I'm Defron and this is my blog.

Data Privacy Day: Passwords

Part One in a five-part exposé for Data Privacy Day

Data Privacy Day: Smartphones

Part two in a five-part exposé for Data Privacy Day

Data Privacy Day: Web Browsing

Part three in a five-part exposé for Data Privacy Day

Tuesday, February 26, 2013

Inconsiderate Behavior

I thought today was going to be a good day: completely over the flu I had caught, night class was canceled, and my work load wasn't large (despite taking the majority of last week off)... I was mistaken.

When I check my work email I see the usual day-to-day emails, but one caught my eye. It was from my Spiceworks install and the title read "C: has less than 5% remaining on [one of the work servers]"... heart sank. Goodbye care free day, hello hellish day full of trying to figure out what's going on.

I turn to the server (running Windows Server 2003R2). I've always been well aware of the storage problems of the C:\ partition on this. This wasn't the first time the C:\ had filled up, in fact. Back when I first started working, it filled up due to an out of control program producing a five-mile long error log. The system, like most in the office, predate me. It was bought through a "value-added" retailer. The VAR decided it was a good idea to partition C:\ to only have 12 GiB of free space. I probably should have done something about it back then, but it being a Windows Server 2003 server, there's no integrated option to shrink one partition and expand the other. Budget was, as always, $0 and uptime was considered critical, so I freed up 4 GiB of space and called it a day. Of that, last week (some 3 years later) I had 2 GiB free space remaining. The server didn't ever really get any new software installed beyond security updates and I ran her lean and mean to reduce the chances of some log file going crazy. As I saw it, the remaining 2 GiB of free space would last me to this summer, where I planned to finally shrink the D:\ partition and expand the C:\ partition. It won't make it to then due to some inconsiderate behavior of an outsider.

A company, which will remain nameless for now, decided it was OK for them to do an automatic update of their software without telling me. Not only did they not tell me, they didn't announce it at all ahead of time, even on their website. The software also doesn't have the option to disable automatic updates and the fact that it can do automatic updates isn't even a listed feature. The software in question uses Microsoft SQL Server for the backend. Why? I dunno. I guess they thought that was a good idea (I disagree with that conclusion); it didn't use a SQL backend two revisions ago. Part of the upgrade included a forced upgrade to MS SQL Server 2008 (We were on MS SQL Server 2005)... That might be acceptable if I lived in an ideal world where I had each server only do a single role, but I don't because I don't have that kind of budget, working for a small business. The server in question was an archive server for patient records, and that functionality also used MS SQL Server. The update also required .NET Framework 4.0, which I had no need for up to then, so I didn't have it installed (free space being a premium, after all).

None of this would have been a problem, had I been given prior notice  of the update. If I was told ahead of time that this update was coming, I could have done something about it, and there would be no issue. Instead due to the company's inconsiderateness, I find myself with... 85 MB of free space on the C:\ partition.The .NET Framework update was also still running and complaining about a lack of free space (obviously). I had to cancel that.Next step is getting me some breathing room and call the company up. They give me the usual company blah about it, don't even apologize for not telling me about the upgrade beforehand. Told me they couldn't revert the upgrade so my only option was to clear up the space myself or uninstall the software.

Uninstalling it is very tempting, but I'll need to get my boss's approval before I can do that. In the mean time, I have a good feeling that the software is hosed and useless. The services related to it wouldn't start up, so I disabled them, crippling the software to dead status anyway, so at least it's not a further threat. I scavenged for free space and was able to get back to a bit over 800 MB. At least now it won't fail over from a single hiccup. That'll buy me the time to defrag the other partition (which is running smoothly so far, but since it was an archive server, still has a ways to go), shrinking it, and expanding the C:\ partition. If my boss doesn't approve some money spending, that'll mean downtime as I boot off GParted to shrink. I'll expand the C:\ partition with extpart from Dell so Windows get too grouchy.

A number of factors lead to the current situation, but the one thing that definitely shouldn't have been the case and would have made the world of difference is if I was told about this major upgrade beforehand so I could prepare for it.

At least Spiceworks is doing its job properly.

Thursday, February 14, 2013

Blog Status Update

It's been about a week and a half since my last blog post, so I thought I'd fill everyone in on what's going on. I knew this would happen eventually, but was hoping I'd have been able to post a bit more before it does.

I'm juggling school, work, this blog, and a few other projects right now. At the beginning of the semester it wasn't an issue, as school work wasn't very demanding. Now, though, school work is requiring more and more of my time. I'm a straight-A student and would like to maintain that, as such I need to focus on my studying and so had to cut back on my blogging. On top of that I got sick and am going back and forth to the dentist, taking up even more of my free time. Oh, and my first midterms are the next two weeks.

I definitely won't be able to continue a post a day like I did for that little bit, but I am going to try to do one or two posts a week. I have plenty I'd like to post about, but it's too time consuming to do so right now. In the immediate future, though, this blog is going to be running at a lower priority than I'd otherwise put it at. It's school, work, one of my other projects, and then this blog. Hopefully in two week's time, I will be able to pick up the pace again, though. Until then, I might be able to accomplish one a week, we'll see.

I'm still getting my feel for blogging, too, so it's definitely not worked out in my schedule. In the mean time we'll just see how this all goes.

Sunday, February 3, 2013

Wake-on-LAN

Wake-on-LAN is one of those technologies that I love, and one I think doesn't get enough attention. I guess it's a bit geeky still.

The actual technology is a hard to understand if you've never done any networking, but basically it works on layer-2 (MAC addresses) only. It sends the magic packet to everyone (broadcast), but only the intended device says "Oh, that's for me" and turns on the PC it's attached to. I always found it funny that it's called a magic packet. The "magic" part was fitting before I had a better grasp on networking, but, incidentally, now that I do understand networking better, the "packet" part makes less sense (since it uses layer-2 Ethernet frames, not IP packets). You can read up more about the technical side over at Wikipedia.

Wake-on-LAN Setup

In order to implement Wake-on-LAN you need to meet a few requirements:
  1. You need to use a wired (Ethernet) connection. There is a Wireless implementation known as WoWLAN, but it doesn't have much market penetration and even more requirements than WoL.
  2. Your BIOS/UEFI needs to support Wake-on-LAN (not all do)
  3. Your NIC needs to support Wake-on-LAN (not all do)
  4. Your OS needs to support Wake-on-LAN so you can manage it (AFAIK, all modern ones do)
To this day I regret the fact that I didn't consider support for WoL when building my current PC. I will never again build a PC that doesn't support Wake-on-LAN. MeetGadget allows you to sort by motherboards with this feature supported. Don't make my mistake in buying a motherboard that doesn't support it if you love WoL, as you will regret it.

BIOS implementation varies from one system to another. It's usually under power settings and something along the lines of "LAN wake-up" "Power on LAN" or something along those lines. Sometimes Wake on PCI and the like can be used, but those are usually for if using an separate PCI device (like a PCI NIC) to send a wake-up command.

If you don't find one of those options in your BIOS, your BIOS probably doesn't support the feature. It sometimes becomes available in a later version of your BIOS, but not usually.

Your NIC either will or will not support it. There's not much you have to do here. Really all you can do is verify it support Wake-on-LAN, which is done most easily by checking the documentation for your NIC.

On the Software/OS side, you'll need to tell the device it's ok to respond to Wake-on-LAN (and thereby allow your PC to turn on). I once was beating my head for hours because I thought I had configured this, but hadn't and the PC was refusing to turn on.

On Windows this is done by launching

devmgmt.msc

Then select "Network adapters" and right-click on the NIC you are using. Select Properties


Click on the advanced tab. The options may be different depending on your NIC, but for Realtek NICs, the option is usually called "Shutdown Wake-On-Lan". Make sure that is enabled. You should also make sure "Wake on Magic Packet" is enabled. Other names I've seen are "Network Wake-up" "Wake on Magic Packet" and other variations along those lines.


Now head over the the Power Management tab and make sure "Allow this device to wake the computer" is checked. Optionally check the box below it about allowing only magic packets to wake it up (otherwise the device may respond to any ethernet frame directed at it instead of particularly to magic packets).


On linux, you'll use a tool called ethtool, here's Debian's official documentation of it.

On Mac OS X, at least on Snow Leopard, it was:

System Preferences -> Energy Savor panel and make sure "Wake for network access” is selected.

Sending WoL Packets

Now that the system is all set up, you'll probably want to do all sorts of cool stuff with it. While WoL itself is layer-2, most tools that send the packet will operate on Layer-3 and 4 (usually using UDP packets to encapsulate the magic packet).

wakeonlan is a command-line Linux tool that I use (it's also available for Mac OS X via Macports). You should be able to pull it from you repos. The majority of wired computers at my work support Wake-on-LAN due to my concentrated efforts in making sure they do. I often do remote work at night on the computers, doing this and that. I just ssh in, turn on all the PCs with wakeonlan, and then control them through various methods, primarily ssh-tunneled RDP (as most are Windows 7/XP Pro computers). I like to imagine the look on someone's face if they were in the office and all of a sudden all the computers around them started powering up.

Two Windows tools are MC-WOL, which is a command-line tool. I like to script WoL sends, so command-line tools like this one and wakeonlan for Linux are useful to me. If you want a GUI, though, there is WOL - Magic Packet Sender.

You can send WoL packets from DD-WRT/Tomato and the like too. From the webGUI and command line. More importantly, you can set it up so incoming packets will automatically cause the router to send a WoL packet to your device. Very useful for sending WoL when outside your LAN. You can then turn your PC on from anywhere with an Internet connection

iPhones can send Wake-On-LAN via Mocha WOL. Unfortuantely Apple in their infinite "wisdom" doesn't allow for this to be automated on certain external events.

Android has two big options PcAutoWaker and Wol Wake on Lan Wan.

PcAutoWaker will allow for your phone to automatically send a magic packet on connecting to a wireless network. Imagine this if you would: You just pulled into your drive way, and by the time you get in the house your PC is already fully booted up. Now that is a beautiful thing to me.

Wol Wake on Lan Wan isn't as cool out of the box, but has some useful features: you can set up widgets for your devices to make sending magic packets easier, and even better: it can be incorporated in Tasker/Locale very easily. This allows for one very interesting thing: Sending WoL packets when your alarm goes off in the morning (note: I don't know if Locale has a similar event trigger). Imagine if you will, your alarm goes off. You're groggy and either hit snooze or turn it off and start getting up. In either case, by the time you reach your PC, it's already booted up. Ah, how wonderful.

That's why I love Wake-on-LAN: it allows for two things I love: saving power (leave PCs off and just turn them on remotely when you need them) and automation (I don't turn on my PCs, they're automatically turned on based on my actions). It's a beautiful thing, it's a simple thing, and it makes my life easier and more environmentally friendly. What could you possibly not like?

Saturday, February 2, 2013

Locking Down wifi on Windows without Active Directory

This is a cool trick I've learned recently, and it doesn't seem easily found through Google (but if you know of netsh, you may be able to discover it).

Windows management is best done through group policy, or at least most easily done through it. In fact, you can blacklist/whitelist wifi networks via group policy for Windows Vista+. The problem is that it's only available via AD group policy, not local group policy. At work I don't have Active Directory (but am hoping to by the end of the year), so I can't use this. Still, I'd like to block wifi networks on our wifi-enabled Windows computers. My desire for this came from the fact that someone in the office thought it'd be all right to take a laptop without permission for the purpose of working on public wifi during lunch. As a rule,  laptops shouldn't be just taken without properly being checked out, but sometimes people just think something not-ok is OK. Luckily the person didn't end up using the laptop on who-knows-what public wifi network, but it was a close call and made me look into this.

I found out it was possible with a couple of ye olde netsh commands. I'll show them off on my crappy laptop with a dead battery that I never use because I hate laptops (maybe I'll go into that another time). Before firing them off on my laptop, Windows saw these wireless networks:


Donnerschlag is my wireless network, so let's make it so that's the only option for this laptop to connect to. Open up the command prompt as administrator:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\windows\system32>netsh wlan add filter permission=denyall networktype=adhoc
Followed by:
C:\windows\system32>netsh wlan add filter permission=denyall networktype=infrastructure
That will block all wireless connections, let's see what Windows says:


Looking good, but now I need to add my whitelisted connections:
C:\windows\system32>netsh wlan add filter permission=allow ssid=Donnerschlag networktype=infrastructure
Aaaaand now:


Success! Here's some other useful netsh commands for wireless networks:

Show current filters:
netsh wlan show filters
Which returns something like:
Allow list on the system (group policy)
---------------------------------------
    

Allow list on the system (user)
-------------------------------
    SSID: "Donnerschlag", Type: Infrastructure

Block list on the system (group policy)
---------------------------------------
    

Block list on the system (user)
-------------------------------
    SSID: "", Type: Adhoc
    SSID: "", Type: Infrastructure
You may want to blacklist just certain wireless networks, this is done by setting the ssid as appropriate and permission to block
netsh wlan add filter permission=block ssid=somewifinetwork networktype=infrastructure
There's also the ever-important delete filter command. syntax after netsh wlan delete filter needs to match the same syntax you used to add that filter.

TechNet Library for Netsh wlan

Friday, February 1, 2013

Colors, Coding, and Consoles!

Who doesn't like alliteration? After sharing how I got prettify the way I wanted, I thought I'd share some of my other color and font schemes schemes.

Fonts:

When it comes to writing code and consoles, nothing beats monospace fonts in my book. When you're staring at code, a good monospace font can make all the difference. There are a few monospace fonts I love:

  • DejaVu Sans Mono (Download) is by far my favorite monospace font that I've ever used and my current font scheme for Console2, Windows CMD (when possible and where Console2 not installed), Notepad++, Linux terminals, and PuTTy. The only two things I'm not overly thrilled about DejaVu Sans Mono is the @ sign and i. I'd rather have the ones from Monaco.

  • DejaVu Sans Mono has two sister fonts: Menlo and Bitstream Vera Sans Mono. I only recently found out about Menlo (while setting up Prettify.js -- see my last article) because it's Mac OS X-only. There is a derivative font of it called Meslo that you can get from GitHub. I've not used it personally. Bitstream Vera doesn't have the same character support of DejaVu Sans Mono, just an FYI. To see a comparison between DejaVu Sans Mono and Menlo, go here

  • Monaco is a really nice font and I envy the @ sign and lowercase i from it. Overall I prefer DejaVu Sans Mono, though. It's a good all-around monospace font.

  • Anonymous Pro is an upgraded version of Monaco that takes better advantage of ClearType, for those who like it. I keep meaning to give this font a real run-down, but haven't yet. It looks really promising, though.

  • Consolas was the first awesome monospace font Windows has shipped. The one problem is that it absolutely has to have ClearType/subpixel rendering to be useable, as without it, the font looks like crap. Be aware of that if you don't like ClearType on while coding.

  • Inconsolata is a font based on Consolas. It does a better job at handling being displayed without ClearType/Subpixel rendering, but the @ sign is worse in my book, and it still doesn't do a great job.

  • Crystal is another really nice monospace font. I, as with Anonymous Pro, just haven't given it a proper chance.

  • Droid Sans Mono is a font from Google created for Android. It's actually a really nice all-around font and I really like it except for one thing: the 0 and O are hard to distinguish since the 0 doesn't have a slash or a dot in the center. If it wasn't for that one thing, I think it'd replace DejaVu Sans Mono as my font of choice. If that doesn't bother you, I highly recommend this font.

Coding:

I do almost all my coding in Notepad++ or in a commandline text editor over SSH. Since I'll include my SSH color schemes in the console section, I will only bother with NotePad++ here.

I personally use a slightly modified version of Obsidian, which is a theme included by default.

First I, naturally changed the font to DejaVu Sans Mono. This is done by going settings-> Style Configurator


I made two changes to the coloring. I manually edited the xml file for the font and changed all instances of fgColor="E0E2E4" to fgColor="BBBBBB". It's a big pain to do this through the style customizor, and much faster to use Notepad++'s "Replace All" functionality after opening up obsidian.xml. The other is I changed the background color to be a bit darker. This can be done in the Style Configurator. Just change the background color to RGB 45,45,45 (#2d2d2d, but you can't use hex). and make sure to check "Enable global background color" (see above). The end result is:

Which I think is very nice. I recently found out about Tomorrow Night Eighties (which I use on here for prettify.js) and Tomorrow Night exists for Notepad++. I've been thinking about modifying it to look like eighties and using it instead of Obsidian, but haven't done so yet.

Consoles

Windows command prompt offers basic changing options.

To change the color right-click the top and select properties, then go to the "Colors" tab.

As you can see, I use a background color of RGB 32,32,32. I use a text color of RGB 187,187,187. The popup text is what you see if you press F7 with the command prompt open. It's the old-school way of pulling up your command history. I never use this, so I never bothered coloring it.

For the font, I use DejaVu Sans Mono as the font when possible. Changing the font to the likes of DejaVu Sans Mono in the native cmd on windows requires a registry edit. Here are some instructions. Note: You don't need to reboot. A simple log-out is sufficient. On Windows 7, you don't even need to do that: just close all open command prompts and when you open a new one, the option to use DejaVu will be available. Reg:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont]
"000"="DejaVu Sans Mono"

I find that the font cannot be changed if you have certain nonunicode language settings. That was the case to me (Japanese is my nonunicode language).

   

An alternative wrapper for the windows CMD is Console2. I actually recommend Console2 over CMD anyway as it offers many more nice features liked tabbed terminals, can also run powershell, and better resizing and copy/pasting. You can download it from SourceForge, just make sure to download the 64-bit if you use 64-bit Windows. Once again, I use RGB 32,32,32 for the background color and RGB 187,187,187 for the text color and DejaVu Sans Mono for the font. You change the font and font color on Edit->Settings->Appearance. The background color under Edit->Settings->Tabs->Background. I also use the xterm cursor with RGB 164,240,79 as the color.

 Finally there is putty. Putty is a bit of a pain to configure color-wise, because it uses the registry instead of a simple config file.

Anyway, my configuration is as follows (Note: don't forget to save the configuration after making the changes!):

Font = DejaVu Sans Mono , Font size: 10px.
Default Foreground = 187,187,187
Default Bold Foreground = 163,163,163
Default Background = 32,32,32
Default Bold Background = 85,85,85
Cursor Text = 32,32,32
Cursor Colour = 147,199,99
ANSI Black = 28,28,28
ANSI Black Bold = 85,85,85
ANSI Red = 215,85,90
ANSI Red Bold = 223,117,125
ANSI Green = 115,185,115
ANSI Green Bold = 147,199,99
ANSI Yellow = 251,194,0
ANSI Yellow Bold = 225,222,89
ANSI Blue = 103,140,177
ANSI Blue Bold = 124,168,211
ANSI Magenta = 188,122,188
ANSI Magenta Bold = 187,134,223
ANSI Cyan = 91,205,215
ANSI Cyan Bold = 64,150,236
ANSI White = 187,187,187
ANSI White Bold = 215,215,215

End result? It's not perfect, but near close in my book (some of the colors are a bit closer than I'd like, and Cyan is still a bit of a pain):



All in all, I'm pretty happy with my colors and fonts. It makes prolonged use of the console and long coding sessions much more pleasant than the default settings, IMO.