Tuesday, 17 May 2016

Using The Terminal in Ubuntu Basics

Why use the command-line?

"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are." 
-- from man intro(1) 
There are many varieties of Linux, but almost all of them use similar commands that can be entered from a command-line interface terminal.
There are also many graphical user interfaces (GUIs), but each of them works differently and there is little standardization between them. Experienced users who work with many different Linux distributions therefore find it easier to learn commands that can be used in all varieties of Ubuntu and, indeed, in other Linux distributions as well.
For the novice, commands-line interface commands can appear daunting:
sudo gobbledegook blah_blah -w -t -h --long-switch aWkward/ComBinationOf/mixedCase/underscores_strokes/and.dots
However, it is important to note that even experienced users often cut and paste commands (from a guide or manual) into the command-line terminal; they do not memorize them. 
It is important, of course, to know how to use the command-line terminal - and anyone who can manage typing, backspacing, and cutting and pasting can manage the command-line terminal (it is not more difficult than that).
This page will outline a few crafty shortcuts which can make using a command-line interface easier.

Starting a Terminal

In Unity

Unity is the default desktop environment used as of 11.04. Where systems are not ready for Unity they revert to GNOME which is also used in previous releases such as Ubuntu 10.04 LTS (Lucid), see next sub-section.
The easiest way to open the Terminal is to use the 'search' function on the dash. Or you can click on the 'More Apps' button, click on the 'See more results' by the installed section, and find it in that list of applications. A third way, available after you click on the 'More Apps' button, is to go to the search bar, and see that the far right end of it says 'All Applications'. You then click on that, and you'll see the full list. Then you can go to Accessories -> Terminal after that. So, the methods in Unity are:
Dash -> Search for Terminal
Dash -> More Apps -> 'See More Results' -> Terminal
Dash -> More Apps -> Accessories -> Terminal
Keyboard Shortcut: Ctrl + Alt + T

In GNOME

GNOME is the classic desktop environment for Ubuntu 11.04 (Natty) and is the default desktop environment in earlier releases, such as Ubuntu 10.04 LTS (Lucid).
Applications menu -> Accessories -> Terminal.
Keyboard Shortcut: Ctrl + Alt + T

In Xfce (Xubuntu)

Applications menu -> System -> Terminal.
Keyboard Shortcut: Super + T
Keyboard Shortcut: Ctrl + Alt + T

In KDE (Kubuntu)

KMenu -> System -> Terminal Program (Konsole).

In LXDE (Lubuntu)

Menu -> Accessories -> LXTerminal.
Keyboard Shortcut: Ctrl + Alt + T

Commands

sudo: Executing Commands with Elevated Privileges

  • Most of the following commands will need to be prefaced with the sudo command. This elevates privileges to the root-user administrative level temporarily, which is necessary when working with directories or files not owned by your user account. When using sudo you will be prompted for your password. Only users with sudo (administrative) privileges will be able to use this command. You should never use normal sudo to start graphical applications as root. (Please see RootSudo for more information on using sudo correctly.)

