Happy national day dear Singapore :)

shantanubhadoria 09-08-2014 22:23:44

Its been close to 3 years since I made Singapore my home but I never got time to post on this blog about it. Its been a awesome experience all through, I have seen beautiful spots around the island, come to know amazing people and made some lasting friendships. This is without doubt my favourite island in the world and its my home. 

So here is taking time out to wish my singaporean friends a happy national day!!

Cheers!!

  • Singapore

Setting up fail2ban for my servers

shantanubhadoria 08-08-2014 04:36:29

In view of increased attacks on my server from Ukraine and China I decided to harden the security on the server.

After normal blocking of unused ports using the firewall, one of my favourite tools to do this job is fail2ban.

The way fail2ban works is it scans your log files to look for suspected intrusion attempts or attacks and blocks the offending source. While it provides lots of sources for scanning standard log files like ssh etc. If you have a custom webapp you might have to write your own custom configuration to prevent website attacks. This is much better than using website constraints to block offending users as it prevents offending IP addresses from contacting your server entirely using the iptables instead of showing a not allowed page.

To configure fail2ban, the first thing you must do is look at your webapplication logs and then note down the error message thrown by your webapp when a login attempt fails. i.e try to login with a invalid account in your website and see the error message thrown. If your app does not throw a message you will need to add some logging in your code to make sure it throws a message containing the source IP address of the user. In my case the error message is simple :

Failed login from <ip address>

Create a filter appropriate filter file

vim /etc/fail2ban/filter.d/shantanubhadoria.conf

enter the following in the file:

# Fail2Ban shantanubhadoria.com filter
[Definition] 
failregex = Failed login from <HOST>
ignoreregex =

You can add more than one regex for conditions other than authentication failure to ban people from your site. Use your imagination!!

cp /etc/fail2ban/jail.conf to /etc/fail2ban/jail.local

vim /etc/fail2ban/jail.local

add the following at the end of file

[shantanubhadoria]

enabled = true
port = 80
filter = shantanubhadoria
logpath = /var/log/shantanubhadoria.log
maxretry = 6

Restart fail2ban service 

service fail2ban restart

  • fail2ban
  • Security

Script kiddies trying to mess around here . . .

shantanubhadoria 08-08-2014 01:32:44

I have been noticing a lot of script kiddie attacks from Odessa, Ukraine on my site recently. Especially from a individual going by alias seoer0724.

Attacks are now blocked, and attempts to break in were not successful in the end but I will be more cautious in keeping an eye out on my servers.

  • Script Kiddies
  • Security

Learning Blender - Building a Tank

shantanubhadoria 17-06-2014 10:29:44

I am still trying to pick up more skills with Blender in my evenings. I have been working on this sketch for a Battle Tank modelled on a Indian Army tank called the Arjun. There is still a lot not in place including the tracks. I have also looked at this graphics engine called Unity 3D which lets you rig up a game or a walkthrough using blender models and some scripting and rigging. Perhaps I will be able to create something interesting soon?
In the meanwhile enjoy my incomplete tank here : 

 

    MBT Arjun - In Progress     by shantanubhadoria     on Sketchfab

  • 3D Modelling
  • Blender

Giant Moth Invasion

shantanubhadoria 06-06-2014 07:40:04

Saw this Giant Moth in the appartment corridor today. It apparently belongs to Tropical Sallowtail Moth family. There has been a large number of these making appearances in Singapore recently. They have even been in the news, so here is a pic for everyone :)

 

  • Blog
  • Singapore
  • Tropical Sallowtail Moth

Teaching myself Blender

shantanubhadoria 01-06-2014 02:13:17

Today I was watched Rio again and I decided to learn some 3d modelling. I am not sure how it will ever be compatible with my existing skill sets(Perhaps it can help in my quadcopter project?). I am just starting with the basics,

I picked up a free and surprisingly effective 3d modelling software made for linux called Blender.

I created a tiny animation with my name on it. The text breaks up into small cubes and dissolves away. The steps are straight out of one of the blender tutorials. I messed up the dissolving away part but you will probably not notice it in the video.

 

  • 3D Modelling
  • Blender

Create your open source report card (From github)

shantanubhadoria 14-04-2014 20:09:30

Found this interesting tool to generate a funny but cool story for your developer habits and preferences. It seems to pull the developer profile data from github. Anyone can enter their github profile name to generate their own story.

http://osrc.dfm.io/shantanubhadoria

  • Github

Playing with FreeSwitch

shantanubhadoria 28-01-2014 01:10:24

Today I have started playing around with freeswitch to explore the possiblity of using it as a tool for secure audio routing.

Wikipedia: 

FreeSWITCH is free and open source communications software for the creation of voice and messaging products. It is licensed under the Mozilla Public License (MPL), a free software license. Its core library, libfreeswitch, is capable of being embedded into other projects, as well as being used as a stand-alone application.

More updates soon . . .

  • FreeSWITCH

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

shantanubhadoria 14-12-2013 19:50:51

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 PWM or it generate a "software PWM", if its the latter, there are obvious benefits to using a external PWM generator like PCA9685. Since I already bought this PWM microcontroller when I was building a quad on the Raspberry Pi, I might go ahead and use it again with BeagleBone Black if it proves to be a better option for performance.

TO use PCA9685 with perl simply install Device::PCA9685 on your BB and connect your PCA9685 to the I2C Pins like I do. There are other ways to do it without using perl but I won't go into that unless I need it. To look into syntax details of how to use Device::PCA9685 look up the documentation for Device::PCA9685 on metacpan

$ cpan Device::PCA9685

Onboard PWM Pins on Beaglebone Black:

BeagleBone black uses a internal clock in its arm335x CPU to generate a PWM on its 8 or so PWM pins. The way to use this is to set the internal registers in the CPU using /dev/mem to trigger the high and low in the PWM signal at the correct moment as required. I will probably write a perl library to maipulate these registers directly from perl for using OMAP335x CPU to achieve the desired PWM signal. 

Stay Tuned . . .

UPDATE: All PWMs are not created equal

I have done my research and I realised that all PWM outputs are not created equal when it comes to the Beaglebone Black. Essentially the black has 

  • Two independent PWM outputs with dual-edge symmetric operation
  • Two independent PWM outputs with single-edge operation
  • One independent PWM output with dual-edge asymmetric operation

So no two similar PWM output which makes me edgy, because having rotors running on different clocks is a bit dodgy especially if I hope to have finer tuned control on my quad so I have dropped the idea to write the perl driver for BBB CPU controlled PWM.

I haven't gone into details of different types of PWM but from a brief read up on the web, a dual edge symmetric PWM provides better quality signal for running Brushless DC motor, in a X config quad that I have, I am not sure I want to have different quality signals running the four motors.

  • ArchLinux
  • Beaglebone Black
  • Device::L3GD20
  • Device::LPS331AP
  • Device::LSM303DLHC
  • Device::SMBus
  • GNU
  • Linux

Setting up ArchLINUX on BeagleBone Black - Part 2

shantanubhadoria 14-12-2013 07:20:59

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 Device::SMBus

 

  • ArchLinux
  • Beaglebone Black
  • GNU
  • Linux
Hi, my name is Shantanu Bhadoria. I am Just Another Perl Hacker. Here is my home page: . I currently live in Singapore . I am a regular contributor and a author of many open source packages at CPAN. My work can be accessed at . Get in touch with me at (+65)-92296717