Letter to Parliament re Section 92

In response to the proposed Section 92 of the Copyright Amendment Act … feel free to write one of these yourself, it’s free!  Also, check out the NZ Creative Freedom Foundation.

Rt. Hon Steven Joyce
Minister for Communications and Information Technology
Care of Distribution Services
Parliament Buildings
Wellington 6160

Dear Steven,

I am writing to you in urgency regarding the proposed Section 92 of the Copyright Amendment Act that assumes guilt upon accusation, forcing the termination of internet connections and websites without evidence, a fair trial, or punishment for false acusations of copyright infringement.

I work for a web development company and cannot let this “roll over” into law without voicing my protest. To know that any one of our clients, or indeed ourselves could be falsely accused without proof required and have our internet access terminated would have dire ramifications as our livelihoods and futures rely on providing these services.

I urge you to carefully consider the ramifications of the proposed Section 92 and speak out on behalf of myself and others who have contacted you regarding this.

I am available for further comment if required.

Yours Sincerely

Bob Brown
Web Developer
(my address)
Dunedin

The mind of a web developer

While in the supermarket today I did a double take when I saw some “PHP Sauce” on the shelf next to me.  Of course, upon closer inspection I realised my folly.  I guess I can’t take a day off work without work chasing down my subconscious!

PHP tutorial - introduction to classes

You might have noticed that I’ve migrated this blog to Wordpress - the main reason for doing so was to give me the ability to easily add pages to the blog so that I could keep my web dev tutorials in one place.

I’ve also just added the introduction to classes tutorial so go and check it out.

Gettin’ hacked

I had an email this morning only five days after my billing cycle started saying that I was close to using my 15GB of data. Normally we spend about 5-10GB, but 15GB in five days is exceptional.

I started digging and after ruling out intentional upload/download from inside my network (using wireshark on my LAN segment) I then started looking at the wireless side of things. I have a server on my LAN that is connected via wireless, and this is also a public facing server with sshd running on it.

I had a quick page through the /var/log/auth.log file and to my surprise I found repeated attempts to log in with various usernames (491 different ones so far) from various locations. These were coming in at the rate of one every four seconds. I can’t see how this would account for 15GB (or 1.5GB for that matter) but when I called Orcon they said they saw a definite increase in traffic over the last two days, which also corresponds to the first entry in the auth.log file.

Here’s what the log entries look like:
Sep 27 13:29:59 pandora sshd[17366]: Failed password for invalid user oracle from 60.190.133.228 port 45662 ssh2
Sep 27 13:30:03 pandora sshd[17368]: Failed password for invalid user michael from 60.190.133.228 port 45857 ssh2
Sep 27 13:30:07 pandora sshd[17374]: Failed password for invalid user ftp from 60.190.133.228 port 46079 ssh2
Sep 27 13:30:12 pandora sshd[17376]: Failed password for invalid user test from 60.190.133.228 port 46301 ssh2
Sep 27 13:30:15 pandora sshd[17379]: Failed password for invalid user webmaster from 60.190.133.228 port 46553 ssh2
and so on …

The requests have come from a range of IP addresses in China, Europe, Canada and Bangladesh. It’s likely to be a distributed and targeted attack.

Interesting. I did install fail2ban some time ago which I was told was supposed to prevent this kind of thing but it was an install-and-forget excercise. I’ll have to research it a bit to find out how it actually works.

Screen recording with Linux

Hello to my future self - I’ve anticipated that I will be back in the future to read this post because I’m sure I would have forgotten how to do this stuff. Firstly, a disclaimer - I am by no means an expert in this field, I just banged it ’till it worked. If you are having trouble doing similar things then I encourage you to post comments where they can be seen and responded to by all.

Secondly, an explanation of what it is I’m doing here. A while back I saw some screencasts re Inkscape at screencasters.heathenx.org. I was impressed - it was a great way to teach people how to use Inkscape.

I had a play around and managed to get to the point where I can now do the following:

  • Record my screen, or any particular window
  • Use my Logitech USB headset to record the audio
  • Play the resulting movie back, sound through speakers or headset

For some reason I seem to be having a ridiculously hard time determining where the audio output goes for my Linux apps. In Windows, when I plug my headset in, it becomes the default audio device for all applications. Currently running applications still use their normal sound output, until restarted. If I dig deep enough I might even be able to find settings in each program that allows me to specify which sound device (headset or sound card) should get the output.

In Linux (Ubuntu 8.04, Gnome to be precise) I discovered under System > Preferences > Sound an application that allows me to adjust the sound preferences. In the dropdown list for each playback type I have seven possible playback device options (Auto, USB Audio, Intel ICH5, Intel ICH5 - IEC958, ALSA, OSS & PulseAudio). It seems that if I set them all to USB Audio then I get lucky and most things play through the headphones. Some things, especially the Adobe Flash Player plugin insists on playing through my desktop speakers regardless. I saw someone complaining that this was Adobe’s fault, not Linux but I can’t comment. In order to avoid all this confusion I found out how to specify the sound device that you want to use for each operation. This is pretty much the crux of this post.

