Playing with Acme::Eyedrops

Today I had some fun with Perl code obfuscation Acme::EyeDrops module makes it ridiculously simple to add new obfuscation shapes to your code. Basically all it involves is creating a file with a extension  *.eye and use it to obfuscate your code. There are around 95 existing shapes to choose from to obfuscate your code including the popular Camel shape. There are a few country specific maps as well e.g. one for Canada. I used a image to ascii converter to convert the map of India into two formats. One where the map is the overlay and another where everything except the map is on overlay. I have pushed my .eye files upstream so you might be able to use it as soon as the dev’s accept my pull request. If you are impatient you can download the India specific .eye files from my github repository and manually copy them over. Here is my first result from a “Hello World” perl script obfuscated with my eye map:   Shape => ‘india_map’ eval eval '"'. +( '['^'+'). ('['^')').('`'|')'). ('`'|'.').('['^'/').( '{'^'[').'\\'.'"'.("`"| '"').('`'|',').('`'|'!') . ("`"| '(').('{'^'[').('`'|'"').('`'| ',').(('`')| '!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+' ).('['^')').('`'|')').('`'|'.').('['^"\/").( '{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`' |'!').('`'|'(').('{'^'[').('`'|'"').('`'|',' ).('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+' ).('['^'+').('['^')').('`'|')').('`'|'.') .('['^'/').('{'^'[').'\\'.'"'.('`'|'"'). ('`'|',').('`'|'!').('`'|'(').("\{"^ '[').('`'|'"').('`'|',').('`'|'!').( '`'|'(').'\\'.'"'.';'.('!'^'+').("\["^ '+').('['^')').('`'|')').('`'|('.')).( '['^'/').('{'^'[').'\\'.'"'.('`'|'"' ).('`'|',').('`'|'!').('`'|'('). ('{'^'[').('`'|('"')).( ( '`')|',').('`'|'!').(('`')| '(').'\\'.'"'.';'.('!'^'+').( '['^'+').('['^')').('`'|"\)").( '`'|'.').('['^'/').('{'^'[').'\\' .'"'.('`'|'"').('`'|',').('`'|('!')).( '`'|'(').('{'^'[').('`'|'"').('`'|(',')).( '`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('[' ^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{' ^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`' |'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').( '`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').("\["^ ')'). (('`')| ')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.("`"| '"').('`'|"\,").( '`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'| '!').('`'|'(').('\\'). '"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.'). ('['^'/').('{'^'[').'\\'. '"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"') . ('`'|',').('`'|'!').('`'|"\("). '\\' .'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^('/')).( ('{')^ '[').'\\'.'"'.('`'|'"').('`'|',').( '`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.( '!'^'+' ).('['^'+').('['^')').('`'|')').('`'| '.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|('"')).( ('`')| ',').('`'|'!').('`'|'(').'\\'.('"'). ';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').("`"| (',')).( '`'|'!').('`'|'(').('{'^'[').('`'| '"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').(('[')^ '/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!' ).('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')') .('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"'). ('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[') .'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.("\!"^ '+').('['^'+').('['^')').('`'|')').('`'| '.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'| ( '(')).'\\'.'"'.';'.('!'^'+').("\["^ '+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`' |'"').('`'|',').('`'|'!').('`'|'(') .'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').("`"| '!').('`'|'(').('{'^'[').('`'|'"' ).('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'['). ( ( ( (( '\\'))))).('"').( '`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+'). ('['^'+').(('[')^ (( ')' ))).('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').(('`')| ',').('`'|"\!").( '`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!'). ('`'|'(').('{'^'[').( '`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'."\"".( '`'|'"').('`'|"\,").( '`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').('['^'+').('['^')').('`'|')').('`'|'.').( '['^'/').(('{')^ '[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|'!').('`'|'(').'\\'.'"'.';'.('!'^'+').("\["^ '+').( '['^')'). ('`'|')').('`'|'.').('['^'/').('{'^'[').'\\'.'"'.('`'|'"').('`'|',').('`'|'!').('`'|'(').('{'^'[').('`'|'"').('`'|',').('`'|('!')).( '`'|...

Setting up ArchLINUX on BeagleBone Black – Part 3 – Setting up I2C and PWM controller

This Article is a placeholder for work in progress and I will log my success as I go forward. ArchLINUX has proven to be the lightest of all the distros that I have installed yet on Beaglebone Black. I have already got all the basics up and running and now I am setting up my perl stack and I2C and PWM interfaces. Make sure you have followed my previous instructions for ArchLINUX here. List of Instructions for Archlinux Install base devel and include all the sub packages. This is needed for installing XS modules and its roughly equivalent to build-essential package on Ubuntu $ pacman -S base-devel Install i2c-tools $ pacman -S i2c-tools Now we can go ahead and install Device::SMBus. This is the interface that I released to CPAN for connecting to I2C devices, in the last release Device::SMBus 1.05 I removed some dependencies on board and distribution specific differences in i2c-dev installations, so it works without issues on both Raspberry Pi and BeagleBone Black , ubuntu,armstrong and archlinux installations. $ cpan Device::SMBus I use the LSM303DLHC for my work with LSM303DLHC Altimeter and Magnetometer $ cpan Device::LSM303DLHC Installing module for using LPS331AP Altimeter Barometer $ cpan Device::LPS331AP Installing module for using L3GD20 Gyroscope $ cpan Device::L3GD20 My two ways of controlling PWM on Beagelbone Black: External I2C PWM Generator like PCA9685: I have already implemented this method before on Raspberry Pi, Since we have already setup I2C on ArchLINUX above, using PCA9685 is quiet simple, and while I have not lokked into the fact if the BeagleBone Black has a seperate microcontroller with a clock for controlling...

Setting up ArchLINUX on BeagleBone Black – Part 2

so I have been trying to get my usual environment up on archlinux.first comes vim $ pacman -Syq vim $ pacman -Syq perl-moose There is a cpan package for easily maintaining CPAN packages on arch linux CPANPLUS::Dist::Arch, its a CPANPLUS backend for ArchLINUXhttps://metacpan.org/pod/release/JUSTER/CPANPLUS-Dist-Arch-1.28/lib/CPANPLUS/Dist/Arch.pod $ cpan CPANPLUS::Dist::Arch setup cpan to use us automatically $ setupdistarch Install Device::SMBus as a pacman package $ cpanp -i...

Setting up perl and cpan the usual way on Angstrom Linux

I have gotten so used to using super convenient the default setups on ubuntu  for perl that other flavours of linux are feeling increasingly user-unfriendly. After I have been forced to switch to Angstrom on my Beaglebone Black, I have been trying to get it up like I usually like my Linux. There are tons of things missing in stock Angstrom distribution of perl and it just doesn’t do things right. So I decided to write a little guide on how to remove the existing perl distro and build a fresh version from the source: $ opkg remove perl --force-depends --force-remove $ wget http://www.cpan.org/src/5.0/perl-5.18.1.tar.gz  $ tar -xvf perl-5.18.1.tar.gz $ cd perl-5.18.1 Update system time, Configure can cause problems if you don't do this step  $ date -s "7 DEC 2013 22:47:00" $ ./Configure -d prefix=/usr/local/perl Go get some cofffee, this will take a while. $ make Mix it up get some hot chocolate this time 🙂 $ make install That will get you your usual cpan app on command line. Now if you want to install cpanminus there are few more step than usual. Upgrade your wgt as Angstrom on BB ships with a version of wget older than what is supported by cpanminus. Specifically the option –retry-connrefused used by cpanm is not supported by older versions of wget. $ opkg wget $ cpan App::cpanmius This should get your cpanm...

Reverting back to Angstrom Linux on my Beaglebone Black

Today I flashed back the Angstrom Kernel on my Beaglebone Black Board. Ubuntu arm Linux kernel caused me some issues with my realtek rtl8192cu wifi dongle, I was not keen to spend much time resolving this so I switched to Angstrom linux. I am quiet used to the process now. Its basically the same process as installing ubuntu on the BB except in this case I burn angstrom on to the SD card instead. This is all a part of the hung up process for me moving my Perl Autopilot development for my quadrotor drone over to my Beaglebone Black Board since my Raspberry Pi is now busy serving as the media center for my TV. However good thing is that I don’t need to use the PCA9685 chipset for generating the PWM signals since the Beaglebone black has its own GPIO Pins which can generate the right Pulse for controlling the DC motors. I can also get rid of the the breadboard for the moment, which might even help me remove a portion of the frame I was using for mounting all these extras. This means I will have some weight reduction, yippee 🙂 I am still working with the algorithms for Getting the right orientation values, I am some distance away from getting all the sensor data for achieving a straight hover capability. Most of this because I had to suspend this project first for all my trips to Macau and Hong Kong and then for my trip to Canada and later all the work committments. I hope I can get something going by the end of this...

Talking to LSM303DLHC Accelerometer and Compass using perl and Device::LSM303DLHC

I bought a pololu’s AltIMU inertial measurement unit that includes among other things a onboard Accelerometer and Magnetometer in the form of the LSM303DLHC chipset. I decided to write down the steps I take to get it working with my Beaglebone Black and Raspberry Pi boards using perl, to help those who are trying to achieve the same. First follow the instructions to install Device::SMBus on Beaglebone Black if you have a Beaglebone Black, or instructions to install Device::SMBus on a raspberry Pi if you are using a Raspberry Pi board Then install Device::LSM303DLHC from cpan sudo apt-get install Device::LSM303DLHC then put this code in a file and save it as lsm303dlhc.pl : #!/usr/bin/perl use strict; use warnings; use Device::LSM303DLHC;  my $dev = Device::LSM303DLHC->new(I2CBusDevicePath => '/dev/i2c-1'); $dev->Magnetometer->enable(); $dev->Accelerometer->enable(); while(){   my $accelerometer = $dev->Accelerometer->getRawReading();   my $compass = $dev->Magnetometer->getRawReading();   print "\tACCELEROMETER: $accelerometer->{x}\t$accelerometer->{y}\t$accelerometer->{z}\t\tCOMPASS: $compass->{x}\t$compass->{y}\t$compass->{z}\t\n" ; } Run this file now, you will get the following result:     The code and these modules have been tested to work on both Raspberry Pi models and on Beaglebone black, and there is no reason why it wont work in other dev boards as long you have perl and the other dependencies for Device::SMBus on...

Setting up Device::SMBus on Beaglebone Black

Yesterday I managed to find time to setup debian on my Beaglebone Black. So today I am going about setting up Device::SMBus perl library on it so that I can start talking to my smart I2C devices through it. First step is ofcourse getting the dependencies in place sudo apt-get install libi2c-dev build-essential libmoose-perl I2C kernel modules are enabled by default on debian so we don’t need to enable them explicitly like we need to in Pi. On debian beaglebone black i2c bus doesn’t seem to support quick write so i2cdetect -y 1 does not work Instead I use i2cdetect -r 1 This should show you the list of i2c devices connected to your board. Next install Device::SMBus from cpan. sudo cpan...

Getting started with Device::SMBus on Raspberry Pi

A while back I wrote a perl library Device::SMBus to interface the plethora of I2C devices available with my Raspberry Pi board. I2C is a serial hardware bus invented by Philips that allows you to connect multiple devices to the same hardware pins and talk to them using their unique device addresses. http://en.wikipedia.org/wiki/I2C Device::SMBus builds on top of a standard linux i2c library libi2c-dev to talk to these class of devices. Each device on the bus is addressed using its standard device address, and the systems interacts with these devices by setting/reading appropriate control registers and translating that information. It was recently made aware to me that it is not straightforward using perl’s Device::SMBus library with raspberry PI. It has a chain of dependencies that needs to be properly documented from start to end to make it easy to people who try to use it: I use model B Pi with Adafruit 16 Channel PWM Servo Controller PCA9685 among other devices. You must have four servos or ESC -> Brushless motors connected to channel 4,5,6,7 for testing your I2C code using the PCA9685. I have also interfaced to other I2C devices like L3GD20 Gyroscope, LSM303DLHC accelerometer and magnetometer, LPS331AP Altimeter. which may also be used to test this module if so desired. I have writter the perl modules for these devices as well. All three of these chipsets are available on Pololu’s AltIMU board, however these chipsets may also be available on other boards by themselves. Device::L3GD20 Device::LSM303DLHC Device::LPS331AP I will skip over the hardware setup guide as that is not the purpose of this manual and there are enough...

The simpler way to installing Perl modules using Aptitude

So somebody asked me this recently, and I have been suggesting this as a quick install method for perl modules if getting the latest module is not a necessity. The modules in ubuntu or debian repositories are often the ones that are thoroughly tested out and well maintained so it can be a good benchmark for selecting the module you might want to use. Its also quicker to install a perl module this way compared to using cpan or cpanminus as it skips many steps like pre-install unit tests etc. Suppose I want to install CGI::Application I use the following command sudo apt-cache search perl CGI::Application 2) It will return the package name as below: libtitanium-perl 3) Now I can install this module by following command: sudo apt-get install libtitanium-perl   If the cpan module you regularly install is not  in the debian or ubuntu repository, it might be a good idea to install dh-make-perl and build .deb files straight from cpan modules and keep them aside for future...

Perl and optimal programming standards

Perl is one of those languages you have to be very careful with when developing large scale applications. Personally I use a couple of tools when writing perl code to clean up after me. PerlTidy (http://perltidy.sourceforge.net/) is my favourite tool for formatting and nicely indenting all my perl code.pod2html is another popular tool useful for generating quick HTML documentation from all your perl code. before I start with this article, here is another perl joke :)No offense intended :p perl -e ‘$a=”etbjxntqrdke”;$a=~s/(.)/chr(ord($1)+1)/eg;print $a’ PS: Type that on your command line 😉 One of the things that we love most about Perl is its flexibility, itssimilarity to natural language, and the fact that There’s More Than One Way To Do It. Of course, when I say we” I mean Perl hackers; the implicit them” in this case is management, people who prefer other languages, or people who have to maintain someone else’s line noise. Perl programmers tend to rebel at the idea of coding standards, or at having their creativity limited by arbitrary rules — otherwise, they’d be coding in Python :). But I think that sometimes a little bit of consistency can be a good thing. As Larry himself said in one of his State of the Onion talks, three virtues of coding are Diligence, Patience and Humility. Diligence (the opposite of Laziness, if you’re paying attention) is necessary when you’re working with other programmers. You can’t afford to name your variables $foo, $bar, and $stimps_is_a_sex_goddess if someone has to come along after you and figure out what the hell you meant. This is where coding standards come in handy.  The verbosity of all...