Wednesday, September 7, 2011

How to Hack Twitter? or even Facebook?

Are you onto hacking my Twitter or Facebook? It really puts you on no.1 on my terrorist list. But on the other hand, it is true that as even more people are switching to wireless/wifi devices and networks for tweets, emails, Facebook status updates, there are serious security implications associated to them. Notice how easy it is to hack into someone's social networking account and scare him or her.

This technique is known as HTTP session hijacking attack.

1- Make yourself comfortable in a crowded place, where you are sure to find some wireless/wifi networks on the loose (An airport or a bus station, or may be a tube station).
2- Fire up your Firefox 3.0.6 or higher (excluding 4.0 +) with Firesheep extension installed (Note there are already around 2 million downloads as I write this post).
3- And sit back and relax while you will have access to all open sessions for various services including Gmail, Yahoo, Hotmail and not to mention Twitter or Facebook.

Workarounds: Service providers have been incorporating the use of SSL in their applications and make sure that your browser uses the link starting from https: rather than http:

Disclaimer: This post is for education purposes only. And I request you to not to harm any user if you get access to his/her personal service account. And perhaps it is your duty as a responsible citizen to warn users of the dangers associated with using insecure wireless networks.

Tuesday, September 6, 2011

PHP: Watermark an Image

I recently came across a project in which I had to use text overlay to watermark an image with PHP GD. As it was an interesting project, therefore, I decided to share the technique.


$text = "© Copyright 2011"; // Text you will like to place as a watermark.
$file = "images/jpg/image1.JPG"; // path to actual image with full filename (in this case image1.JPG)
    $filew = 'image2'.'JPG'; // intended name of the new image file with watermark enabled
    $dim = getimagesize($file); // function to get dimensions of our original image
    $imagewidth  = $dim[0]; // get the width of the original image
    $imageheight = $dim[1]; // get the height of the original image
    $image = imagecreatefromjpeg($file); //create a new resource from our original image
    $black = imagecolorallocate($image, 0, 0, 0); // color of the copyright text to place on the image
    $grey = imagecolorallocate($image, 128, 128, 128); // I used the grey color to create a shadow
    $font = 'arial.ttf'; // font file. I copied the arial.ttf in the root folder. Use the full path to the file.
    imagettftext($image, 12, 0, 5, 20, $black, $font, $text); // function to copy text on the image.
    imagettftext($image, 12, 0, 6, 21, $grey, $font, $text); // function to copy text to create shadow
    $fpath = "_stamped/"; // my new path for the altered image
    $filec = $fpath .$filew; // create a full new path for the altered image
    imagejpeg($image, $filec ); // copy the image to the new path
    imagedestroy($image); // free the memory

In order to use it in your HTML, use the following code:
echo "<p><img class='image' src=\"$filec\"></p>";

Output Result will be quite similar to that as follows:


From the Web