Friday, March 28, 2014

How to access your EC2 linux instance filesystem over ssh using nemo on linux mint using private key?

I assume that following are available:

1. You have a working EC2 linux instance setup
2. You are running linux mint (Actually I use mint)
3. You have access to your private EC2 key (.pem file)

Steps

1. Place your .pem file in ~/.ssh folder and rename it to id_rsa
2. Run following command ssh-add ~/.ssh/id_rsa (This will load the key in ssh-agent)
3. Use the command in sftp://@ in the address bar of nemo.

This will show all the folders on the remote machine. You can choose to add it to favorites...

Cheers!!!




Friday, March 21, 2014

Wordpress on AWS for company intranet

A while ago I was asked by my CIO, if we can replace our existing custom built intranet with something better that is available off the shelf.

I initially thought of showing off Drupal/Joomla/Wordpress and give a comparison along with the recommended platform. I thought of setting up the infrastructure on one of the test machines that I had which was running linux. Unfortunately it did not have apache, php and other required packages. Installation of these packages using apt-get was a challenge due to restrictive information security policies that would not allow download of files from the repositories. Also the organizational proxy  did not play well with linux making it a nightmare to get anything done (CNTLM did work for a while). Overcoming these would have been a bureaucratic ordeal.

After some thought I decided to use AWS. Picked up a pre-built bitnami AMI from AWS marketplace and set it up on a spot EC2 micro instance.

It took a couple of days for one of our guys to put the content from our existing intranet on wordpress and find a good looking theme.

The demo to CIO went very well  and we got the implementation green signal for Wordpress.

Since AWS EC2 instance was running on my personal account I got a bill of 3.82 USD later on for this exercise. A small price to pay for a successful demo with little effort and avoid organizational bureaucracy.

I have started loving the power of cloud and AWS.

Monday, March 3, 2014

Disable dual graphics for better battery life on mint linux

My acer timeline x 4820TG laptop has 2 graphics cards. An onboard intel card (less powerful but battery friendly) and AMD radeon 5650 (Powerful but battery hungry). This is basically called hybrid graphics. More information can be found at https://wiki.archlinux.org/index.php/hybrid_graphics


Both the graphics cards were used to be on, and eating battery life. Also the fan would make a lot of noise.

Everything was fine when I used to run Windows 7 with the AMD drivers. Since last 2 years I have been using mint linux and it has been a cause of trouble for me since then. I finally decided to take a dig at it solve the issue.

After a couple of searches found the solution...

Use the following commands....

To list the switchable devices
-------------------------------------------------
sudo chown prabhat /sys/kernel/debug
cat /sys/kernel/debug/vgaswitcheroo/switch


To switch off discrete (Radeon) graphics card
------------------------------------------------------------

sudo chown prabhat /sys/kernel/debug/
sudo chown prabhat /sys/kernel/debug/vgaswitcheroo/switch
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch


To switch on discrete graphics card
--------------------------------------------------------------

sudo chown prabhat /sys/kernel/debug/
sudo chown prabhat /sys/kernel/debug/vgaswitcheroo/switch
sudo echo ON > /sys/kernel/debug/vgaswitcheroo/switch


To switch off discrete graphics card at system startup
-----------------------------------------------------------------------------------------

sudo gedit /etc/rc.local

Add following before exit 0

chown prabhat /sys/kernel/debug/vgaswitcheroo/switch
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch

*Replace prabhat with your username.

You should not need these if your kernel is >3.12 (Mine is 3.11) as the driver automatically manages the power of radeon gpu.

Friday, February 28, 2014

In search of an HTML5 IDE

In my pursuit to find a decent development environment for HTML I tried gedit, sublime text, redcar, komodo edit and netbeans.

I was trying to find an eclipse plugin but could not find one for HTML5 and javascript though I rememeber seeing a javascript developer edition of eclipse in helios.
After playing a couple of days with various editors I settled on Netbeans. Its much lighter than eclipse.

Netbeans 7.4 is fantastic in terms of code auto completion. It also provides excellent inline documentation when you are writing code and gives browser compatibility of html tags and css styles.

It provides you facility to include various javascript libraries for development when you are creating a new project.

It also provides you options to build the right starting library for your HTML5 app. You can choose between bootstrap, HTML5 boilerplate and Modernizr

So far it has been working pretty well for me.
 

Monday, February 13, 2012

Automation of code build and deployment (Continuous Integration & Deployment)

 I have been working on code build and deployment automation for a couple of days. Have gone through many tools that are good and can help in this case. Below is a table that that lists down the applications that help at different stages of the cycle. Below table shows movement of the code (source to binary form).