File & Directory Commands

  • The tilde (~) symbol stands for your home directory. If you are user, then the tilde (~) stands for /home/user
  • pwd: The pwd command will allow you to know in which directory you're located (pwd stands for "print working directory"). Example: "pwd" in the Desktop directory will show "~/Desktop". Note that the GNOME Terminal also displays this information in the title bar of its window. A useful gnemonic is "present working directory."
  • ls: The ls command will show you ('list') the files in your current directory. Used with certain options, you can see sizes of files, when files were made, and permissions of files. Example: "ls ~" will show you the files that are in your home directory.
  • cd: The cd command will allow you to change directories. When you open a terminal you will be in your home directory. To move around the file system you will use cd. Examples:
    • To navigate into the root directory, use "cd /"
    • To navigate to your home directory, use "cd" or "cd ~"
    • To navigate up one directory level, use "cd .."
    • To navigate to the previous directory (or back), use "cd -"
    • To navigate through multiple levels of directory at once, specify the full directory path that you want to go to. For example, use, "cd /var/www" to go directly to the /www subdirectory of /var/. As another example, "cd ~/Desktop"will move you to the Desktop subdirectory inside your home directory.
  • cp: The cp command will make a copy of a file for you. Example: "cp file foo" will make an exact copy of "file" and name it "foo", but the file "file" will still be there. If you are copying a directory, you must use "cp -r directory foo" (copy recursively). (To understand what "recursively" means, think of it this way: to copy the directory and all its files and subdirectories and all their files and subdirectories of the subdirectories and all their files, and on and on, "recursively")
  • mv: The mv command will move a file to a different location or will rename a file. Examples are as follows: "mv file foo"will rename the file "file" to "foo". "mv foo ~/Desktop" will move the file "foo" to your Desktop directory, but it will not rename it. You must specify a new file name to rename a file.
    • To save on typing, you can substitute '~' in place of the home directory.
    • Note that if you are using mv with sudo you can use the ~ shortcut, because the terminal expands the ~ to your home directory. However, when you open a root shell with sudo -i or sudo -s, ~ will refer to the root account's home directory, not your own.
  • rm: Use this command to remove or delete a file in your directory.
  • rmdir: The rmdir command will delete an empty directory. To delete a directory and all of its contents recursively, use rm -rinstead.
  • mkdir: The mkdir command will allow you to create directories. Example: "mkdir music" will create a directory called "music".
  • man: The man command is used to show you the manual of other commands. Try "man man" to get the man page forman itself. See the "Man & Getting Help" section down the page for more information.
  • sudo: The sudo command is used to perform file operations on files that the Root User would only be allowed to change. An example would be trying to move one of your documents that another user accidentally moved to / back to yourdocuments directory. Normally, to move the file, you would type mv /mydoc.odt ~/Documents/mydoc.odt, but you are not allowed to modify files outside of your home directory. To get around this, you would type sudo mv /mydoc.odt ~/Documents/mydoc.odt. This will successfully move the file back to its correct location, provided that you are not astandard user, who has less (administrative) ability than an administrator. Be aware, though, that by using the sudocommand, you need to be extra careful. It is easier to damage your system by using the sudo command. For more information about the sudo command, click here.

Running a File Within a Directory

So you've decided to run a file using the command-line? Well... there's a command for that too!
  • ./filename.extension
After navigating to the file's directory, this command will enable any Ubuntu user to run files compiled via GCC or any other programming language. Although the example above indicates a file name extension, please notice that, differently from some other operating systems, Ubuntu (and other Linux-based systems) do not care about file extensions (they can be anything, or nothing). Keep in mind that the 'extension' will vary depending upon the language the source code is written in. Also, it is not possible, for compiled languages (like C and C++) to run the source code directly -- the file must becompiled first, which means it will be translated from a human-readable programming language to something the computer can understand. Some possible extensions: ".c" for C source, ".cpp" for C++, ".rb" for Ruby, ".py" for Python, etc. Also, remember that (in the case of interpreted languages like Ruby & Python) you must have a version of that language installed on Ubuntu before trying to run files written with it.
Finally, the file will only be executed if the file permissions are correct -- please see the FilePermissions help page for details.

System Information Commands

  • df: The df command displays filesystem disk space usage for all mounted partitions. "df -h" is probably the most useful - it uses megabytes (M) and gigabytes (G) instead of blocks to report. (-h means "human-readable")
  • du: The du command displays the disk usage for a directory. It can either display the space used for all subdirectories or the total for the directory you run it on. Example:
user@users-desktop:~$ du /media/floppy
1032    /media/floppy/files
1036    /media/floppy/
user@users-desktop:~$ du -sh /media/floppy
1.1M    /media/floppy/
  • -s means "Summary" and -h means "Human Readable"
  • free: The free command displays the amount of free and used memory in the system. "free -m" will give the information using megabytes, which is probably most useful for current computers.
  • top: The top ('table of processes') command displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit top, press "q".
  • uname -a: The uname command with the -a option prints all system information, including machine name, kernel name & version, and a few other details. Most useful for checking which kernel you're using.
  • lsb_release -a: The lsb_release command with the -a option prints version information for the Linux release you're running, for example:
