Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Penetration Testing with Raspberry PI
  • Table Of Contents Toc
  • Feedback & Rating feedback
Penetration Testing with Raspberry PI

Penetration Testing with Raspberry PI

4.6 (12)
close
close
Penetration Testing with Raspberry PI

Penetration Testing with Raspberry PI

4.6 (12)

Overview of this book

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.
Table of Contents (8 chapters)
close
close
7
Index

Combining Kali Linux and the Raspberry Pi

We know that it's tempting to just dive on into the Kali Linux interface and start running some great security tools. But first, there are some important housekeeping items to take care of. These items are as follows:

  • Changing our password.
  • Updating Kali Linux.
  • Resizing the partition to use all the available space on that large microSD (32 GB in our case). This will dramatically reduce the chance of running into common issues found with using Kali Linux on Raspberry Pi.

First on our list is to change our password. Kali Linux ships with the same default credentials, so we'll want to make sure that no one can log into our box except us. How embarrassing would be it if we had our penetration testing box penetrated by another party. Think of the irony there! To start this process, we need to open up a terminal and enter the passwd command. We'll be asked to type the password in twice to make sure that it is correct:

Combining Kali Linux and the Raspberry Pi

The other very important thing to do is to update Kali as soon as we can. This will ensure that we have the latest and greatest versions of code and applications. The process for updating Kali is pretty straightforward. We'll simply type the following commands into the CLI.

The upgrade will install all the newest version of the packages installed. The dist-upgrade command will install this plus intelligently updates all the dependencies with the new versions of packages. The dist-upgrade command is certainly not required, but we definitely recommend it:

apt-get update
apt-get upgrade
apt-get dist-upgrade

After this, we reboot our Raspberry Pi 3, and when it comes back, we should have a fully updated operating system, ready for playing around with some pen-testing tools.

Next, we want to resize the partition to use all the available space on our 32GB microSD card. We will show two different ways of doing this. The first way will be via the CLI. The second will take advantage of gparted in GUI.

Starting with CLI, if we run the  df -h  command, the following figure shows we don't have a partition that is close to the size of our microSD card. It is currently only at 6.7G:

Combining Kali Linux and the Raspberry Pi

The process to expand this partition involves a couple of steps. The following steps will help us unlock the full usable size of our microSD card. It is important to have that extra space for log files, command outputs, or tcpdumps.

We need to make sure that we follow the steps very carefully, as we wouldn't want to erase our root partition. This process uses the  fdisk, parted and resize2fs commands. Here is the process that we used:

  1. Let's check enter the disk utility, where we can view where the partitions currently stand. Here, we will want to run the fdisk command to check our current partitions:
    fdisk /dev/mmcblk0
    

    This will get us into the fdisk utility so that we can plan our changes to the partition table.

  2. Now we'll obtain partition information. Once at the Command (m for help) prompt, we'll enter p. This will dump out the partition information for our microSD card:

    Combining Kali Linux and the Raspberry Pi

  3. Now let's delete current partition. We'll exit from the fdisk utility by typing q. We now want to get into the parted utility and specify the microSD card we wish to modify. The device information was gleaned from the previous step. We can accomplish this by typing the following command:
    parted /dev/mmcblk0
    
  4. This will take us into the partition table utility. Once at the (parted) prompt, we will want to change the unit to chs, which is for cylinders, head, and sectors. This will allow us to get the correct numbers for the resize. To do this, let's type chs:
    (parted) unit chs
    
  5. Once we set the correct unit, we want to print out the partition information in the correct unit within parted. This will give us the correct sizes that will allow us to resize your partition. To do this, we'll just type print at the prompt:
    (parted) print
    
  6. Now, in this output, we are going to want to write down or remember the total size of the microSD card. This is found in the line that starts with Disk. In our example, it was the following:
    Disk /dev/mmcblk0:  3822,237,62
    
  7. Once we have the total size of the microSD in the chs unit, we can delete the second partition. Let's pay particular attention here, as we don't want to delete the root partition. At the prompt, we will want to type rm 2, where 2 is the partition number:
            (parted) rm 2
    
  8. We will be prompted with an error and asked to either Ignore or Cancel. Let's type i to ignore:
    Ignore/Cancel? i
    
  9. We have now removed the unneeded partition. We can confirm this by printing out the partition information again, and it will show that only one exists:
    (parted) print
    
  10. At this point, we can see that we only have that one partition and are ready to create the extended partition that uses all of the available space. The following figure is a screenshot of all that we talked about in steps 3-9:

    Combining Kali Linux and the Raspberry Pi

  11. Now let's create the new partition. We will use parted again, but this time to create the partition. First, let's start the tool by entering the parted command. Once in parted, we can make the new larger partition. This is where those numbers we saw and recorded in the parted print command in the previous section come into play. At the prompt, we will want to use mkpart to make the partition, with the first number being one number higher than the End sector number on the first partition. The second number is the disk number size we saw in that same output. For our microSD card partition, we ran the following command:
    (parted) mkpart primary 7,199,9 3822,237,62
    
  12. Once that command has been entered, we will get a warning; we can hit i to ignore it. After that, we want to verify that our partition has been created. We can use the print command under parted to accomplish this. We should see the second entry, which shows the correct usable space for our microSD card. We can now quit out of parted. The following screenshot shows steps 11 and 12 of our example:

    Combining Kali Linux and the Raspberry Pi

  13. Let's expand the filesystem. Now that we have all this space, we want to make sure that the filesystem can take advantage of it. We can accomplish this by using the resize2fs command. We will run this against that newly formed partition. The following command results in the following screenshot:
    resize2fs /dev/mmcblk0p2
    

    Combining Kali Linux and the Raspberry Pi

  14. Finally, we'll need to perform some verification. We can now verify that everything worked as planned if you run that same df -h command we did initially. We should see that the size closely matches our microSD card's advertised usable space:

    Combining Kali Linux and the Raspberry Pi

Now that we've seen the CLI commands to increase that partition size, let's look at another way of using the GUI interface within Kali Linux. These steps will walk through the process:

  1. The tool we use is gparted, which is installed using the following command:
    apt-get install gparted
    

    Combining Kali Linux and the Raspberry Pi

  2. Once we have installed it, we can launch it via command line (via X over SSH) using gparted. Once the GUI has started, we can click on the Resize/Move button:

    Combining Kali Linux and the Raspberry Pi

  3. From here, we will click on the edge of the fat16 partition and drag it over to include all of the unallocated space:

    Combining Kali Linux and the Raspberry Pi

  4. Now we will click on Apply and verify that we indeed want this operation:

    Combining Kali Linux and the Raspberry Pi

  5. It will take some time, but it will show us the progress of our repartitioning:

    Combining Kali Linux and the Raspberry Pi

  6. Once it's completed, we can now see that the fat16 partition that Kali Linux resides in now has direct access to the entire SD card:

    Combining Kali Linux and the Raspberry Pi

  7. While it is useful to consume the entire physical drive with this partition, we may have situations that require multiple partitions to be used. We can certainly adjust our approach with gparted to accomplish this.
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Penetration Testing with Raspberry PI
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon