10.09.2016 Views

Hacking_and_Penetration_Testing_with_Low_Power_Devices

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Adding tools the hard way<br />

71<br />

described in the preceding text <strong>with</strong> one small exception. You must tell the configure<br />

script the target architecture <strong>and</strong> the location of the correct header <strong>and</strong> library files by<br />

running ./configure –host¼arm-linux-gnueabihf –prefix¼/usr/arm-linuxgnueabihf<br />

from <strong>with</strong>in the source directory.<br />

As <strong>with</strong> native compilation, you may find that the build fails due to missing<br />

libraries. This can be a somewhat frustrating experience. You will need to download<br />

<strong>and</strong> cross compile any dependent packages before you can proceed to build the tool<br />

you really wanted. If a program has more than a couple of dependencies, it might be<br />

worthwhile to build it directly on the Beagle.<br />

Some simpler programs might have only a Makefile <strong>with</strong>out a configure script,<br />

which is used to generate the Makefile. In many cases, executing the comm<strong>and</strong><br />

CC¼arm-linux-gnueabihf-gcc make will tell the make utility to substitute the cross<br />

compiler for the default native compiler. You will need to double-check the output as<br />

the package builds to see if this is working properly. Some developers hard-code the<br />

compile comm<strong>and</strong> into their Makefile <strong>and</strong> you might have to change gcc, g++, etc. to<br />

have the arm-linux-gnueabihf- prefix.<br />

CROSS COMPILING USING ECLIPSE<br />

Eclipse is a widely used <strong>and</strong> powerful integrated development environment (IDE)<br />

that runs on several operating systems. It has become the de facto st<strong>and</strong>ard in several<br />

areas of software development. The vast majority of compiled tools for Linux systems<br />

are written in C or C++. All of the hacking tools written in compiled languages<br />

included <strong>with</strong> The Deck are written in C <strong>and</strong>/or C++.<br />

Eclipse is available for download from http://www.eclipse.org/downloads/ in<br />

several different packages for different kinds of developers. One of the packages<br />

available is configured for C/C++ development work. A tar ball can be downloaded<br />

from the Eclipse website. In order to avoid any problems <strong>with</strong> dependencies <strong>and</strong><br />

automatically create menu entries, it may be more convenient to install Eclipse from<br />

your Linux repositories. If you are running Ubuntu, everything you need can be<br />

installed <strong>with</strong> the comm<strong>and</strong> sudo apt-get install eclipse eclipse-cdt. One<br />

downside of using the repositories is that you might not have the most up-to-date<br />

version of Eclipse. This is likely not a concern for our purposes.<br />

Using existing make files<br />

For our purposes, we are likely to have a project <strong>with</strong> an existing Makefile. Eclipse<br />

has the ability to create a new project from an existing code complete <strong>with</strong> a Makefile.<br />

Run Eclipse <strong>and</strong> then select File->New->Other <strong>and</strong> you will be presented <strong>with</strong><br />

the dialog box shown in Figure 4.1. Select Makefile Project <strong>with</strong> Existing Code under<br />

C/C++ as shown in the figure <strong>and</strong> then click Next.<br />

Give your project a name, point Eclipse to the correct directory, <strong>and</strong> select the<br />

Cross GCC toolchain from the dialog box as shown in Figure 4.2. Then, click Finish<br />

to create your project. We aren’t done yet. You will likely want to create a new build<br />

configuration by right-clicking your project in the Project Explorer window <strong>and</strong> then

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!