Happy new year everyone!

Posted on the December 30th, 2009 under Uncategorized by admin

I hope that all my friends and family will have a better new year than 2009. So here’s to 2010!

Adventures and Geekery on an Acer EasyStore H340

Posted on the October 19th, 2009 under Linux by admin

So I bought this nifty little Intel Atom based NAS-like device. The only problem is that it runs Windows Home Server out of the box and contains no easy way of installing a simple Linux based distribution to get things like ZFS (or ZFS-FUSE) or Linux software RAID working. Well, you can do it by installing Ubuntu on it on another computer and then making a few tweaks and then transplanting the hard disk back into this little machine. I tried, it works, but is slightly time consuming. My experience was that after Ubuntu wouldn’t run any daemons on startup so I spent a good hour trying to understand what the heck was going on. After almost giving up, I blindly typed in my username and password and then ran the SSH daemon (e.g. /etc/init.d/sshd start). Voila! That worked so I could at least get into it and can actually fix things. So to remedy whatever bizarreness was going on, I installed rcconf and disabled and re-enabled all the required daemons and everything was now fine even after a reboot. So that was that.

Next up was the another annoying aspect and limitation of this box. It had only 4 drive bays. Since I didn’t want to waste a whole drive bay on an installation of a rather simple installation of Ubuntu, I wanted to see if I can substitute a USB stick with all the necessary packages and utilize all 4 bays for storage. Well, disaster struck here again. The machine only booted from USB if there were no HDs in the bays or a reset switch was pressed at the back. But how do you permanently change boot priority on a machine that had no video output? The answer to this is that you could build or purchase a cable that hooked on to a 26 pin connector on the motherboard. Slight annoyance here was that building a cable wasn’t exactly easy nor cheap for that matter. An enterprising individual sells pre-made cables for around $100 or so dollars since that option seemed more reasonable than purchasing a crimp tool, and all other necessary parts to build a cable, I decided to go ahead and bite the bullet, i.e. I placed a purchase order.

Another option was to purchase a PCIe X1/X4 video card since the machine had a PCIe slot, but this, again, was not a very tenable option. These cards are almost impossible to find locally and not cheap either. There was also no guarantee that the card would actually function. The option to purchase a pre-made cable looked much better at this point.

Anyhow, I knew about these limitations before I bought the box so I shouldn’t really complain all that much. All this annoyance gave me an idea of building a Linux distribution that contained everything I needed:

  • Apache
  • HellaNZB or SABNZBd (for News Groups)
  • Transmission BitTorrent Client
  • FTP Server (I don’t really need this but nice to have)
  • Apple File Protocol or netatalk

Now, I am aware that FreeNAS has a lot of that functionality, but is FreeBSD based and not all that updated. So let me know if you’d be interested in willing to help test such a simple Linux based distribution that booted off of a USB stick. Let’s see how far I get with this.

My ideas thus far:

  • Use Arch Linux
  • Use larch to build a live/USB bootable disk
  • Some sort of a basic PHP based user interface to add/remove packages and do configuration
  • Email notification of disk full scenarios and/or other hardware issues
  • ZFS support through ZFS-FUSE
  • Software RAID0/5/etc.

Transparent Bridging Firewall

Posted on the August 15th, 2009 under Linux, Technology by admin

Finally got my transparent bridge up and running. It’s sole purpose in life is to provide QoS (Quality of Service) based prioritization of my VoIP traffic. An added bonus is to provide a snappier web surfing experience if there is other traffic running in the background. All this is being done using the very excellent pfSense. It rocks!

If you want to set one up as well, go here. But to read up more on it, refer to this excellent article.

Affinity Data Extractor

Posted on the August 4th, 2009 under Linux by admin

For those that read underground computer magazines, especially the coded ones, here’s a tool to exact some of the goodies contained with in the .EXEs and .DATs.

You can download here: aftx.pl

Linux User Logon Script

Posted on the July 17th, 2009 under Linux by admin

Here’s a short script in Perl that checks which users have not logged in over 5 days. I wrote it to run automatically via cron and send emails to users reminding them that their inactivity paste 5 days (for example) will cause their account to be locked and then deleted (e.g. past 10 days). Hope someone finds it useful:


#!/usr/bin/perl

$wtmpx_file_loc = "/var/log/wtmp";
@type=("Empty","Run Lvl","Boot","New Time","Old Time","Init","Login","Normal","Term","Account");

$templ = "l";
$template = "i i A32 A4 A32 A256 i i i2 l4 A20";
# 1 2 3 4 5 6 7 8 9 10 11
$recordsize = length(pack($template,( )));
$records = length(pack($templ,( )));

open(WTMP,$wtmpx_file_loc) or die "Unable to open wtmpx: $!\n";
@users = `egrep -i 'bash' /etc/passwd|awk -F":" '{print \$1}'`;

chomp(@users);

my %user = (
$id => { $lastlog => '' }
);

