Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Penetration Testing with Raspberry PI
Penetration Testing with Raspberry PI

Penetration Testing with Raspberry PI: Construct a hacking arsenal for penetration testers or hacking enthusiasts using Kali Linux on a Raspberry Pi

eBook
S$24.99 S$35.99
Paperback
S$44.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Penetration Testing with Raspberry PI

Chapter 2. Preparing the Raspberry Pi

The Raspberry Pi should be considered an underpowered platform for security assessments. This is because it has been designed as a low-cost, portable computer primarily targeting educationalists and hobbyists. This open platform may be limited in computing power, but it does provide many powerful use cases that security professionals can leverage for penetration testing and other service engagements. The focus of this chapter will be on how to prepare a Raspberry Pi running Kali Linux (or other platforms) for a penetration test.

The following topics will be covered in this chapter:

  • Raspberry Pi use cases
  • The Command and Control server
  • Preparing for a penetration test
  • Overclocking
  • Setting up wireless cards
  • Setting up a 3G USB modem with Kali Linux
  • Setting up the SSH service
  • SSH default keys and management
  • Reverse shell through SSH
  • Stunnel
  • Wrapping up with an example

Raspberry Pi use cases

Raspberry Pi is a common requirement for security professionals to gather information from remote sites in large distributed organizations. Many people leverage commercial tools that specialize in vulnerability assessments for this situation; however, you may not have access to such tools due to a limited budget or vendor partnership requirements. An example of this situation is when the authors of this book had to take part in a security assessment that included multiple locations all over the world. For this project, it was not feasible to travel to every location to deliver local penetration testing services. To overcome this, we sent Raspberry Pi devices configured with Kali Linux to each location and remotely assessed the network for vulnerabilities at a very affordable price. We will cover this engagement example in more detail at the end of this chapter.

Another valuable use case for a Raspberry Pi is when a security professional wants to leave a device on...

The Command and Control server

As we have stated in other chapters, the Raspberry Pi is not a powerful machine. To overcome this weakness, it is best practice to capture data in a controlled manner or leverage offline computing when using Kali Linux on a Raspberry Pi. We found that not doing so would either overwhelm the processors when using most of the attack tools or quickly consume the limited local storage space when viewing captured data. We will cover filtering captured data in Chapter 3, Penetration Testing, under the Tuning your network capture section.

When planning to remotely access multiple Raspberry Pi systems, we recommend setting up a central Command and Control (C&C) server rather than accessing each box individually. The C&C server should be a more powerful system such as a traditional server so it can focus on CPU intensive tasks such as breaking passwords through brute force. More importantly, tasks can also include using the C&C server to perform the actual...

Preparing for a penetration test