user@computer:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.10
Release:        11.10
Codename:       oneiric
  • ip addr reports on your system's network interfaces.

Adding A New User

  • "adduser newuser" command will create a new general user called "newuser" on your system, and to assign a password for the newuser account use "passwd newuser".

Options

The default behaviour for a command may usually be modified by adding a --option to the command. The ls command for example has an -s option so that "ls -s" will include file sizes in the listing. There is also a -h option to get those sizes in a "human readable" format.
Options can be grouped in clusters so "ls -sh" is exactly the same command as "ls -s -h". Most options have a long version, prefixed with two dashes instead of one, so even "ls --size --human-readable" is the same command.

"Man" and getting help

Warning /!\ man command, info command and command --help are the most important tools at the command line.
Nearly every command and application in Linux will have a man (manual) file, so finding them is as simple as typing "man "command"" to bring up a longer manual entry for the specified command. For example, "man mv" will bring up the mv (move) manual.
Move up and down the man file with the arrow keys, and quit back to the command prompt with "q".
"man man" will bring up the manual entry for the man command, which is a good place to start!
"man intro" is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.
There are also info pages, which are generally more in-depth than man pages. Try "info info" for the introduction to info pages. 
Some software developers prefer info to man (for instance, GNU developers), so if you find a very widely used command or app that doesn't have a man page, it's worth checking for an info page.
Virtually all commands understand the -h (or --help) option which will produce a short usage description of the command and it's options, then exit back to the command prompt. Try "man -h" or "man --help" to see this in action.
Caveat: It's possible (but rare) that a program doesn't understand the -h option to mean help. For this reason, check for a man orinfo page first, and try the long option --help before -h.

Searching for man files

If you aren't sure which command or application you need to use, you can try searching the man files.
  • man -k foo will search the man files for foo. Try "man -k nautilus" to see how this works.
    • Note that this is the same as doing apropos command.
  • man -f foo searches only the titles of your system's man files. Try "man -f gnome", for example.
    • Note that this is the same as doing whatis command.

Other Useful Things

Prettier Manual Pages

Users who have Konqueror installed will be pleased to find they can read and search man pages in a web browser context, prettified with their chosen desktop fonts and a little colour, by visiting man:/command in Konqueror's address bar. Some people might find this lightens the load if there's lots of documentation to read/search.

Pasting in commands

Often, you will be referred to instructions that require commands to be pasted into the terminal. You might be wondering why the text you've copied from a web page using Ctrl + C won't paste in with ctrl+V. Surely you don't have to type in all those nasty commands and filenames? Relax. ctrl+shift+V pastes into a GNOME terminal; you can also do middle button click on your mouse (both buttons simultaneously on a two-button mouse) or right click and select Paste from the menu. However, if you want to avoid the mouse and yet paste it, use "Shift + Insert", to paste the command. If you have to copy it from another terminal / webpage, you can use "Ctrl + Insert" to copy. 

Save on typing

Up Arrowor Ctrl + P
Scrolls through the commands you've entered previously.
Down Arrowor Ctrl + N
Takes you back to a more recent command.
Enter
When you have the command you want.
tab
A very useful feature. It autocompletes any commands or filenames, if there's only one option, or else gives you a list of options.
Ctrl + R
Searches for commands you've already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing a portion of the command will search through your command history. When you find it, simply press Enter.
History
The history command shows a very long list of commands that you have typed. Each command is displayed next to a number. You can type !x to execute a previously typed command from the list (replace the X with a number). If youhistory output is too long, then use history | less for a scrollable list.
  • Example: you ran history and found you want to use command 1967. Simply enter
!1967

Change the text

The mouse won't work. Use the left/right arrow keys to move around the line. 
When the cursor is where you want it in the line, typing inserts text - ie it doesn't overtype what's already there.
Ctrl + A or Home
Moves the cursor to the start of a line.
Ctrl+ E or End
Moves the cursor to the end of a line.
Esc + B
Moves to the beginning of the previous or current word.
Ctrl + K
Deletes from the current cursor position to the end of the line.
Ctrl + U
Deletes from the start of the line to the current cursor position.
Ctrl + W
Deletes the word before the cursor.
Alt + B
Goes back one word at a time.
Alt + F
Moves forward one word at a time.
Alt + C
Capitalizes letter where cursor is and moves to end of word.

