Raspberry Pi for Secret Agents
Total Page:16
File Type:pdf, Size:1020Kb
Raspberry Pi for Secret Agents Third Edition Turn your Raspberry Pi into a secret agent toolbox with this set of exciting projects Matthew Poole BIRMINGHAM - MUMBAI 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 Author Copy Editor Matthew Poole Safis Editing Reviewer Project Coordinator Jon Witts Kinjal Bari Commissioning Editor Proofreader Kartikey Pandey Safis Editing Acquisition Editor Indexer Tushar Gupta Tejal Daruwale Soni Content Development Editor Production Coordinator Trusha Shriyan Arvindkumar Gupta Technical Editor Rupali R. Shrawane 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 h t t p : / / c u b i k s o u n d z . c o m and LinkedIn profile at h t t p s : / / w w w . l i n k e d i n . c o m / i n / c u b i k, 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 [email protected] 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. h t t p s : / / w w w 2 . p a c k t p u b . c o m / b o o k s / s u b s c r i p t i o n / p a c k t l i b 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. Table of Contents Preface 1 Chapter 1: Getting up to No Good 7 A brief history lesson on the Pi 7 Raspberry Pi Model A 9 Raspberry Pi Model B 10 Raspberry Pi Model B+ 11 Raspberry Pi Model 2 12 Raspberry Pi Zero 13 Raspberry Pi 3 15 So, which Pi for us spies? 16 Where to buy a Pi 17 The ins and outs of the Raspberry Pi 17 GPIO headers 18 Audio/Video jack 19 Status LEDs 19 USB 19 Ethernet port 19 CSI camera connector 19 Display Serial Interface 20 HDMI 20 Power 20 MicroSD card 21 Preparing the SD card 21 Download the Raspbian image 21 Using Microsoft Windows 22 Using Linux 23 Boot up your Pi 24 Expand the filesystem 25 Goodbye GUI 25 Using the raspi-config utility 26 Setting up your Pi 27 The importance of a sneaky headless setup 30 Keeping your system up to date 31 Backing up your SD card 31 Complete SD card backup in Windows 32 Complete SD card backup in MAC OS X 33 Complete SD card backup in Linux 34 Summary 36 Chapter 2: Audio Antics 37 Configuring your audio gadgets 37 Sound variations 37 Introducing the ALSA sound system 38 Controlling the volume 39 Switching between HDMI and analog audio output 41 Testing the speakers 43 Preparing to record 43 Testing the microphone 48 Clipping, feedback distortion, and improving sound quality 49 Recording conversations for later retrieval 50 Writing to a WAV file 51 Writing to an MP3 or OGG file 51 Creating command shortcuts with aliases 53 Keep your recordings running safely with tmux 54 Making a covert wearable recorder with Pi Zero 56 Listening in on conversations from a distance 61 Listening in Windows 61 Listening in Mac OS X or Linux 63 Listening in over Bluetooth 65 Introducing Bluetooth audio 65 Setting up Bluetooth on the Pi 65 Installing PulseAudio 68 Connect to your Bluetooth headset or speaker 68 Bluetooth by default 71 Talking to people from a distance 73 Talking in Windows 73 Talking in Mac OS X or Linux 74 Attention Mac users 75 Talking in Bluetooth 75 Distorting your voice in weird and wonderful ways 76 Make your computer do the talking 78 Scheduling your audio actions 79 Start on power up 79 Scheduled start 82 [ ii ] Controlling recording length 83 Start recording with noise detection 84 Calling your fellow agents 86 Setting up SIP Witch 86 Connecting the softphones 90 Windows (MicroSIP) 91 Configuring the MicroSIP softphone for Windows 92 Mac OS X (Telephone) 92 Linux (Ring) 93 Android (CSipSimple) 93 iPhone/iPad (Linphone) 94 Running a softphone on the Pi 94 Encrypting SIP Witch passwords 95 Setting up Linphone 95 Playing files with Linphone 97 Using your voice to control things 98 Give your Pi some ears 99 Bonus one-line sampler 103 Summary 104 Chapter 3: Webcam and Video Wizardry 105 Meet the USB Video Class drivers and Video4Linux 105 Raspberry Pi Camera Module 106 Connecting the camera module 107 Setting up the camera module 109 Using USB cameras 113 Connecting the webcam 113 Finding out your webcam's capabilities 116 Capturing your target on film 117 Viewing your camera in VLC media player 121 Viewing in Windows 121 Viewing in Mac OS X 122 Viewing in Linux 123 Recording the video stream 123 Recording in Windows 124 Recording in Mac OS X 124 Recording in Linux 125 Detecting an intruder and setting off an alarm 125 Creating a motion detection configuration 126 Trying out Motion 128 Collecting the evidence 130 [ iii ] Viewing and e-mailing the evidence 132 Hooking up more cameras 133 Preparing a webcam stream in Windows 133 Preparing a webcam stream in Mac OS X 133 Configuring MotionEye for multiple input streams 134 Watching your camera over the Internet 136 The link between the Pi and the broadcasting service 136 Night vision 139 Make a covert wearable recorder with Pi Zero 140 Turning your TV on or off using the Pi 141 Scheduling a playback scare 142 Summary 144 Chapter 4: Wi-Fi Pranks – Exploring Your Network 146 Getting an overview of all the computers on your network 147 Monitoring Wi-Fi airspace with Kismet 147 Preparing Kismet for launch 149 First Kismet session 151 Adding sound and speech 154 Enabling rogue access point detection 155 Mapping out your network with Nmap 156 Finding out what the other computers are up to 159 How encryption changes the game 163 Traffic logging 164 Shoulder surfing in Elinks 164 Pushing unexpected