Archive for July, 2012

Version 2 of small perl mechanize script to send sms from danish telco provider Bibob

Thursday, July 26th, 2012

A year ago I wrote a small perl Mechanize script to send sms from the command line (very useful for scripts) utilizing the web-sms service you get as a Bibob customer.

Now a year later I actually found some use for it, but it didn’t work anymore due to the fact that Bibob had changed their website since then. And not just the graphics and layout, but the whole shebang.

I have made some very small changes to the perl script to make it work again and I appriciate the versatility of perl and that the Bibob webmasters obviously thought a great deal about the upgrade.

The new code can be downloaded here, hbut is also included verbatim in this post

#!/usr/bin/perl -w

##############################################################################
#
# File:         bibob_sms.pl
# Type:         bot
# Description:  Send an SMS using bibob websms and perl mechanize
# Language:     Perl
# Version:      2.0
# License:      BeerWare – Thomas S. Iversen wrote this file. As long as you
#               retain this notice you can do whatever you want with this
#               stuff. If we meet some day, and you think this stuff is worth
#               it, you can buy me a beer in return. Thomas
# History:
#               2.0 – 2011.07.26 – New version due to total bibob.dk relayout
#               1.0 – 2011.07.28 – Intial version
#
# (C) 2011,2012 Thomas S. Iversen (zensonic@zensonic.dk)
#
##############################################################################

use strict;
use WWW::Mechanize;
use File::Basename;

# Variables controlling bot behaviour

my $sms_url=‘https://www.bibob.dk/min-konto/web-sms’;
my $login_url=‘https://www.bibob.dk/’;

my $script=basename($0);
die "$script <bibob mobile number> <bibob password> <recipeient number> <message>" if(!($#ARGV+1 == 4));

my $username=$ARGV[0];
my $password=$ARGV[1];
my $recipients=$ARGV[2];
my $message=$ARGV[3];

#
# You should not need to alter anything below this line
#

#
# Main code.
#

# Create mechanize instance
my $mech = WWW::Mechanize->new( autocheck => 1 ); #Create new browser object
$mech->agent_alias( ‘Windows IE 6′ ); #Create fake headers just in case
$mech->add_header( ‘Accept’ => ‘text/xml,application/xml,application/xhtml\+xml,text/html,text/plain,image/png’ );
$mech->add_header( ‘Accept-Language’ => ‘en-us,en’ );
$mech->add_header( ‘Accept-Charset’ => ‘ISO-8859-1,utf-8′ );
$mech->add_header( ‘Accept-Language’ => ‘en-us,en’ );
$mech->add_header( ‘Keep-Alive’ => ’300′ );
$mech->add_header( ‘Connection’ => ‘keep-alive’ );

# Get login page
$mech->get($login_url);
$mech->success or die "Can’t get the login page";

# Submit the login form with username (mobilnumber) and password
$mech->submit_form(with_fields => { ‘phoneNumber’ => $username, ‘password’ => $password });
$mech->success or die "Could not login";

# Get sms page
$mech->get($sms_url);
$mech->success or die "Could not get sms page";

# Send sms by submitting sms form
$mech->submit_form(with_fields => { ‘recipients’ => $recipients, ‘message’ => $message });
$mech->success or die "Could not send sms";

# Figure out status
my $html = $mech->content();
die "Form submitted, but message does not appear to be sent" if(!$html=~/Beskeden blev afsendt/ig);
exit 0;

Setting up an TP-Link TD-8616 ADSL modem with TDC

Sunday, July 8th, 2012

I got tired of my zyxel P660R-D1 due to it rebooting once in while. I went looking for an replacement ADSL to ethernet box. The Zyxel is a full blown router, but why use that when I already have an Linksys E3000? Looking around I found the P-Link TD-8616 ADSL modem, which sells for around $25.

To set it up was very very very easy:

  • Plug it in.
  • Configure my laptop with at static ip of 192.168.1.2.
  • Connecting the laptop and the TD-8616 back to back.
  • Browsing to 192.168.1.1
  • Altering the VCI/VPI to 0/101 to match TDC
  • Browsing the web interface of my E3000
  • Using the mac address clone feature, giving the E3000 the mac of the old zyxel router
  • Renew the lease of the E3000.
  • All done.

I’ll reserve my final judgement until I have seen the stability, but the setup was easy enough and until know it performs quite nicely with 40% of the power that the zyxel needed.