Anyway, here’s what I did …

Recorded My Desktop

There’s a package in the Ubuntu universe repository called recordmydesktop which as the name suggests can be used to record your desktop, with sound. This is great for making recordings of how to do things to share with others. I installed the recordmydesktop package, along with the GTK front end to save me having to look up the commands all the time..

bob@sparkie:~$ sudo apt-get install recordmydesktop gtk-recordmydesktop

Once installed I then hit Alt-F2 (to bring up the Run Application dialog) and typed in gtk-recordmydesktop.

It seemed that by default it was trying to record sound via the mic input on my sound card. Fat chance it would have had because I don’t have a mic in my soundcard, instead I have a USB headset.

After Googling around I discovered that if I click the Advanced button in gtk-recordmydesktop I could then enter the sound device to use to capture audio. I used the device name “plughw:Headset,0,0″ and was able to record sound via my USB headset.

The key to this was finding out what to type in for the device name. I discovered the aplay and arecord utilities that allow you to play and record sound. Each utility has a -l switch which lists the available devices. Here’s the output of my arecord -l:

bob@sparkie:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: ICH5 [Intel ICH5], device 0: Intel ICH [Intel ICH5]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 1: Intel ICH - MIC ADC [Intel ICH5 - MIC ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 2: Intel ICH - MIC2 ADC [Intel ICH5 - MIC2 ADC]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH5 [Intel ICH5], device 3: Intel ICH - ADC2 [Intel ICH5 - ADC2]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

You can see beside each “card” there is a device name, either ICH5 (my sound card) or Headset. Each of those cards has a number of subdevices - in the case of the sound card you can see there are four possible subdevices I could have chosen (numbered 0 to 3) and for the headset it’s a free ride because there’s only one to choose from (as I would have expected).

So, now that plughw:Headset,0,0 should make a bit more sense. With that all set up, I hit record, wiggled my mouse around, spoke some gibberish and created a .ogg file of my session.

Sound Recording and Playback

While I was debugging my sound devices I fiddled around a bit with arecord and aplay. Using the command arecord -Dplughw:Headset,0,0 -f S16_LE -c2 -r44100 > myfile.wav I created a 44kHz wav file using the headset mic as my recording device.

When I played it back with aplay myfile.wav, it played through my desktop speakers. To play it through my headset I just specified the device name as I did with the arecord command, thus aplay -Dplughw:Headset,0 myfile.wav

If you want to use mplayer to play something back using a specific device for audio output, this command will do the trick for you: mplayer -ao alsa:device=hw=1.0 ep069.flv. Device 1.0 is card #1, device 0 - and that’s the headset.

If you need to adjust the volume, I found you can use the alsamixer. To control each card you can specify which one with the -c switch. In my case card 0 is the default and internal sound card, and card 1 is the USB Headset: alsamixer -c 1

That’s all for now!

HTTP Monitor Script for Bash

If you run a web application, or want to know when a web server goes up or down. There’s a range of products you can use to do this, such as Nagios (URL monitoring is only one aspect of server monitoring that Nagios can perform). There are times however when configuring a full blown monitoring system like Nagios is way over the scope of what you want to do right now.

Here’s a script I use to monitor URL’s. I put this in my cron to run every 5 minutes. It only emails you when the HTTP status of the URL has changed since last time you requested it. This should avoid heaps of emails in your inbox, unless you have a bouncy server.

#!/bin/bash
# Simple HTTP monitor script
# Monitors a URL and sends an email when the status of it changes

NOTIFY_EMAIL=youremailhere@yourdomainname.com

if [ -z $1 ]; then
  echo Usage: $0 url_to_monitor
  echo Example: $0 http://www.google.com/
  exit 1
fi

URL=$1
STATUS_FILE_PREFIX=.`echo $URL | sed -s 's/[\/\.:]/-/g'`
RESULT_TEXT=`HEAD $URL | head -n 1`
STATUS_FILE_SUFFIX=`echo $RESULT_TEXT | sed -s 's/ /-/g'`
if [ ! -f $STATUS_FILE_PREFIX.$STATUS_FILE_SUFFIX ]; then
  rm "$STATUS_FILE_PREFIX.*" > /dev/null 2>&1
  touch $STATUS_FILE_PREFIX.$STATUS_FILE_SUFFIX
  echo $URL returned $RESULT_TEXT | mail -s "[$0]: $URL returned $RESULT_TEXT" $NOTIFY_EMAIL
fi
exit $RESULT

This should work on a stock Ubuntu/Debian system. To actually use this script:

  1. Save the above as monitor.sh in your favourite directory.
  2. Edit it and change the NOTIFY_EMAIL address to your own
  3. chmod u+x monitor.sh
  4. Invoke it like this: ./monitor.sh http://www.google.com/

What you do with it is up to you. Note that to track the status this script will create hidden files in the current directory. For example, if Google returns a 200 OK status, a hidden file called .http—www-google-com-.200-OK will be created.

←Older