More ways to run a terminal

You can also get it with a function key
You can run more than one - in tabs or separate windows.
You can also install guake (GNOME), tilda (XFCE / LXDE/Mate) or yakuake (KDE) and have a terminal which appears and hides on shortcut key. This can be particularly useful if you use terminal a lot. Drop down terminals can make things a lot easier if you are trying to run a desktop enviroment with a non defualt window manager and something goes wrong drop down terminals can run the orginal window manager --replace to restore a previous option to make things much less painful. 

An extremely handy tool :: Incremental history searching

In terminal enter:
gedit  ~/.inputrc
Then copy paste and save:
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
From now on, and many agree this is the most useful terminal tool, it saves you a lot of writing/memorizing...
All you need to do to find a previous command is to enter say the first two or three letters and upward arrow will take you there quickly:
Say I want:
for f in *.mid ; do timidity "$f"; done
All I need to do is enter:
fo
And hit upward arrow command will soon appear.

How to create upsidedown and/or reverse text with your terminal

If you wish or need to ever flip text upside down [vertical flip] "uʍop ǝpısdn ʇxǝʇ dıʃɟ" or/and create reverse text here is a terminal way to achieve this.
Copy/paste and save the following as flip.pl in your home folder (thanks to Lars Noodén for script).
#!/usr/bin/perl

use strict;
use warnings;
use utf8;

binmode(STDOUT, ":utf8");

my %flipTable = (
    "a" => "\x{0250}",
    "b" => "q",
    "c" => "\x{0254}", 
    "d" => "p",
    "e" => "\x{01DD}",
    "f" => "\x{025F}", 
    "g" => "\x{0183}",
    "h" => "\x{0265}",
    "i" => "\x{0131}", 
    "j" => "\x{027E}",
    "k" => "\x{029E}",
    "l" => "|",
    "m" => "\x{026F}",
    "n" => "u",
    "o" => "o",
    "p" => "d",
    "q" => "b",
    "r" => "\x{0279}",
    "s" => "s",
    "t" => "\x{0287}",
    "u" => "n",
    "v" => "\x{028C}",
    "w" => "\x{028D}",
    "x" => "x",
    "y" => "\x{028E}",
    "z" => "z",
    "A" => "\x{0250}",
    "B" => "q",
    "C" => "\x{0254}", 
    "D" => "p",
    "E" => "\x{01DD}",
    "F" => "\x{025F}", 
    "G" => "\x{0183}",
    "H" => "\x{0265}",
    "I" => "\x{0131}", 
    "J" => "\x{027E}",
    "K" => "\x{029E}",
    "L" => "|",
    "M" => "\x{026F}",
    "N" => "u",
    "O" => "o",
    "P" => "d",
    "Q" => "b",
    "R" => "\x{0279}",
    "S" => "s",
    "T" => "\x{0287}",
    "U" => "n",
    "V" => "\x{028C}",
    "W" => "\x{028D}",
    "X" => "x",
    "Y" => "\x{028E}",
    "Z" => "z",
    "." => "\x{02D9}",
    "[" => "]",
    "'" => ",",
    "," => "'",
    "(" => ")",
    "{" => "}",
    "?" => "\x{00BF}", 
    "!" => "\x{00A1}",
    "\"" => ",",
    "<" => ">",
    "_" => "\x{203E}",
    ";" => "\x{061B}",
    "\x{203F}" => "\x{2040}",
    "\x{2045}" => "\x{2046}",
    "\x{2234}" => "\x{2235}",
    "\r" => "\n",
    " " => " "
);

