Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Raspberry Pi for Secret Agents - Third Edition
Raspberry Pi for Secret Agents - Third Edition
Raspberry Pi for Secret Agents - Third Edition
Ebook564 pages3 hours

Raspberry Pi for Secret Agents - Third Edition

Rating: 0 out of 5 stars

()

Read preview

About this ebook

About This Book
  • Turn your Raspberry Pi into a multi-purpose secret agent gadget for audio and video surveillance, Wi-Fi exploration, or playing pranks on your friends
  • Detect an intruder on camera or with sensors and set off an alarm or receive messages to your phone
  • Find out what the other computers on your network are up to and make yourself anonymous on the Internet
  • This book has been updated for new additions to your toolkit featuring the tiny, recently released Raspberry Pi Zero board
Who This Book Is For

This book targets people who are new to the Raspberry Pi Zero or Raspberry Pi 2, have some experience with the original Raspberry Pi models, and even budding secret agents who would like to use the Raspberry Pi Zero as a secret agent toolbox. No programming experience is assumed. Suitable for the novice and expert alike, each topic provides a fast and easy way to get started with exciting applications, with practical examples in every chapter.

LanguageEnglish
Release dateJul 27, 2016
ISBN9781786461667
Raspberry Pi for Secret Agents - Third Edition
Author

Matthew Poole

Matthew Poole (1624-79), author of the famous Synopsis Criticorum Biblicum, was a seventeenth century ecclesiastical leader, nonconformist, apologist and minister in England. Poole is best remembered for his Synopsis in the scholarly Latin tongue, and his English language Annotations upon the Holy Bible.

Read more from Matthew Poole

Related to Raspberry Pi for Secret Agents - Third Edition

Related ebooks

Programming For You

View More

Related articles