Tools/ Stage Version Contol Checkout Compile & build Run unit tests Configuration of deployment environments Deployment of build to various environments Deployment of DB changes to various environments
Tools Git Cruise Control Cruise Control (ANT, MAVEN, Make, Scripts, etc) Junit cfEngine Control Tier Liquibase
SVN Jenkins Jenkins (ANT, MAVEN, Make, Scripts, etc) Nunit Smartfrog Capistrano Scripts
CVS
Hudson(ANT, MAVEN, Make, Scripts, etc) Scripts Bcfg2 Fabric dbdeploy
Clearcase More tools


Smartfrog
More Tools
More Tools More unit testing frameworks



I was looking only at the open source tools, thus commercial tools are not found in this list. I found Jenkins to be amazingly simple and powerful. With a rich set of plugins and super easy interface and configuration its a breeze. In fact I was able to use it for the entire cycle right from checkout to deploy. It checks out the code, builds the war file (using ANT) transfers it to a windows or unix machine and deploy it.

While other tools might provide extra functionality but they will also add the overhead of managing multiple tools. Using a single tool for the entire cycle reduces the complexity of entire system.

Am currently exploring it for continuous integration and deployment for one of our legacy systems built on COBOL. Theoretically it would work. Just need to iron out a couple of issues on the legacy system front and it would be good to go.

Cruise control was a bit buggy (perhaps the windows build had an issue) and a lot more difficult to configure compared to Jenkins.

Also tried Beebox, but could not get to to work.

Did not try Luntbuild as the last release was somewhere in 2010. Not sure if it is still being maintained.

My verdict is Jenkins. The way to go...

Saturday, January 21, 2012

Open Source Shopping Carts evaluation

I was looking at some open source shopping carts in the process of setting up an online shop. Read a lot of sites/posts/blogs however none of them could make me really understand which one to choose and I ended up downloading, installing and experimenting to find one which one suits best.

In fact it all depends on what is it that you are trying to achieve and how much of money and expertise do you have. I was not looking to do any coding (very minimal if any) to modify the shopping cart to suit to my needs. I will just tabulate the basic feature set that someone setting up an online shop would look for. I started with zencart moved to opencart and then to oscommerce before finally coming back to opencart. I read somewhere that opencart is wordpress of shopping carts, and I wholeheartedly endorse this statement.

 Goal: To set up an online shopping site as quickly as quickly as possible.

Opencart Vs Zencart vs Oscommerce

ParameterOpencartZencartOscommerce
Version1.5.1.31.5.02.3.1
Installation10 min10 min10 min
Possible customizations without codingLow. But most will not need.Highest. Entire screen layout can be changed. Sections can be defined and worked out.Medium
Free AddonsNot really usabe addonsGood ListGood List
Do you need addonsNoYesYes
Base installation look & FeelDecent look and feel with all the features out of box without adding any plugins are available. Product images with lighbox is available.Bad. Something as basic as image zoom using lightbox is not available. Cannot attach multiple images of the product without addons.Bad. Can attach multiple images. Lighbox for image zoom is available out of box.
Basic theme/templateDecent. Additional good freely downloadable templates are not availablke freely. However in most cases the default is decent to start with.Bad. You will have to search for themes templates that can make the site look decent. Haven't really seen good ones available freely.Bad. Same story as zencart.
Ease of use (Admin)Easiest. Provides google analytics integration out of box andd that is cool for most.For uploading images to server you will need to create the folder on server using ftp and then you can upload the images using web front end. Can be improved hugely.Decent
Ease of use (Customer)Easiest with folding javascript sections.Easy but inefficient as page refreshes for every section.Easy but inefficient as page refreshes for every section.
SlideshowsVery easy to build. Put the images and set them via front end.Will need addon (Free).Will need addon (Free)

Support on zencart forum as pretty good and you get your questions answered pretty quickly. In fact zencart is a fork of oscommerce and has gotten added more features but usability has reduced.

Though oscommerce is pretty good I could not find good free templates for it. STS (Simple Template System) does not work for version 2.3.1 and MTS (mini template system) though appears to be pretty good costs money.

I also tried magento. But the base installation downloaded from their site was broken. So did not pursue it.

Remember, shopping cart is only a tool for you get your products online quickly so that you can start selling and making money. Try to have minimal addons as they would have their own overhead and will demand time from you.

My recommendation. Go for opencart. It has everything you need to set up an online store and your effort to result ratio in setting up the shop would be highest without much disappointment.

Cheers!!!

Sunday, March 8, 2009

Rainbow Tables (RTs), Password cracking and Protection against RTs

I first learnt about these around two and a half years ago when I stumbled on one of security related sites (Can't remember). The concept looked awesome. It’s used for cracking passwords that are hashed in a fraction of time than most other techniques will allow you.
 
Before we move further let me give brief background information on password storage
 
Systems that need authentication provide a means to store the authentication tokens (User ID and password) in an authentication repository(database). These passwords are stored in following ways:
 
1. Plaintext    : Passwords are stored in plaintext in the authentication repository. Once someone has access to the repository the person can see the password without any difficulty and can use them to access the system from the front end. Obviously designers of these system haven't thought enough on security front, cared less or plainly thought that nobody would try to steal passwords for these systems (for whatsoever reason). Nevertheless it’s a real bad design considering better practices as mentioned below can be applied with very little effort.
 
2. Encrypted Passwords: Designers of these systems are conscious of their security and implement a mechanism that will encrypt the password by using either a publicly or privately available encryption mechanism. Problem with this mechanism is that all encryption algorithms have corresponding decryption algorithms and can be decrypted once the key is available to the person looking to get the passwords to the system.
 
3. Hashed Passwords (Most widely used): Unlike encryption algorithms hashing algorithms are one way functions without any corresponding de-hashing algorithms that generate a unique hash for a given input. A mathematical representation would be 
H(x) =p where no such F exists such that F (p) =x. H is the hashing function and F is the non-existent de-hashing function. The commonly used hashing algorithms in widespread use are MD5 and SHA. In general hashing algorithms generate a fixed size hash value for any given input (e.g. 128 bit for MD5, Password= 11, Hash=6512BD43D9CAA6E02C990B0A82652DCA).
 
There is no mathematical way for a strong (Attacks have been demonstrated on MD5 and SHA1. SHA 256 is considered to be secure. SHA 3 is under development at the time of writing of this article) hashing algorithm to retrieve the password from the hash. The methodologies that are used in general are dictionary or brute force attack where you try many passwords one after the other until you find a password that will give you the exact hash that you are looking for. If you find the exact hash for the plaintext! Voila you have cracked the password. The problem with dictionary based attacks is that dictionaries can't be very big and a password that does not exist in the dictionary will not be cracked. Brute force cracking has its limitations in terms of huge processing power requirements that are required to compute hashes. To brute force a password of up to 10 characters containing all small alphanumeric characters (abcdefghijklmnopqrstuvwxyz0123456789), the number of hashes to be calculated would be 36^1+36^2+36^3+36^4+36^5+36^6+36^7+36^8+36^9+36^10. 
 
Now this is a big task. It will take weeks or months to crack password this way.
 
A good idea would be to precompute the hashes and maintain a table of plaintexts and hashes. This will save the time of computing hashes and make the job of cracking the password easy. However the generated hash table will be very big in size.
 
Rainbow tables are way to keep the size of these precomputed tables low by making use of intermediate reduction functions. This was first proposed by Philippe Oechslin in his paper faster time-memory trade-off technique published in 2003.
 
So you want to use rainbow tables for cracking passwords. The questions are:
Q.1. What passwords you want/can to crack?
Ans. a.You can crack the passwords for which you have access to the password repository and the hashed password. 
b. You will also need to have the knowledge of the hashing algorithm used.
c. You will also require the rainbow tables built for the corresponding hashing algorithm.
 
The most common password repository is of Windows OS (If you are using one). It stores the NTLM hashed (LM hashed too for compatibility with older versions of windows) passwords that can be recovered using many programs like pwdump, LCP and Cain & Abel (You will require administrative access to the system for recovering these hashes).
 
Now you need to have the rainbow tables. You can either build them yourself which is a very time taking process that you might not want to do unless you have huge processing power available or you can download rainbow tables form many of the sites that provide it either free of cost or by the way of payment (Tables sizes will be in the range of 350 MB to 100 GB+). 
 
In case you do not want to download the tables there are a couple of resources that I have found that you can try using: 

The above mentioned resources allow you to submit hashes and return plain texts for free.
In case you want to download and work in a more sophisticated manner the following resources should be helpful:
 
One of the simplest articles that I have found that can be helpful in understanding rainbow tables is:
 
Limitations of rainbow tables
1. For all the goody goody image of rainbow tables it also has its share of limitations. In spite of excellent compression algorithms rainbow tables still are quite big in size if the character set is huge. In general it’s difficult to find rainbow tables with big character sets for password lengths of more than 14.
2. Generating rainbow tables is very CPU intensive and takes huge amount of time. This can be offset by using distributed architecture for table generation or using very powerful computers.
 
Q. How to protect yourself against rainbow tables
Ans. 
1. Keep your passwords longer. In case of windows if your password is more than 14 characters long then no LM hashes (Which is weaker) will be stored. Do not use passwords, instead always use passphrases that are longer and easier to remember.
 
2. When designing a system for password storage never store password in plain hash. Use salts. Maybe double or triple hash them. e.g.
Password=hello how are you
Stored Password= SHA256(SHA256(Password+"The desired salt"))
Salts can be generated randomly and need not be secret.
This will make rainbow tables ineffective.