while ( <> ) {
    my $string = reverse( $_ );
    while ($string =~ /(.)/g) {
        print $flipTable{$1};
    }
    print qq(\n);
}
Then to set it up:
sudo mv flip.pl /bin/
cd /bin/
sudo chown yourusername flip.pl && sudo chmod +x flip.pl
Then open terminal and enter:
flip.pl
else
perl /bin/flip.pl
Write what you want and hit return
Copy and paste wherever you want text document or Internet forum, etc...
  • ɹǝʇuǝ puɐ ʇuɐʍ noʎ ʇɐɥʍ ǝʇıɹʍ ˙˙˙ɔʇǝ ɯnɹoɟ ʇǝuɹǝʇuı ɹo ʇuǝɯnɔop ʇxǝʇ ʇuɐʍ noʎ ɹǝʌǝɹǝɥʍ ǝʇsɐd puɐ ʎdoɔ
==================
If you want to reverse back to front, write your text in a text editor and save as mytext to the home folder.
Then enter:
rev mytext
Copy and paste the result, tluser eht etsap dna ypoc.

And of course you can combine both for truly cryptic results, ɔodʎ ɐup dɐsʇǝ ʇɥǝ ɹǝsnʃʇ

Starting an application, and using the Tab key

To start an application from the terminal, just type the name. Let's start gedit, and use Tab to complete the name.
First, type ged as done below
user@host:~$ ged
Press the Tab key to auto-complete the name. It should now read:
user@host:~$ gedit
Press Enter to start gedit from the terminal. Before continuing, quit gedit.

Installing applications

Installing applications from the terminal is easily done using apt-get. To search for applications, we use apt-cache. Both belong to the same program called apt.
Search for videolan:
user@host:~$ apt-cache search videolan
You should get a long list of packages related to videolan. To install vlc-plugin-jack (will allow you to use vlc with jack):
user@host:~$ sudo apt-get install vlc-plugin-jack
What is sudo?
Sudo is a command that lets' you perform other commands as 'superuser'. Installing programs is not allowed for a normal user. When using sudo, you need to use your user password to allow passing the command that follows it.

More basic commands, and starting scripts

Up and Down Arrow Keys

You already know how to use the Tab key, which saves you a lot of effort when typing. Other helpful keys are the up and downarrow keys. Pressing up will page back in history of the commands you have used. Pressing Down will page forwards.

Download a script

This script is called myscript.sh, and the only thing it does is prints some text when you execute it from the terminal. Download it into your Download folder.

Change to another directory and start the script

Now, if you downloaded the script into your Download folder in your user home directory, you could do following to start it from the terminal.
Try the ls command:
user@host:~$ ls
You should see a list of files and folders in your home directory. To change to the Downloads directory use the cd command:
user@host:~$ cd Downloads
Notice that the prompt looks different now:
user@host:~/Downloads$
Now, you could do ls again to see what is in the Downloads directory. And to start the script, you do:
user@host:~/Downloads$ ./myscript.sh
If you aren't able to start the script, it may be that it isn't set to be executable. To make the script executable, do:
user@host:~/Downloads$ chmod +x myscript.sh
And then, try again.
Finally, to get back to your home directory you can do:
user@host:~/Downloads$ cd ../
Also, just using cd without an argument will get you back to your home directory.

How to find help about different commands

Each command usually has one or two help sections. To see a shorter help section for the ls command, do:
user@host:~ ls --help
To get the more extensive manual, do:
user@host:~ man ls
To quit the manual, press q.
That's all for this short guide. Hopefully you have learned enough about using the command line to know how to follow simple tutorials and guides that involve the terminal.

Top 10 Security Assessment Tools

