Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Asterisk Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds

Posted by Admin • Tuesday, October 5. 2010 • Category: Asterisk
One of my asterisk setups got attacked recently by a brute force script kiddie. The attack is simple:
  1. Try sequential sip usernames from 1 to 10000, hoping that the admin chose a numeric username scheme
  2. If asterisk returns anything but a 401, then perhaps this is a real account, add it to the list
  3. If anything is on the list of "possibles", then brute force their passwords


Why this works:
  • Asterisk has no delay for failed logins, so a brute force attack is viable, hundreds of attempts per second are possible. Not sure what can be done about this
  • The admin didn't set alwaysauthreject = yes in sip.conf. It's off by default, why??? With this enabled, there is no way to tell if a username is valid from the reject response


To deal with this:

Continue reading "Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds"

Nvidia X Driver stops working in Ubuntu Lucid 10.04

Posted by Admin • Monday, July 26. 2010
In the hopes of fixing my periodic keyboard-gets-stuck issue, I upgraded to the latest and greatest kernel (2.6.32-24-generic), as suggested by the helpful Ubuntu upgrade tool. I should mention that the machine is a Dell Precision M4400 (it's a laptop, sort of). I was then greeted with a "Your display is messed up, you're in low-res mode" dialog. Running the nvidia configuration tool yields:

"You do not appear to be using the NVIDIA X driver. Please edit your X configuration file (just run `nvidia-xconfig` as root), and restart the X server."


Great. Now I'm down to one monitor. The nvidia driver won't load. Reinstalling it won't work. Setting this aside for a bit I attempt to start VirtualBox - and I get the same issue! - The kernel driver isn't loaded. OK so this must be a DKMS issue. I reinstall the virtualbox DKMS module:
 sudo apt-get remove virtualbox-ose-dkms
 sudo apt-get install virtualbox-ose-dkms


But that doesn't help, though it yields a hint: Kernel source is not available. Apparently the trusty ubuntu updater installed the new kernel but not the kernel headers for it! My Kernel is: uname -a
Linux akomgen3 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:20:59 UTC 2010 x86_64 GNU/Linux
So:
sudo apt-get install linux-headers-2.6.32-24-generic
Now I can remove and reinstall the dkms packages for virtualbox and all the nvidia packages, and all is good again

Reviews Motorola Droid X Battery Life woes may not mean a defective battery

Posted by Admin • Monday, July 26. 2010 • Category: Reviews
Last week my wife replaced her Blackberry Storm2 (9550) with a shiny Droid X, and was relieved to find that the Droid kept up with her insane usage load just fine - whereas the Storm2 would lock up every few minutes (probably memory or garbage collection issues). That's the good news. Unfortunately, the X introduced a new problem - battery life. With her usage, it lasts 4 hours. The Storm2 lasted 24 or more. Granted it's a bigger display, but the specs promised ... well, a lot more than 4 hours.

We theorized that it may be runaway processes and excessive number of apps, or defective battery, but as it turns out it's neither. This is what I did:

Continue reading "Motorola Droid X Battery Life woes may not mean a defective battery"

Linux Verizon Wireless tethering Ubuntu Karmic to a Storm 2

Posted by Admin • Friday, April 2. 2010 • Category: Linux
This topic is fairly well described, so this is just a quick how to for me. (This is for USB, I am not attempting bluetooth this time) UPDATE: I now use berry4all instead of the below. It just works, and there is a GUI


Old Way:

  1. sudo apt-get install libbarry0 barry-util barrybackup-gui
    Chances are you already have the first two in a karmic install, and you may not even need barrybackup-gui. I did not need to add any new apt repositories
  2. if the phone requires a password, edit /etc/ppp/peers/barry-verizon and change the pty line to read
    pty "/usr/sbin/pppob -P My_Password"
    Yes there is a password line in that file, but it doesn't seem to do anything, and I don't know how to use variables in a pppd script :-)
  3. sudo pppd call barry-verizon
    You should see the progress and the IP's relevant to the connection. If you're having trouble, add debug:
    sudo pppd debug call barry-verizon
