Header Banner
Null Byte Logo
Null Byte
wonderhowto.mark.png
Cyber Weapons Lab Forum Metasploit Basics Facebook Hacks Password Cracking Top Wi-Fi Adapters Wi-Fi Hacking Linux Basics Mr. Robot Hacks Hack Like a Pro Forensics Recon Social Engineering Networking Basics Antivirus Evasion Spy Tactics MitM Advice from a Hacker

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
A stylized pig logo overlaid on a binary code background.

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.

Download Snort

You can download Snort at snort.org.

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

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

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

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.

Downloading a file from a web browser interface.

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

Kali Linux desktop environment with application icons.

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

Terminal output displaying the installation process of various Linux packages.

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

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

Command line interface showing a file download in progress.

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.

Terminal window displaying installation confirmation for the library package 'libret' on a Linux system.

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

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.

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

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

Kali Linux desktop interface with file icons and a blue dragon logo.

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

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.

Terminal window displaying a directory listing.

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

Command line interface showing directory navigation and file listing in a Unix-like operating system.

Next, let's untar it:

kali > tar xzvf snort-2.9.6.1.tar.gz

Terminal window displaying a file extraction command for dnnrt-2.6.1.tar.gz in a Linux environment.

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

Command line interface displaying compilation checks for the software package 'mmap' on a Unix system.

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

Packet processing output from Snort, an open-source intrusion detection system.

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

The next big software update for iPhone is coming sometime in April and will include a Food section in Apple News+, an easy-to-miss new Ambient Music app, Priority Notifications thanks to Apple Intelligence, and updates to apps like Mail, Photos, Podcasts, and Safari. See what else is coming to your iPhone with the iOS 18.4 update.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!