Security Assessment Tools
Modern data centres deploy firewalls and managed networking components, but still feel insecure because of crackers. Hence, there is a crucial need for tools that accurately assess network vulnerability. This article brings you the top 10 assessment tools to address these issues, categorised based on their popularity, functionality and ease of use.
Vulnerabilities are unfortunately an integral part of every software and hardware system. A bug in the operating system, a loophole in a commercial product, or the  misconfiguration of critical infrastructure components makes systems susceptible to attacks. Malicious techies can penetrate systems via these vulnerabilities, for personal or commercial gains. While technically this is not very easy, there have been enough successful attempts to cause one to worry.
Earlier, it was believed that this was true only for commercial products. Yet, lately, open source systems have been cracked, resulting in data theft and a loss of reputation or money. Apart from local area networks, websites are also vulnerable and have become the prime target of crackers. In short, vulnerabilities can be exploited from within the organisation, as well as over the Internet by unknown people.
On the bright side, with the number of attacks increasing, there are now a slew of tools to detect and stop malware and cracking attempts. The open source world has many such utilities (and distros). Here, I must mention BackTrack Linux, which has gained international fame for its wide range of vulnerability assessment and digital forensics software utilities. The most recent version also contains powerful wireless vulnerability testing tools.
Though there are literally hundreds of tools, I have selected the top 10 based on the fact that no other tool can really replace them. The primary selection criteria have been the feature set, how widespread the product is within the security community, and simplicity.
Please refer to Figure 1, which shows the top five tools I chose for network assessment, while Figure 2 shows the leading Web vulnerability scanning products. Of course, only FOSS tools are mentioned. I have presented the tools in the order that they are expected to be used to detect vulnerabilities; this should provide a systematic approach to readers who wish to make a career as certified penetration testers.
Top 5 network security scanners
Figure 1: Top 5 network security scanners
Top 5 web security scanners
Figure 2: Top 5 web security scanners

The top 5 network security assessment tools

Vulnerability scanning of a network needs to be done from both within the network as well as without (from both “sides” of the firewall). The approach I would suggest is to start from the network evaluation phase, where sniffing and primary attacks are performed. The gathered data is used in the attack phase to exploit the exposed vulnerabilities.

Wireshark

The very first step in vulnerability assessment is to have a clear picture of what is happening on the network. Wireshark (previously named Ethereal) works in promiscuous mode to capture all traffic of a TCP broadcast domain.
Customised filters can be set to intercept specific traffic; for example, to capture communication between two IP addresses, or capture UDP-based DNS queries on the network. Traffic data can be dumped into a capture file, which can be reviewed later. Additional filters can also be set during the review.
Typically, the tester is looking for stray IP addresses, spoofed packets, unnecessary packet drops, and suspicious packet generation from a single IP address. Wireshark gives a broad and clear picture of what is happening on the network.
However, it does not have its own intelligence, and should be used as a data provider. Due to its great GUI, any person with even some basic knowledge can use it.

Nmap

This is probably the only tool to remain popular for almost a decade. This scanner is capable of crafting packets and performing scans to a granular TCP level, such as SYN scan, ACK scan, etc. It has built-in signature-checking algorithms to guess the OS and version, based on network responses such as a TCP handshake.
Nmap is effective enough to detect remote devices, and in most cases correctly identifies firewalls, routers, and their make and model. Network administrators can use Nmap to check which ports are open, and also if those ports can be exploited further in simulated attacks. The output is plain text and verbose; hence, this tool can be scripted to automate routine tasks and to grab evidence for an audit report.
You can read the series of Nmap articles published earlier for better understanding.

Metasploit

Once sniffing and scanning is done using the above tools, it’s time to go to the OS and application level. Metasploit is a fantastic, powerful open source framework that performs rigorous scans against a set of IP addresses.
Unlike many other frameworks, it can also be used for anti-forensics. Expert programmers can write a piece of code exploiting a particular vulnerability, and test it with Metasploit to see if it gets detected. This process can be reversed technically — when a virus attacks using some unknown vulnerability, Metasploit can be used to test the patch for it.
While this is a commercial tool, I have mentioned it here because the community edition is free, yet makes no compromises on the feature set.

OpenVAS

The Nessus scanner is a famous commercial utility, from which OpenVAS branched out a few years back to remain open source. Though Metasploit and OpenVAS are very similar, there is still a distinct difference.
OpenVAS is split into two major components — a scanner and a manager. A scanner may reside on the target to be scanned and feed vulnerability findings to the manager. The manager collects inputs from multiple scanners and applies its own intelligence to create a report.
In the security world, OpenVAS is believed to be very stable and reliable for detecting the latest security loopholes, and for providing reports and inputs to fix them. A built-in Greenbone security assistant provides a GUI dashboard to list all vulnerabilities and the impacted machines on the network.
Creating detailed reports is one thing that makes OpenVAS a tool favoured by infrastructure security managers.