Reviews for Raspberry Pi for Secret Agents - Third Edition

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Raspberry Pi for Secret Agents - Third Edition - Matthew Poole

    Table of Contents

    Raspberry Pi for Secret Agents - Third Edition

    Credits

    About the Author

    About the Reviewer

    www.PacktPub.com

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Downloading the color images of this book 

    Errata

    Piracy

    Questions

    1. Getting up to No Good

    A brief history lesson on the Pi

    Raspberry Pi Model A

    Raspberry Pi Model B

    Raspberry Pi Model B+

    Raspberry Pi Model 2

    Raspberry Pi Zero

    Raspberry Pi 3

    So, which Pi for us spies?

    Where to buy a Pi

    The ins and outs of the Raspberry Pi

    GPIO headers

    Audio/Video jack

    Status LEDs

    USB

    Ethernet port

    CSI camera connector

    Display Serial Interface

    HDMI

    Power

    MicroSD card

    Preparing the SD card

    Download the Raspbian image

    Using Microsoft Windows

    Using Linux

    Boot up your Pi

    Expand the filesystem

    Goodbye GUI

    Using the raspi-config utility

    Setting up your Pi

    The importance of a sneaky headless setup

    Keeping your system up to date

    Backing up your SD card

    Complete SD card backup in Windows

    Complete SD card backup in MAC OS X

    Complete SD card backup in Linux

    Summary

    2. Audio Antics

    Configuring your audio gadgets

    Sound variations

    Introducing the ALSA sound system

    Controlling the volume

    Switching between HDMI and analog audio output

    Testing the speakers

    Preparing to record

    Testing the microphone

    Clipping, feedback distortion, and improving sound quality

    Recording conversations for later retrieval

    Writing to a WAV file

    Writing to an MP3 or OGG file

    Creating command shortcuts with aliases

    Keep your recordings running safely with tmux

    Making a covert wearable recorder with Pi Zero

    Listening in on conversations from a distance

    Listening in Windows

    Listening in Mac OS X or Linux

    Listening in over Bluetooth

    Introducing Bluetooth audio

    Setting up Bluetooth on the Pi

    Installing PulseAudio

    Connect to your Bluetooth headset or speaker

    Bluetooth by default

    Talking to people from a distance

    Talking in Windows

    Talking in Mac OS X or Linux

    Attention Mac users

    Talking in Bluetooth

    Distorting your voice in weird and wonderful ways

    Make your computer do the talking

    Scheduling your audio actions

    Start on power up

    Scheduled start

    Controlling recording length

    Start recording with noise detection

    Calling your fellow agents

    Setting up SIP Witch

    Connecting the softphones

    Windows (MicroSIP)

    Configuring the MicroSIP softphone for Windows

    Mac OS X (Telephone)

    Linux (Ring)

    Android (CSipSimple)

    iPhone/iPad (Linphone)

    Running a softphone on the Pi

    Encrypting SIP Witch passwords

    Setting up Linphone

    Playing files with Linphone

    Using your voice to control things

    Give your Pi some ears

    Bonus one-line sampler

    Summary

    3. Webcam and Video Wizardry

    Meet the USB Video Class drivers and Video4Linux

    Raspberry Pi Camera Module

    Connecting the camera module

    Setting up the camera module

    Using USB cameras

    Connecting the webcam

    Finding out your webcam's capabilities

    Capturing your target on film

    Viewing your camera in VLC media player

    Viewing in Windows

    Viewing in Mac OS X

    Viewing in Linux

    Recording the video stream

    Recording in Windows

    Recording in Mac OS X

    Recording in Linux

    Detecting an intruder and setting off an alarm

    Creating a motion detection configuration

    Trying out Motion

    Collecting the evidence

    Viewing and e-mailing the evidence

    Hooking up more cameras

    Preparing a webcam stream in Windows

    Preparing a webcam stream in Mac OS X

    Configuring MotionEye for multiple input streams

    Watching your camera over the Internet

    The link between the Pi and the broadcasting service

    Night vision

    Make a covert wearable recorder with Pi Zero

    Turning your TV on or off using the Pi

    Scheduling a playback scare

    Summary

    4. Wi-Fi Pranks – Exploring Your Network

    Getting an overview of all the computers on your network

    Monitoring Wi-Fi airspace with Kismet

    Preparing Kismet for launch

    First Kismet session

    Adding sound and speech

    Enabling rogue access point detection

    Mapping out your network with Nmap

    Finding out what the other computers are up to

    How encryption changes the game

    Traffic logging

    Shoulder surfing in Elinks

    Pushing unexpected images to browser windows

    Knocking all visitors off your network

    Protecting your network against Ettercap

    Analyzing packet dumps with Wireshark

    Running Wireshark in Windows

    Running Wireshark in Mac OS X

    Running Wireshark in Linux

    Exploring dynamic DNS, port forwarding, and tunneling

    Dynamic DNS

    Choosing your domain name

    Verifying your domain name

    Updating your domain name

    Port forwarding

    Adding the forwarding rule

    Verifying your port forwarding

    Port forwarding security

    Connected at last

    Tunneling

    Port tunneling in Windows

    Port tunneling in Linux or Mac OS X

    Creating a diversion using a chat bot

    Introducing XMPP

    Useful Profanity

    Connecting to Google chat

    Connecting to XMPP servers

    Getting around Profanity

    Project AgentBot

    Awakening the bot

    Keeping your conversations secret with encryption

    Summary

    5. Taking Your Pi Off-Road

    Keeping the Pi dry and running with housing and batteries

    Setting up point-to-point networking

    Creating a direct wired connection

    Static IP assignment in Windows

    Static IP assignment in Mac OS X

    Static IP assignment in Linux

    Turning the Pi into a Wi-Fi hotspot

    Connecting the Pi to the mobile Internet

    Multiple personalities

    Switching modes

    Automatic mode-switching

    Be anonymous on the Internet

    Know your onions

    Setting up the Wi-Fi access point

    Installing and setting up a DHCP server

    Set up the routing tables

    Installing and setting up Tor

    Test your anonymity

    Tracking the Pi's whereabouts using GPS

    Tracking the GPS position on Google Earth

    Preparing a GPS beacon on the Pi

    Setting up Google Earth

    Setting up a GPS waypoint logger

    Mapping GPS data from Kismet

    Using GPS as a time source

    Setting up GPS on boot

    Controlling the Pi with your smartphone

    Android (Raspi SSH)

    iPhone/iPad (SSH Remote)

    Common remote control commands

    Receiving status updates from the Pi

    Tagging tweets with GPS coordinates

    Sending e-mail updates

    Installing and setting  up the SMTP client

    Sending attachments

    Scheduling regular updates

    Accessing your files from anywhere with Dropbox

    Keeping your data secret with encryption

    Erasing the Pi should it fall into the wrong hands

    Encrypting your home with eCryptfs

    Rigging the self-destruct mechanism

    Jam the airwaves with a Pi Zero

    Installing PiFm

    Broadcasting to the airwaves

    Summary

    6. Detecting and Protecting Against Your Enemies

    Say hello to the GPIO

    Power connections

    Building a laser trip wire

    How it works

    Wiring it up

    Writing the detection script

    Protecting an entire area

    Wiring it up

    Implementing the detection script

    Sending alerts to your phone using SMS

    SMS gateway

    Sending messages through the API

    Use your phone as an access control device

    Probe Requests

    Scanning with tshark

    Displaying secret codes and messages

    Enabling the serial port

    Connecting the Pi-Lite

    Encoding our messages

    Writing the encoder script

    Sending our text to the display

    Better security with a true random number generator

    Kernel entropy pool

    Setting up our hardware RNG

    Enabling the hardware RNG in Raspbian Wheezy

    Enabling the hardware RNG in Raspbian Jessie

    Testing the hardware RNG

    Using the HWRNG for our entropy pool

    Exporting the HWRNG data to another Linux server

    Connecting the UART pins

    Transferring entropy to the serial port

    Receiving entropy on the server

    Summary

    Graduation

    Raspberry Pi for Secret Agents - Third Edition


    Raspberry Pi for Secret Agents - Third Edition

    Copyright © 2016 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: April 2013

    Second edition: January 2015

    Third edition: July 2016

    Production reference: 1210716

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham 

    B3 2PB, UK.

    ISBN 978-1-78646-354-8

    www.PacktPub.com

    Cover image by Connecting Objects (connectingobjects.com)

    Credits

    About the Author

    Matthew Poole is a systems engineer based near Southampton on the south coast of England, with over 20 years of industry experience. After graduating in electronics and communications engineering, he went on to train as and become an air traffic engineer for Civil Aviation Authority, UK, working on microprocessor-based control and communications systems.

    Later, he became a software architect and mobile technology specialist, working for several consultancies and global organizations in both hands-on architecture and product-management roles .

    He is now a partner at Connecting Objects, a boutique systems consultancy focusing on the design of Bluetooth and other wireless-based IoT systems, taking ideas from concept to prototype. He is also the Director of Technology for Mobile Onboard, a leading UK-based transport technology company specializing in bus connectivity and mobile ticketing systems.

    He is also the author of Building a Home Security System with Raspberry Pi, Packt Publishing.

    You can find his blog at http://cubiksoundz.com and LinkedIn profile at https://www.linkedin.com/in/cubik, or you can reach him on Twitter at @cubiksoundz.

    About the Reviewer

    Jon Witts has been working within the IT industry since 2002 and specifically within educational IT since 2004. He was introduced to Linux back in 2001 through his collaboration with two German artists who were visiting the arts organization he was then working with. Having studied Fine Arts and Educational Technology, and having sought to innovate with open and accessible digital technologies within his creative practice, Jon is happiest when deconstructing technology and finding its limits.

    Jon has embedded within his school the use of Raspberry Pi computers, as an integral part of the delivery of the school’s Computer Science curriculum, as well as to run various school clubs and projects. Jon is a Raspberry Pi Certified Educator and also helps to organize and run the Hull Raspberry Jam events.

    I would like to thank my wife, Sally, and our three daughters for putting up with all the cables and components around the house, not least for being so tolerant of the need to dodge the robots racing round the kitchen floor!

    www.PacktPub.com

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

    Preface

    The Raspberry Pi was developed with the intention of promoting basic computer science in schools, but the Pi also represents a welcome return to simple, fun, and open computing.

    Using gadgets for purposes other than the intended ones, especially for mischief and pranks, has always been an important part of adopting a new technology and making it your own.

    With a  £25 Raspberry Pi computer and a few common USB gadgets, anyone can afford to become a secret agent.

    This third edition by Matthew Poole takes the previous edition's projects and brings them up to date to now support the new Raspberry Pi Zero, Raspberry Pi Version 3, and the Raspbian Jessie operating system.

    There is also a new chapter that looks at ways to connect sensors and gadgets to our Pi to protect ourselves against other would-be secret agents.

    What this book covers

    Chapter 1,Getting Up to No Good, looks at all of the different models of the Raspberry Pi available, and then takes you through the initial setup, preparing it for sneaky headless operations over the network.

    Chapter 2,Audio Antics, teaches you how to eavesdrop on conversations with a Pi Zero-based wearable voice recorder, or play pranks on friends by broadcasting your own distorted voice from a distance using the Bluetooth audio.

    Chapter 3, Webcam and Video Wizardry, shows you how to set up a webcam video feed with built-in motion detection that can be used to detect intruders, or to stage a playback scare by automatically switching on a TV.

    Chapter 4, Wi-Fi Pranks – Exploring Your Network, teaches you how to capture, manipulate, and spy on the traffic that flows through your network.

    Chapter 5, Taking Your Pi Off-Road, shows you how to encrypt your Pi and send it away on missions while keeping in touch with it via smartphone, GPS, and Twitter updates. You'll also learn how to turn your Pi into a cellular 4G-connected router while staying anonymous on the Internet.

    Chapter 6, Detecting and Protecting Against Your Enemies, looks at ways to detect infiltrations and protect ourselves against other would-be spies, by plugging sensors and other gadgets into our Raspberry Pi, alerting us when people stray into our territories.

    What you need for this book

    The following hardware is recommended for maximum enjoyment:

    The Raspberry Pi computer (Version 2/Version 3, and Pi Zero)

    An SD card (4 GB minimum, class 10 recommended)

    A PC/laptop running Windows, Linux, or Mac OS X with an internal or external SD card reader

    A Pi Zero connector kit

    A USB microphone / sound card (projects verified with Formosa AS301 Tube Delight and pluggable USB audio adapter.

    A USB Bluetooth adapter (projects verified with Cambridge Silicon Radio dongles) or Pi 3 onboard Bluetooth

    A Bluetooth headset and/or speaker

    Official Raspberry Pi Camera module

    A camera module or USB webcam (projects verified with Logitech C270)

    A USB Wi-Fi adapter (projects verified with Farnell element14 Wi-Pi dongle)

    A USB 3G/4G modem (projects verified with Huawei E3372 HiLink modem)

    A USB GPS receiver (projects verified with U-blox7)

    A lithium polymer battery pack (projects verified with RS Components USB Power Banks and iMuto X4)

    Waveshare Laser Sensor module

    LED matrix display (project verified with the Ciesco Pi-Lite board)

    Passive IR motion sensor (projects verified with Parallax 555-28027)

    USB to 3.3V TTL serial/UART converter

    An Android phone or iPhone (projects verified with Samsung Galaxy S7 Edge and iPhone 4S)

    All software mentioned in this book is free of charge and can be downloaded from the Internet.

    Who this book is for

    This book is for all the mischievous Raspberry Pi owners who would like to see their computer transformed into a neat spy gadget to be used in a series of practical pranks and projects. No previous skills are required to follow the book, and if you're completely new to Linux, you'll pick up most of the basics along the way.

    Conventions

    In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

    Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: The cat command is commonly used to output the contents of text files, and /proc/asound is a directory.

    A block of code is set as follows:

    #!/bin/bash

    sudo echo 17 > /sys/class/gpio/export

    sudo echo in > /sys/class/gpio/gpio17/direction

    # loop forever

    while true

    do

      # read the beam state

      BEAM=$(sudo cat /sys/class/gpio/gpio17/value)

    Any command-line input or output is written as follows:

    pi@raspberrypi ~ $ cat /proc/asound/cards

    New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Just right-click on the image file and select Send to, then click on Compressed (zipped) folder.

    Note

    Warnings or important notes appear in a box like this.

    Tip

    Tips and tricks appear like this.

    Reader feedback

    Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

    To send us general feedback, simply e-mail feedback@packtpub.com, and mention the book's title in the subject of your message.

    If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

    Customer support

    Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

    Downloading the example code

    You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

    You can download the code files by following these steps:

    Log in or register to our website using your e-mail address and password.

    Hover the mouse pointer on the SUPPORT tab at the top.

    Click on Code Downloads & Errata.

    Enter the name of the book in the Search box.

    Select the book for which you're looking to download the code files.

    Choose from the drop-down menu where you purchased this book from.

    Click on Code Download.

    Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

    WinRAR / 7-Zip for Windows

    Zipeg / iZip / UnRarX for Mac

    7-Zip / PeaZip for Linux

    The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Raspberry-Pi-for-Secret-Agents-Third-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

    Downloading the color images of this book 

    We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/RaspberryPiforSecretAgentsThirdEdition_ColorImages.pdf.

    Errata

    Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book.

    Enjoying the preview?
    Page 1 of 1