Hack Like a Pro: How to Compile a New Hacking Tool in Kali

Jun 4, 2014 02:00 AM
Oct 10, 2016 06:20 PM
635374724339840443.jpg

Welcome back, my newbie hackers!

Recently, I "upgraded" to Kali as my hacking platform, despite my preference for BackTrack. I did this reluctantly, primarily because new readers here could no longer download BackTrack from their site. I want to point out here that we all must keep in mind that with any software—or for that matter, any product—that is newer is not necessarily better.

Although Kali has some new tools and has new version of old tools, the developers of Kali left out some very valuable ones. A tool that I am missing most is Snort.

Snort is the world's most widely used Intrusion Detection System (IDS), and as such, I use it to test whether my exploits can get past it without detection. In the previous versions of BackTrack, Snort has always been included, but not Kali. I thought I would take this opportunity to show you how to download, install, and compile a new tool to Kali, using Snort as an example.

The Process of Compiling Tools for Kali

The process will differ slightly for each tool, but the overall process is very similar. In the case of Snort, we have some dependencies that must be installed to make it work properly. Other tools may or may not have dependencies. One of the advantages of using a package manager such as rpm or .deb is that it will usually handle the dependencies for you. The drawback is that you get a tool that is not necessarily optimized for your platform.

By compiling the tool, we can optimize it for our platform. This means that it will run faster and more efficiently. In a production environment for Snort, this is critical. A slow or inefficient Snort will either drop packets or slowdown your network. Neither is good, so let's look at installing Snort from its source code and compiling it specifically for our platform.

Step 1: Download Snort

You can download Snort at snort.org.

635374179903433403.jpg

When you click on "Download Snort" button, it will take you to this page.

635370358168256321.jpg

Select the "Source" snort.2.9.6.1.tar.gz. If you are using a browser, it will prompt you with the following screen. Chose to save Snort. In this case, I saved it to my Desktop, but you can save it wherever is convenient and easiest for you.

635370361408256550.jpg

As you can see, the source file is now on my Desktop in Kali.

635370362505756392.jpg

Step 2: Pre-Installation

Before we install Snort, there are few pieces of software that Snort needs to run properly. These are often referred to as dependencies. They can include library files and other files that an application needs to run. In the case of Snort, there are a few.

Let's do that now.

kali> sudo apt-get install flex bison build-essential checkinstall libpcap-dev libnet1-dev libpcre3-dev libmysqlclient15-dev libnetfilter-queue-dev iptables-dev

635372925559662949.jpg

You will be prompted twice with (y/n). Simply select y to both.

Step 3: Build & Install Libnet

Next, we need to download, build, and install libnet from the source. We can download it from here. In this case, I'm using the command-line download tool wget.

kali >wget https://libdnet.googlecode.com/files/libdnet-1.12.tgz

635372944150289048.jpg

Once we have successfully downloaded libdnet, we need to untar it, configure it and make it.

First , untar it:

kali >tar xvfvz libdnet-1.12.tgz

Then, change directories to the new libnet directory:

kali > cd libdnet-1.12

And configure it with the "CFLAGS=-fPIC" for a 64-bit version:

kali > ./configure "CFLAGS=-fPIC"

And finally, make the file:

kali > make

We should then be greeted by a screen like that below.

635372947839193895.jpg

Step 4: Build Symbolic Link to Where Snort Looks for Libnet

We need to build a symbolic link from where libnet is, to the location where Snort expects libnet to be, by typing:

kali> ln -s /usr/local/lib/libdnet.1.0.1 /usr/lib/libdnet.1

Step 5: Build & Install Data Acquisistion (DAQ) Library

Snort has what is called a Data Acquisistion Library (DAQ). This is an abstraction layer for I/O (input/output) that enables us to plug different hardware/software interfaces for packet I/O. We can download it at snort.org as well.

635374181805481770.jpg

I've downloaded it and placed it on my Desktop as well.

635372952575912723.jpg

We go to the terminal and cd to the Desktop directory and then untar this file.

kali> tar xvfvz daq-2.0.2.tar.gz

Then we change directories to the new daq directory:

kali> cd daq-2.0.2

And configure it:

kali > ./configure

Then finally, make the file:

kali > make

Step 6: Install Snort

Now that we have all the files we need to run Snort, let's complete the installation of Snort. Change to the Desktop directory. You should see the Snort source code there.

635370367259976626.jpg

Next, let's change directories to /bin and make a directory in the /bin directory named snort. Let's now copy the snort source code to that directory:

kali > cp /root/Desktop/ snort-2.9.6.1.tar.gz /bin/snort

635370377194350146.jpg

Next, let's untar it:

kali > tar xzvf snort-2.9.6.1.tar.gz

635370378508256419.jpg

Step 7: Compile

In our final step, we need to compile Snort. Let's change to the new directory that was created when we untarred the source code file.

kali> cd /bin/snort/snort-2.9.6.1

Now, let's configure it.

kali > ./configure

635372958801381393.jpg

And finally, make Snort.

kali >make

Now we should have a compiled version of Snort specifically compiled for our platform! We can now run Snort by simply typing snort at the command prompt:

kali >snort

635372998171226360.jpg

Although the steps with differ slightly for different tools, the basic steps to compile a new tool are:

  1. Download the tool
  2. Untar and uncompress the tool
  3. Configure the tool
  4. Make the tool

Hope this all helps with having compiled Snort, but most importantly, I hope it helps with understanding how to compile ANY tool in Linux, and specifically, Kali. If all this seems too much, you can always simply use the package manager, aptitude (apt-get install snort). This will install the binaries for your platform, but not necessarily optimize it for your platform.

Keep coming back, my newbie hackers, as we continue along this exhilarating learning path to becoming pro hackers!

Cover image via Shutterstock

Comments

No Comments Exist

Be the first, drop a comment!