while (read(WTMP,$record,$recordsize)) {
($ut_type,$ut_pid,$ut_line,$ut_id,$ut_user,$ut_host,$ut_exit,$ut_session,$ut_tv,$ut_addr_v6,$ut_unused)=unpack($template,$record);
if ($ut_user eq "") { next; }

if ($ut_tv > $user{$ut_user}{$lastlog}) {
$user{$ut_user}{$lastlog} = $ut_tv;
}

# print "ut_user=$ut_user ut_host=$ut_host ut_tv=$ut_tv"."\n";
}

#$user{'hfarrell'}{$lastlog} = time() - 24*60*60*5;

$today = time();

foreach $key (@users) {
$diff = $today - $user{$key}{$lastlog};
printf "%-15s - %-25s", $key, scalar localtime($user{$key}{$lastlog});

$days = time() - $user{$key}{$lastlog};
my ($sec, $min, $hour, $day,$month,$year) = (localtime($diff))[0,1,2,3,4,5,6];

if (!defined $user{$key}{$lastlog}) {
print " ** NEVER LOGGED ON";
} elsif ($days > (5*(24*60*60))) {
printf " ** DID NOT LOG IN THE LAST 5 DAYS--OVER BY %d DAY(S)", ($days/(24*60*60));
}
print "\n";
}

SevenSegment class for Arduino

Posted on the July 3rd, 2009 under Arduino by admin


// SevenSegment Multiplexing by Farhan Yousaf <farhany AT me DOT com>
// Use freely.
//
void setup()                    // run once, when the sketch starts
{
for (int i=1; i < 13; i++) {
pinMode(i, OUTPUT);
}
}
byte digits[10][7] = {
//  a, b, c, d, e, f, g
{ 1, 1, 1, 1, 1, 1, 0 }, //0
{ 0, 1, 1, 0, 0, 0, 0 }, //1
{ 1, 1, 0, 1, 1, 0, 1 }, //2
{ 1, 1, 1, 1, 0, 0, 1 }, //3
{ 0, 1, 1, 0, 0, 1, 1 }, //4
{ 1, 0, 1, 1, 0, 1, 1 }, //5
{ 1, 0, 1, 1, 1, 1, 1 }, //6
{ 1, 1, 1, 0, 0, 0, 0 }, //7
{ 1, 1, 1, 1, 1, 1, 1 }, //8
{ 1, 1, 1, 1, 0, 1, 1 }  //9
};
class SevenSegment {
public:
int _digit;
int _startpin;
int mode; //cathode or anode
void display(int digit);
void setPins(int start_pin);
void clearDisplay();
SevenSegment(int start_pin);
void selectLED(int pin);
};
SevenSegment::SevenSegment(int start_pin) {
setPins(start_pin);
}
void SevenSegment::setPins(int start_pin) {
for (int i=start_pin; i < (start_pin+7); i++) {
pinMode(i, OUTPUT);
}
_startpin=start_pin;
}
void SevenSegment::clearDisplay() {
for (int i=0; i < 7; i++) {
digitalWrite(_startpin+i, !LOW);
}
//delay(3);
}
void SevenSegment::display(int digit) {
for (int i=0; i < 7; i++) {
digitalWrite(_startpin+i, !digits[digit][i]);
}
delay(3);
}
void SevenSegment::selectLED(int pin) {
for (int i=1; i < 5; i++) {
digitalWrite(i, LOW);
}
digitalWrite(pin, HIGH);
}
void loop() // run over and over again
{
SevenSegment digit(6);
digit.selectLED(1);
digit.display(7);
digit.selectLED(2);
digit.display(6);
digit.clearDisplay();
}

Posted on the June 17th, 2009 under Academic by admin

I have decided that a lot of what I worked on for my undergrad University days is of no use to anyone unless it is released. While I don’t provide gurantees of how good some of the essays, powerpoint presentations and other documents will be — one thing will be sure: It’s out there! I hope people find them useful, and if they are citation worthy, to give me credit. Nevertheless, overall goal is to release this information to the general public.

Today’s release is a Power Point I had written for one of my undergrad security classes at Ryerson on the Melissa virus. Be sure to read the notes section for additional details notes.

ITM420 – Anatomy of a Virus (Melissa)

Covert AACs to MP3s

Posted on the June 7th, 2009 under Linux by admin

A very simple bash script to use in Debian/Ubuntu to convert AAC (M4A) files to MP3. This will work only with unprotected DRM-less AACs. Great for use with your shiny GPS device that can play MP3s.

#!/bin/bash
#aac2mp3.sh

for i in *.m4a; do
ffmpeg -i "$i" -acodec libmp3lame -ac 2 -ab 256k "${i%m4a}mp3";
done

Note that you’ll need ffmpeg and libmp3lame installed, e.g.

apt-get install libmp3lame0
apt-get install ffmpeg

Hosting your own content

Posted on the June 6th, 2009 under Site News by admin

One of good friends has been running his own mail, file, blog, and other services by hosting it on his servers at home. I always wanted to do the same, but it took a few years to learn enough to be able to do it myself. So far, it’s great to be able feel free from all the commercial hosting companies especially when my demands aren’t very “commercial” or high volume.

I should write a short primer on how to do this? Maybe.

Moved!

Posted on the May 21st, 2009 under Uncategorized by admin

I have successfully moved my blog to a non-commercial host. Let’s see how well it works.