Aircrack

The list of network scanners would be incomplete without wireless security scanners. Today’s infrastructure contains wireless devices in the data centre as well as in corporate premises to facilitate mobile users. While having WPA-2 security is believed to be adequate for 802.11 WLAN standards, misconfiguration and the use of over-simple passwords leaves such networks open to attacks.
Aircrack is a suite of software utilities that acts as a sniffer, packet crafter and packet decoder. A targeted wireless network is subjected to packet traffic to capture vital details about the underlying encryption. A decryptor is then used to brute-force the captured file, and find out passwords. Aircrack is capable of working on most Linux distros, but the one in BackTrack Linux is highly preferred.

The top five Web security assessment tools

Scanning websites is an entirely different ballgame from network scans. In the case of websites, the scope of the scan ranges from Layer 2 to 7, considering the intrusiveness of the latest vulnerabilities. The correct approach for scanning websites starts from Web-level access, right up to scanning all backend components such as databases. While most Web security scanners are automated, there could be a need for manual scripting, based on the situation.

Nikto

Let’s start with this tool because of its feature set. This open source tool is widely used to scan websites, mainly because it supports HTTP and HTTPS, and also provides findings in an interactive fashion. Nikto can crawl a website just the way a human would, and that too in the least amount of time. It uses a technique called mutation, whereby it creates combinations of various HTTP tests together to form an attack, based on the Web server configuration and the hosted code.
Thus, it finds critical loopholes such as file upload misconfiguration, improper cookie handling, cross-scripting errors, etc. Nikto dumps all findings in a verbose mode, which helps in knowing more about the Web vulnerabilities, in detail. However, it can also result in too many things getting notified, some of which may be false alarms. Hence, care should be taken while interpreting Nikto logs.

Samurai framework

Once a baseline check is performed by Nikto, the next step is to take the “deep-dive” approach.Samurai is a framework — a bunch of powerful utilities, each one targeted for a specific set of vulnerabilities.
It comes as a Linux distribution, purely focusing on penetration-testing tools such as WebScarab for HTTP mapping, W3AF plugins for application-based attacks, and it also has tools to test browser-based exploits. It is amazing to note that the most recent version can find vulnerabilities that are usually not detected even by a few commercial software products.

Safe3 scanner

While the first two tools are good for static websites, for portals needing user ID and password, we need something that can deal with HTTP sessions and cookies. Safe3 scanner is a fantastic open source project, which has gained momentum and fame because it can handle almost all types of authentication, including NTLM.
It contains a Web crawler (a spider like that of search engines) capable of ignoring duplicate page scans and yet detect client-side JavaScript vulnerabilities. Safe3 scans also detect the possibility of the latest AJAX-based attacks and even report vulnerable script libraries. It comes with a user-friendly GUI and is capable of creating nice management reports.

Websecurify

Though very similar to Samurai, Websecurify also brings application-level assessment into play. In case of a large Web farm where code is maintained by a team of developers, following standards can sometimes yield insecure code like passwords mentioned in code, physical file paths in libraries, etc. Websecurify can traverse code and find such loopholes swiftly.
A nice feature is that it allows you to create screenshots of the problem areas automatically, which helps in preparing audit reports. It is one of the very few platform-independent tools and also supports mobile coding, which is helping it get more popular in the cyber-security assessment world.

SQLmap

Unless I mention a tool to detect SQL-injection attacks, this article would not be complete. Though this is a very old “first-generation” type of attack, many public websites still fail to fix it. SQLmap is capable of not just exploiting SQL-injection faults, but can also take over the database server. Since it focuses on a specific task, it works at great speed to fingerprint databases, find out the underlying file system and OS, and eventually fetch data from the server. It supports almost all well-known database engines, and can also perform password-guessing attacks. This tool can be combined with the other four tools mentioned above to scan a website aggressively.
A vulnerability assessment tool should include network scanning as well as website vulnerability exploitation. Open source software is prone to attacks too; hence, network administrators must know about the reputed scanners and use them in their daily tasks to make their infrastructure secure and stable.