Tuesday, 8 November 2011

How To Go To Specific Line Number In Nano

Nano is a light-weight command line text editor that will be very useful in many cases such as while editing files on remote server through SSh. Numerous times, you want to jump to the specific line and this is very easy in nano editor.

First we need to know the line number and I usually use grep to do so. The grep -n switch will output the line number. Now if you know the line number, you can use either of the following ways to go to the specific line number.

First way is to open nano directly to the line of the file you want to reach. The syntax is something like below:

nano +104 file.sh

The above command will directly take you the line number 104 of file.sh file. Now, if you are already in nano and you want to reach to some specific line number, use the shortcut Ctrl + _ (underscore == Ctrl + Shift + -). Nano will ask you the line number to go to and enter the line number you want to go to. Another equivalent shortcut is Alt + g which I just discovered today.

I hope this helps. :)



Read more...

Monday, 7 November 2011

How To Find And Change Hostname In Linux

Several times,we want to change the hostname we have set during installation. In most cases, we don't care hostname during installation and later we might need to change it to something mandatory. So I will discuss on how we can view the hostname and change it according to our wish.

To simply know the hostname, you can open the terminal(gnome-terminal for ubuntu) where you will find a entry which is something similar to samar@Techgaun: ~$. This entry is in the format user@hostname so in this example, samar is the user and Techgaun is the hostname. So this way you could simply know your hostname.

Also, there is a hostname command which also can be used to know the hostname. It can also be used to edit the hostname of your system.

To view hostname with this command, open terminal and type:

hostname

To view the FQDN, you can type:

hostname -f

Now to change the hostname, just type:

sudo hostname NEW_HOSTNAME

The above might need restart of shell(or simply do Ctrl + Shift + T) to see the effect.

Also, the file containing the host name is /etc/hostname so to change the hostname permanently, you can edit this file as well.

sudo gedit /etc/hostname

and then change the entry for host name as per your requirement. Then you need to reboot your system to see the effect or you could alternatively do:

sudo /etc/init.d/hostname stop

This will perfectly work for debian based systems. For the Redhat and similar variants, you need to edit /etc/sysconfig/network file and set its HOSTNAME field.

I hope this helps you. :)


Read more...

Saturday, 5 November 2011

Image Resizing Using Linux Command Line

Image resizing is one of those things in linux that should not be done using GUI. Better than GUI, there is a part of ImageMagick package for effective resizing of any image.

For resizing images, you need to have ImageMagick installed in your linux system. ImageMagick is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. You can use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bezier curves.

For ubuntu and debian based distros, type the following in console for installation:
sudo apt-get install imagemagick

Now, to resize any image, we can either use mogrify or convert command(these commands are far more complex and useful than just resizing, check man mogrify for more details of their functionalities.) that is part of ImageMagick suite.

For example, to resize an image you can use the following command:

mogrify -resize 50% image_name.jpg

That would reduce the size to 50% of the original size.

To resize to certain pixel, you can specify the expected dimension as below:

mogrify -resize 800x600 image_name.jpg


Read more...

Friday, 4 November 2011

SEO Friendly and Better Title For Blogspot Blog

The blogger blogspot has a default setting to show the title of posts page in your blog in the format Blog Name : Post Title which is not much SEO friendly. Better would be the format Post Title : Blog Name. Changing to this better format is very simple and easy.

Go to your design page and click on Edit HTML and then check the Expand Widget Templates checkbox.

Now search for:

<title><data:blog.pageTitle/></title>

Replace that whole thing you've just searched with the following blogger code:

<b:if cond='data:blog.url == data:blog.homepageUrl'>
<title><data:blog.pageTitle/></title>
<b:else/>
<title><data:blog.pageName/>: <data:blog.title/></title>
</b:if>

Now you should see the effect in action. :)


Read more...

Wednesday, 2 November 2011

Reversing Android Applications With ARE

A new platform ARE has been developed for making android reverse engineering easy and fast. With many necessary tools packaged in a single tool, ARE is a Virtual Machine for Android Reverse Engineering.

You just need to load the new virtual machine with virtualbox and you are ready for android reverse engineering.

The softwares present in ARE are:
Androguard
Android sdk/ndk
APKInspector
Apktool
Axmlprinter
Ded
Dex2jar
DroidBox
Jad
Smali/Baksmali

Both the login username and password for ARE is android

Download ARE

More mirrors:

Mirror 1
Mirror 2

Good luck with android reversing.


Read more...

Tuesday, 1 November 2011

How To Search Strings In Binary Files in Linux

There is this very useful strings command in linux that lets us to search strings inside binary and object files. This is useful for developers in many cases and also for linux binary crackers. Also, end users can study more about executable with this command.

I've used strings command several times for ELF binary cracking and the command helps us gather more information of any given executable. It supports many executables and object formats such as elf32-i386, a.out-i386-linux, pei-i386, elf32-little, elf32-big, elf64-x86-64, pei-x86-64, elf64-l1om, elf64-little, elf64-big, plugin, srec, symbolsrec, verilog, tekhex, binary, ihex, and trad-core.

Usage:

The command itself is pretty easy to use, the simplest being as below:

strings file_name

Specify the name of object or executable file of supported type and you are good to go. However you might want to customize the way strings command searches the strings in the given file. For example, to search for strings in all the sections of the file(by default, it searches only
the data section), you can use the command as below:

strings -a file_name

There are much more options which you can study by typing strings -h and man strings in the terminal. I hope it helps you.

Read more...

Shortcuts For Copy and Paste In Linux Terminal

If you are used to with Ctrl + c and Ctrl + v for copy paste tasks in graphical tools, you will come to know these shortcuts do not work in linux terminal. However you still have the luxury of using such shortcut but with the help of one more finger to press the extra Shift key.

You might have already figured out what shortcuts you have to use. If not, they are Shift + Ctrl + C and Shift + Ctrl + V for copy and paste respectively. I hope this is helpful.


Read more...

Two Really Useful Shortcuts While Using Linux Terminal

In this post, I am going to share two really useful shortcuts while using linux terminal. When you get to use these two shortcuts, you will always be using them for ease while operating under terminal.

Both of these shortcuts are used for ease while erasing the erroneous words or commands in terminal. Rather than pressing backspace all the time, you would love to see some shortcuts to achieve the same. And here are two commands that you will usually be using.

The first one is Ctrl + w which will erase the current word you are typing. For example, you typed cat abcdef and you want to remove abcdef, then you can use Ctrl + w. So this shortcut would erase whole word at the last of command you are typing.

The other one is Ctrl + u which will erase whole line of command you are currently typing. For instance, you typed ls -lia /home/user/Downloads and you think "Oh that's not the command I want to execute right now", then you can safely use the shortcut Ctrl + u.

I hope you find these shortcuts useful while using linux terminal.


Read more...