Note1: In my experience, after I kill the pppd connection I can't reconnect until I momentarily unplug the phone. Also, mass storage mode is not necessary.

Note2: These steps should be similar for most providers. Look at /etc/ppp/peers/barry-* to see the predefined provider scripts.

Note3: I believe that the connection will fail miserably if you have any other network connection active on the PC besides the tethered phone.

Note4: I am posting this using my blackberry!

Low Tech Hacks Snowblower oil change with no mess

Posted by Admin • Sunday, March 21. 2010 • Category: Low Tech Hacks
Like most dutiful snowblower owners I change the oil in the spring. The manual says to change it every 25 hours - I don't put that many hours on the engine in a year but the oil probably shouldn't be kept in there that long.

The first year I did the oil change I wound up with a 4 foot oil puddle on my garage floor. Like most small snowblowers, mine has an extension oil drain pipe with a cap. You're supposed to unscrew the cap and drain the oil into something. Well, mine unscrewed at the base - the whole pipe came out, pouring oil down the machine's body and causing me to bring shovelfuls of sand in to clean up the mess. But, there is a better way. (And this is my notepad for next year)

Continue reading "Snowblower oil change with no mess"

Linux Postfix satelite mail configuration with special needs

Posted by Admin • Monday, February 15. 2010 • Category: Linux
OK so I have special needs. (Either that or I am just oblivious to a working example of this).