The Kali Linux ARM image we covered in Chapter 1, Raspberry Pi and Kali Linux Basics, has already been optimized for a Raspberry Pi. We found however that it is recommended to perform a few additional steps to ensure you are using Kali Linux in the most stable mode to avoid crashing the Raspberry Pi. The steps are as follows:

  1. The first recommended step is to perform the OS updates as described in detail in Chapter 1, Raspberry Pi and Kali Linux Basics. We won't repeat the steps here, so if you have not updated your OS, please go back to Chapter 1, Raspberry Pi and Kali Linux Basics, and follow the instructions.
  2. The next step you should perform is to properly identify your Raspberry Pi. The Kali Linux image ships with a generic hostname. To change the hostname, use the vi editor (although feel free to use any editor of your choice; even if you are a fan of nano, we won't judge you much) with the vi /etc/hostname command as shown in the following screenshot...

Overclocking

Overclocking the Raspberry Pi can improve the performance. The risk of doing this can also greatly reduce the life of the hardware. Overclocking may require more power from the Raspberry Pi, so if you are powering it from a weak power source, overclocking could cause issues. We have had some problems resulting in what appears to be corruption in microSD cards and operating systems when overclocking the Raspberry Pi.

Note

Only overclock the Raspberry Pi if you can accept the risk that you may permanently damage your system.

To overclock the Raspberry Pi, you can use the raspi-config application for advanced hardware manipulation. Unfortunately, this application does not come with the Kali Linux image and requires some configuration. Don't worry; we have made the following steps pretty easy for you to follow. They are:

  1. From your Raspberry Pi command line, type:
    wget http://www.drchaos.com/wp-content/uploads/2014/09/raspberry_pi_overclock_files.zip
    

    Tip

    You can also use the official...

Setting up wireless cards

When you purchase a Wi-Fi adapter for your Raspberry Pi, you want to make sure it not only works with the Raspberry Pi, but also works with Kali Linux. Luckily, almost every Wi-Fi adapter we used works with both the Raspberry Pi and Kali Linux. In this book, we are using the CanaKit Wi-Fi dongle, as shown in the following image:

Setting up wireless cards

CanaKit makes an extremely popular Raspberry Pi kit that ships with this version of the Wi-Fi adapter. You can also purchase an adapter separately. If you need to purchase a separate card, make sure it is one that works with Debian Linux.

Tip

A good resource for compatible cards is http://elinux.org/RPi_USB_Wi-Fi_Adapters.

Once you connect your Wi-Fi adapter, you should first verify that the system shows it is functioning properly. You can do this by issuing the iwconfig command in a terminal window as shown in the following screenshot:

Setting up wireless cards

You should see a wlan0 interface representing your new wireless interface. The next step is to enable the...

Raspberry Pi use cases


Raspberry Pi is a common requirement for security professionals to gather information from remote sites in large distributed organizations. Many people leverage commercial tools that specialize in vulnerability assessments for this situation; however, you may not have access to such tools due to a limited budget or vendor partnership requirements. An example of this situation is when the authors of this book had to take part in a security assessment that included multiple locations all over the world. For this project, it was not feasible to travel to every location to deliver local penetration testing services. To overcome this, we sent Raspberry Pi devices configured with Kali Linux to each location and remotely assessed the network for vulnerabilities at a very affordable price. We will cover this engagement example in more detail at the end of this chapter.

Another valuable use case for a Raspberry Pi is when a security professional wants to leave a device on-site...

The Command and Control server


As we have stated in other chapters, the Raspberry Pi is not a powerful machine. To overcome this weakness, it is best practice to capture data in a controlled manner or leverage offline computing when using Kali Linux on a Raspberry Pi. We found that not doing so would either overwhelm the processors when using most of the attack tools or quickly consume the limited local storage space when viewing captured data. We will cover filtering captured data in Chapter 3, Penetration Testing, under the Tuning your network capture section.

When planning to remotely access multiple Raspberry Pi systems, we recommend setting up a central Command and Control (C&C) server rather than accessing each box individually. The C&C server should be a more powerful system such as a traditional server so it can focus on CPU intensive tasks such as breaking passwords through brute force. More importantly, tasks can also include using the C&C server to perform the actual...

Preparing for a penetration test


The Kali Linux ARM image we covered in Chapter 1, Raspberry Pi and Kali Linux Basics, has already been optimized for a Raspberry Pi. We found however that it is recommended to perform a few additional steps to ensure you are using Kali Linux in the most stable mode to avoid crashing the Raspberry Pi. The steps are as follows:

  1. The first recommended step is to perform the OS updates as described in detail in Chapter 1, Raspberry Pi and Kali Linux Basics. We won't repeat the steps here, so if you have not updated your OS, please go back to Chapter 1, Raspberry Pi and Kali Linux Basics, and follow the instructions.

  2. The next step you should perform is to properly identify your Raspberry Pi. The Kali Linux image ships with a generic hostname. To change the hostname, use the vi editor (although feel free to use any editor of your choice; even if you are a fan of nano, we won't judge you much) with the vi /etc/hostname command as shown in the following screenshot:

    The...

Overclocking


Overclocking the Raspberry Pi can improve the performance. The risk of doing this can also greatly reduce the life of the hardware. Overclocking may require more power from the Raspberry Pi, so if you are powering it from a weak power source, overclocking could cause issues. We have had some problems resulting in what appears to be corruption in microSD cards and operating systems when overclocking the Raspberry Pi.

Note

Only overclock the Raspberry Pi if you can accept the risk that you may permanently damage your system.

To overclock the Raspberry Pi, you can use the raspi-config application for advanced hardware manipulation. Unfortunately, this application does not come with the Kali Linux image and requires some configuration. Don't worry; we have made the following steps pretty easy for you to follow. They are:

  1. From your Raspberry Pi command line, type:

    wget http://www.drchaos.com/wp-content/uploads/2014/09/raspberry_pi_overclock_files.zip
    

    Tip

    You can also use the official...

Setting up wireless cards


When you purchase a Wi-Fi adapter for your Raspberry Pi, you want to make sure it not only works with the Raspberry Pi, but also works with Kali Linux. Luckily, almost every Wi-Fi adapter we used works with both the Raspberry Pi and Kali Linux. In this book, we are using the CanaKit Wi-Fi dongle, as shown in the following image:

CanaKit makes an extremely popular Raspberry Pi kit that ships with this version of the Wi-Fi adapter. You can also purchase an adapter separately. If you need to purchase a separate card, make sure it is one that works with Debian Linux.

Tip

A good resource for compatible cards is http://elinux.org/RPi_USB_Wi-Fi_Adapters.

Once you connect your Wi-Fi adapter, you should first verify that the system shows it is functioning properly. You can do this by issuing the iwconfig command in a terminal window as shown in the following screenshot:

You should see a wlan0 interface representing your new wireless interface. The next step is to enable the interface...

Setting up a 3G USB modem with Kali Linux


You can use 3G USB modem cards with Kali Linux and connect to your Raspberry Pi over cellular for stealthy remote access. Each card is manufactured a little differently, and therefore the setup may vary based on the type of 3G card and service provider. Our recommendation is using a MiFi (short for Mobile Wi-Fi) hotspot and connecting Kali Linux through a Wi-Fi adapter; however, if you want to use a 3G USB modem, make sure you verify it works with Debian.

In our next example, we use the Huawei 3G USB modem connect card. This is a 3G GSM card that works with most frequencies around the globe.

Here are the steps to set up this card:

  1. Open up a terminal window and type in the following command:

    wget http://www.ziddu.com/download/22764375/3gusbmodem.zip.html
    
  2. Unzip the file issuing the unzip command.

  3. Make changes in the directory you just unzipped.

  4. Make the file an executable by typing in chmod +x 3gusbm*.

  5. Run the script by typing ./3gusbmodem –interactive.

  6. The...

Setting up the SSH service


The Secure Shell (SSH) gives you full access to the Kali Linux operating system on a Raspberry Pi from a remote location. It is the most common way to manage Linux systems using a command line. Since the Kali Linux GUI is not needed for most penetration testing exercises, we recommend that you use SSH or command-line utilities whenever possible. We found some installations of Kali Linux have SSH enabled while others may need you to install the OpenSSH server.

You should first verify whether the SSH service is installed. Type in the service --status-all command to check whether the SSH service is running. If you see + as shown in the following screenshot, you are good to go. If you see a - sign, then you will need to install the OpenSSH server.

To install the OpenSSH server, open a command-line terminal and type apt-get install openssh-server to install the SSH services. You will need to start the SSH services by issuing the service ssh start command as shown in the...

SSH default keys and management


At this point, you have a Raspberry Pi ready for remote management using SSH. This is good; however, the keys that are installed by default are extremely predictable with every other default installation for OpenSSH. Although this is optional, best practice is changing the default keys. After all, it would be embarrassing if your penetration testing machine got hacked.

Here are the steps to create a new SSH key for your Kali Linux system:

Note

Make sure you use a keyboard and console for the following steps. Do not attempt to perform the following steps over an existing SSH session.

  1. Move the default SSH keys by typing the following into the terminal or command line:

    cd /etc/ssh/
    mkdir default_kali_keys
    mv ssh_host_* default_kali_keys/
    
  2. Generate a new key by using the following command and watching the prompts:

    dpkg-reconfigure openssh-server
    Creating SSH2 RSA key; this may take some time ...
    Creating SSH2 DSA key; this may take some time ...
    Creating SSH2 ECDSA...
Left arrow icon Right arrow icon

Description

If you are looking for a low budget, small form-factor remotely accessible hacking tool, then the concepts in this book are ideal for you. If you are a penetration tester who wants to save on travel costs by placing a low-cost node on a target network, you will save thousands by using the methods covered in this book. You do not have to be a skilled hacker or programmer to use this book. It will be beneficial to have some networking experience; however, it is not required to follow the concepts covered in this book.

Who is this book for?

If you are looking for a low budget, small form-factor remotely accessible hacking tool, then the concepts in this book are ideal for you. If you are a penetration tester who wants to save on travel costs by placing a low-cost node on a target network, you will save thousands by using the methods covered in this book. You do not have to be a skilled hacker or programmer to use this book. It will be beneficial to have some networking experience; however, it is not required to follow the concepts covered in this book.

What you will learn

  • Install and tune Kali Linux on a Raspberry Pi for hacking
  • Use a Raspberry Pi for pentests such as breaking wireless security, scanning networks, and capturing sensitive data
  • Perform maninthemiddle attacks and bypass SSL encryption
  • Compromise systems using various exploits and toolkits
  • Bypass security defenses and remove data off a target network
  • Develop a command and control system to manage remotely placed Raspberry Pis
  • Turn a Raspberry Pi into a honeypot to capture sensitive information
  • Grasp professional penetration testing through proper documentation

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 27, 2015
Length: 208 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396435
Category :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 27, 2015
Length: 208 pages
Edition : 1st
Language : English
ISBN-13 : 9781784396435
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 148.97
Raspberry Pi for Secret Agents - Second Edition
S$36.99
Kali Linux: Wireless Penetration Testing Beginner's Guide, Second Edition
S$66.99
Penetration Testing with Raspberry PI
S$44.99
Total S$ 148.97 Stars icon

Table of Contents

7 Chapters
1. Raspberry Pi and Kali Linux Basics Chevron down icon Chevron up icon
2. Preparing the Raspberry Pi Chevron down icon Chevron up icon
3. Penetration Testing Chevron down icon Chevron up icon
4. Raspberry Pi Attacks Chevron down icon Chevron up icon
5. Ending the Penetration Test Chevron down icon Chevron up icon
6. Other Raspberry Pi Projects Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(12 Ratings)
5 star 83.3%
4 star 0%
3 star 8.3%
2 star 8.3%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Zulu_Man Feb 06, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
You don't know a single thing about Rasberry Pi B+ and Pen Testing? This book is an awesome write and works in a chronological order. Starts from the very basic and guides you to advanced techniques. I highly recommend this! $10 for Kindle edition??? How can it not be worthy? Lol. Go buy it!
Amazon Verified review Amazon
Peter Dec 04, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good
Amazon Verified review Amazon
Cristian Gradisteanu Mar 14, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book on how to use this powerful little device for pen testing. It gives you the tools of the trade and the power of such a low consumption device to have your arsenal with you all the way. As a pen tester you will love this book!
Amazon Verified review Amazon
Aldhissla Sep 29, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
this book is amost the same of the book "penetration testing w/ kali linux"perfect book w/ explication for the raspberry
Amazon Verified review Amazon
Christophe21 Nov 20, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Si vous souhaitez utiliser votre Raspberry sur d'autres projets que les projets classiques, l'idée de profiter de la petite taille de cet ordinateur pour jouer au "man in the middle" sur un réseau (où vous êtes autorisé à pénétre...), ce livre est fait pour vous. Bien évidemment, les techniques proposées par l'ouvrage sont adaptées à la puissance du Raspberry, et donc pas nécessairement très performantes, mais cet ouvrage vous permettra de comprendre, à moindres frais, les rudiments des tests de pénétration. L'ouvrage est très pédagogique.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.