My needs are:
  1. Do not receive inbound mail
  2. Do not deliver mail locally at all
  3. Send all outbound mail through an upstream relay (ISP's smtp)
  4. Qualify local addresses with a valid domain name (ISP's smtp will reject invalid domains)
  5. Map some local addresses to convenient aliases (distribution lists in the real mail system - google apps in this case)


Doesn't seem so hard, right? So I started with the postfix "Satelite System" option in ubuntu installer, and then...

Continue reading "Postfix satelite mail configuration with special needs"

Linux Software RAID in Ubuntu Karmic 9.10

Posted by Admin • Monday, February 15. 2010 • Category: Linux
I am writing this down because it was somewhat hard to figure out how much of the HOWTO's out there are out of date. This is not particularly difficult, but it's my first RAID setup and this blog is my notepad. I am setting up a RAID1 on a Dell Precision 490 with two brand new 500GB SATA drives.

First I tried using BIOS RAID. My system doesn't have a true RAID controller card and after some trial,error and googling I decided to forget it and go with an industrty standard (MD) Linux software RAID. I reset my drives to non-raid in the BIOS, popped in Ubuntu server x64 CD and went on ahead.

Continue reading "Software RAID in Ubuntu Karmic 9.10 "

Linux MySQL replication dies with ERROR 1201 (HY000): Could not initialize master info structure

Posted by Admin • Friday, February 12. 2010 • Category: Linux
On a fine happy morning I am greeted with an alert that slave is not running. Running start slave yields this:
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
Enabling the log yielded nothing. Googling yielded This Page that helped me a lot, but I didn't have to do quite as much work all over again. Here is what I did.

Continue reading "MySQL replication dies with ERROR 1201 (HY000): Could not initialize master info structure"

Code and Hacks Splitting a large image to print on multiple sheets

Posted by Admin • Wednesday, December 23. 2009 • Category: Code and Hacks
This really seems like such a simple task, doesn't it? All I wanted was to print a large (48 megapixel) raytraced image I generated onto several pages, and then tape them together to make a poster.

In my efforts to find a convenient tool to do this, I've attempted the following:
  • Kinko's: (or any neighborhood print shop). I am listing this option because it eliminates the need to do this altogether - they can print an image on a huge poster all at once. This 'should' work, and is probably the best but most expensive option. In my experience, Kinko (Fedex) simply could not receive the image, perhaps they can't handle large uploads.
  • Online Printers: You are probably seeing some options in the google ads on this page already. Of course, I wanted it right now, so that was not an option
  • Rasterbator: A great tool, but not what I need. It creates nice looking multi-page PDF's from low-res images by using the old school newspaper graphic dot approach.
  • Adobe Illustrator (CS3): It seems to have a "print on multiple pages" option in the print dialog, but I've tried every single setting, and it always loses about a 1/4" off the sides, making them un-stitchable. Maybe I'm just Adobe-dumb. Illustrator also insisted that I trust it to manage the print colors rather than trust my printer (a solid-ink Phaser), and the printouts came out practically all brown until I told it to trust the printer. It easily wasted $30 of solid ink before I gave up on Illustrator
  • Photoshop: It can be done. Easiest way is to add guides (view menu) using percentages (eg 50%, 25%, as needed), then select the area between guides (snaps to guides), and copy into new images. This is labor intensive, but if you're careful with mouse movement you should get the right pieces. If you're printing on a small quantity of sheets, this is the best option probably. You can also paste each copied sliver into the same second image - you will then retain any options you've set for that document (such as layout, color quality, etc). Maybe there is a plugin for photoshop that does this automatically?
  • Gimp: Apparently there is a poster plugin of some sort, but in my haste to get this out the door I didn't have the time to understand how to install/compile/use Gimp plugins
  • ImageMagick: This is what I ultimately used. Being a command-line tool it doesn't have a nice visual "layout and split" interface. But what it does have to offer is reliable operation, unix style - one thing, done right. Read more for details on how, below.
  • PDF: What I have not tried is to use the ImageMagick approach above, then auto-convert each image into a PDF and stitch them into one document so they can be printed all at once. I'm not sure if this can be done (easily). If I have to do this again, I'll look into this. (Update: This is no longer necessary, see Geeqie note below)

Continue reading "Splitting a large image to print on multiple sheets"

Hardware Hacks D945GCLF fan issues and alternatives

Posted by Admin • Saturday, December 12. 2009 • Category: Hardware Hacks
I've had my D945GCLF (the Intel Atom 230 board) up for 440 days. That's an impressive uptime until you realize that it's a Gentoo box running asterisk, mpd, and not much else. As anyone familiar with D945GCLF or D945GCLF2 knows, the northbridge has an aluminum heatsink with a 40mm fan. Most people have had theirs fail right away, but I was lucky enough to have mine last over a year before starting to vibrate and slow down. Once I started getting Nagios alerts about high temps, it was time to do something.

I never liked the idea of small fans. A 40mm sleeve bearing wonder is certainly no exception. When it comes to cooling, I always look for big and slow - and that in my book means 120mm running at 7V speeds. I looked for a replacement fanless heatsink but couldn't find one that was reported to fit. Here is what I did:

Continue reading "D945GCLF fan issues and alternatives"

Code and Hacks Upgrading Belkin F5D7231-4 v2000 router to dd-wrt firmware

Posted by Admin • Monday, November 23. 2009 • Category: Code and Hacks
As the dd-wrt hardware database claims that this router is supported, I was happy to attempt this installation. Only the micro edition will fit on its tiny 2MB of flash. The dd-wrt page suggests that only tftp flash procedure will work, and so I grabbed their tftp.exe - to no avail. This router seems to have a lot of upgrading threads dedicated to it, but most of the How-To's I was able to find did not work for me. Some said that in order to get the firmware to load on this device you need to catch the perfect second during its reset cycle where the ping TTL's (you have to ping it) are 100, and launch the tftp upload at that exact time. I was never able to achieve any part of this.

Fortunately after nearly giving up I found this thread which offers alternate (windows only) utility called "Sercomm" to load an alternate (I'm honestly not sure where it came from) .bin image onto the router - I can only assume that it's the dd-wrt image converted to sercomm format. The image you get from dd-wrt will not work with this loader. I loaded this yesterday (2009/11/22) and got the latest (dd-wrt v24 SP2) on my router, and it even works great (so far).

That said, there is one caveat to the instructions provided in the Readme.txt file: I first loaded the dd-wrt image (two are provided: dd-wrt and original Belkin), and the router failed to reboot or respond. I then loaded the Belkin image, it worked correctly as per instructions. Then I was able to load the dd-wrt image successfully. Naturally the IP address changed to 192.168.1.1 instead of 192.168.2.1

Linux Disabling X server autostart (gdm) on Ubuntu Karmic (9.10)

Posted by Admin • Monday, November 16. 2009 • Category: Linux
There are many reasons one may wish to do this - running their desktop installation as a sever (temporarily perhaps), solving some video issues... or just doing it to get that facet of control back. I, for instance, prefer to run X with "startx" when I'm ready to do so. I do not enjoy a black screen when the latest intel video driver doesn't work - I'd rather Ctrl-Alt-Backspace and fix it.

Anyway, so Karmic (and apparently certain installs before Karmic, as well) uses an init system called "Upstart". If you've tried messing with update-rc and noticed that disabling /etc/init.d/gdm doesn't work, this is why. Oh sure, you can run /etc/init.d/gdm stop, but it's only temporary, assuming that works for you at all - for me it does not - my console does not recover and I get a black screen.

To get it to stop permanently the proper way is apparently to work with upstart. You'll notice some definitions in /etc/init (no, not /etc/init.d). These work somewhat like the Gentoo init.d scripts - you can define dependencies, events, phases, etc. So looking at /etc/init/gdm.conf I see:

Continue reading "Disabling X server autostart (gdm) on Ubuntu Karmic (9.10)"

Linux Upgrading to Ubuntu 9.10 Karmic Koala breaks X (xorg) on intel driver on 945G chipset

Posted by Admin • Monday, November 2. 2009 • Category: Linux
After upgrading my IBM desktop with "82945G/GZ Integrated Graphics Controller" X stopped working entirely, regardless of any changes to xorg.conf. Running startx manually revealed an error like this:

(EE) Failed to load module "i810" (module does not exist, 0)
(EE) open /dev/fb0: No such file or directory
(EE) intel(0): [drm] Failed to open DRM device for : No such file or directory
(EE) intel(0): Failed to become DRM master.


Took me a little while to figure out how to get me my machine back:

Continue reading "Upgrading to Ubuntu 9.10 Karmic Koala breaks X (xorg) on intel driver on 945G chipset"

Linux Backing Up Google Docs automatically from Linux

Posted by Admin • Monday, October 26. 2009 • Category: Linux
I'm not quite sure why a working example of doing this is so hard to find!

As far as I can tell, at the time of this writing there are two choices of ready-made (and free) apps that do this: GDocBackup and php-google-backup, a tiny php script (on google code) that uses Zend libraries. The former is a windows binary and is said to run in Mono. The latter is a php script which currently partially works (can't handle spreadsheets or PDF's). Not wanting to run Mono (an emulator - I might as well write this in Java), and not satisfied with only backing up .doc's and presentations... I hacked up my own.

Here is how I did it

Continue reading "Backing Up Google Docs automatically from Linux"

Linux Getting Pidgin to sign off when you lock your screen

Posted by Admin • Wednesday, October 14. 2009 • Category: Linux
I am signed in to google talk from many places - blackberry, laptops, desktops, etc - and every once in a while, IM's don't go to the right one. Since I lock my workstation at the office whenever I get up, I figured it'd be nice to have Pidgin log off at the same time.

I am not sure how you would do this in Windows, but in Linux (Ubuntu in my case), I did it like this:

Changed my screen lock hotkey (Ctrl-Alt-l for me) to run the following:
xlock -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"
That's it. If you want specific screensaver modes you can stick them in them too:
xlock -mode blank -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"

Update: July 2012


Ubuntu has a broken version of xlock (1:5.31-1) which gets the BadMatch (invalid parameter attributes) error. I switched to using slock from "suckless-tools" package, like so:
bash -c "purple-remote setstatus?status=offline ; slock ; purple-remote setstatus?status=available"

Interestingly, after running slock, xlock works too.. it's actually related to dpms: If you run xset +dpms, xlock will work (once).
You can adjust the xlock version for this bug as follows:
xlock -mode blank -startCmd "xset +dpms ; purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"


PS: Doing this in openbox:


<keybind key="C-A-l">
        <action name="Execute">
                <startupnotify><enabled>true</enabled><name>Run</name></startupnotify>
                <command>xlock -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"</command>
        </action>
</keybind>