Kali Linux Revealed
Total Page:16
File Type:pdf, Size:1020Kb
Kali Linux Revealed Mastering the Penetration Testing Distribution Kali Linux Revealed Mastering the Penetration Testing Distribution by Raphaël Hertzog, Jim O’Gorman, and Mati Aharoni Kali Linux Revealed Copyright © 2017 Raphaël Hertzog, Jim O’Gorman, and Mati Aharoni This book is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. è http://creativecommons.org/licenses/by-sa/3.0/ Some sections of this book borrow content from the “Debian Administrator’s Handbook, Debian Jessie from Discovery to Mastery” written by Raphaël Hertzog and Roland Mas, which is available here: è https://debian-handbook.info/browse/stable/ For the purpose of the CC-BY-SA license, Kali Linux Revealed is an Adaptation of the Debian Administrator’s Handbook. “Kali Linux” is a trademark of Offensive Security. Any use or distribution of this book, modified or not, must comply with the trademark policy defined here: è https://www.kali.org/trademark-policy/ All Rights Not Explicitly Granted Above Are Reserved. ISBN: 978-0-9976156-0-9 (paperback) Offsec Press 19701 Bethel Church Road, #103-253 Cornelius NC 28031 USA www.offensive-security.com Library of Congress Control Number: 2017905895 The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the authors nor Offsec Press shall have any liabil- ity to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. Because of the dynamic nature of the Internet, any Web addresses or links contained in this book may have changed since publication and may no longer be valid. Printed in the United States of America. Table of Contents 1. About Kali Linux 1 1.1 A Bit of History ................................................. 2 1.2 Relationship with Debian ........................................... 4 1.2.1 The Flow of Packages ........................................... 4 1.2.2 Managing the Difference with Debian ................................... 4 1.3 Purpose and Use Cases ............................................ 5 1.4 Main Kali Linux Features ........................................... 7 1.4.1 A Live System ............................................... 8 1.4.2 Forensics Mode .............................................. 8 1.4.3 A Custom Linux Kernel ........................................... 8 1.4.4 Completely Customizable ......................................... 9 1.4.5 A Trustable Operating System ....................................... 9 1.4.6 Usable on a Wide Range of ARM Devices .................................. 9 1.5 Kali Linux Policies ............................................... 9 1.5.1 Single Root User by Default ........................................ 10 1.5.2 Network Services Disabled by Default ................................... 10 1.5.3 A Curated Collection of Applications .................................... 10 1.6 Summary .................................................... 11 2. Getting Started with Kali Linux 13 2.1 Downloading a Kali ISO Image ....................................... 14 2.1.1 Where to Download ............................................ 14 2.1.2 What to Download ............................................. 14 2.1.3 Verifying Integrity and Authenticity .................................... 16 Relying on the TLS-Protected Website .................................. 17 Relying on PGP’s Web of Trust ...................................... 17 2.1.4 Copying the Image on a DVD-ROM or USB Key .............................. 19 Creating a Bootable Kali USB Drive on Windows ............................. 19 Creating a Bootable Kali USB Drive on Linux ............................... 20 Creating a Bootable Kali USB Drive on OS X/macOS ............................ 23 2.2 Booting a Kali ISO Image in Live Mode .................................. 24 2.2.1 On a Real Computer ............................................ 24 2.2.2 In a Virtual Machine ............................................ 24 Preliminary Remarks .......................................... 25 VirtualBox ............................................... 26 VMware ................................................ 36 2.3 Summary .................................................... 43 3. Linux Fundamentals 47 3.1 What Is Linux and What Is It Doing? ................................... 48 3.1.1 Driving Hardware ............................................. 48 3.1.2 Unifying File Systems ........................................... 49 3.1.3 Managing Processes ............................................ 50 3.1.4 Rights Management ............................................ 51 3.2 The Command Line .............................................. 51 3.2.1 How To Get a Command Line ....................................... 51 3.2.2 Command Line Basics: Browsing the Directory Tree and Managing Files .................. 52 3.3 The File System ................................................. 54 3.3.1 The Filesystem Hierarchy Standard ..................................... 54 3.3.2 The User’s Home Directory ......................................... 55 3.4 Useful Commands ............................................... 56 3.4.1 Displaying and Modifying Text Files .................................... 56 3.4.2 Searching for Files and within Files ..................................... 56 3.4.3 Managing Processes ............................................ 57 3.4.4 Managing Rights .............................................. 57 3.4.5 Getting System Information and Logs .................................... 60 3.4.6 Discovering the Hardware ......................................... 61 3.5 Summary .................................................... 62 4. Installing Kali Linux 65 4.1 Minimal Installation Requirements ..................................... 66 4.2 Step by Step Installation on a Hard Drive ................................. 66 4.2.1 Plain Installation .............................................. 66 Booting and Starting the Installer .................................... 66 Selecting the Language ......................................... 68 Selecting the Country .......................................... 69 Selecting the Keyboard Layout ...................................... 70 Detecting Hardware .......................................... 70 Loading Components .......................................... 70 Detecting Network Hardware ...................................... 71 Configuring the Network ........................................ 71 Root Password ............................................. 72 Configuring the Clock ......................................... 73 Detecting Disks and Other Devices .................................... 74 Partitioning .............................................. 74 IV Kali Linux Revealed Copying the Live Image ......................................... 80 Configuring the Package Manager (apt) ................................. 81 Installing the GRUB Boot Loader ..................................... 83 Finishing the Installation and Rebooting ................................. 85 4.2.2 Installation on a Fully Encrypted File System ................................ 85 Introduction to LVM .......................................... 86 Introduction to LUKS .......................................... 86 Setting Up Encrypted Partitions ..................................... 86 End of the Guided Partitioning with Encrypted LVM ............................ 90 4.3 Unattended Installations ........................................... 91 4.3.1 Preseeding Answers ............................................ 92 With Boot Parameters ......................................... 92 With a Preseed File in the Initrd ..................................... 92 With a Preseed File in the Boot Media .................................. 93 With a Preseed File Loaded from the Network ............................... 93 4.3.2 Creating a Preseed File ........................................... 93 4.4 ARM Installations ............................................... 94 4.5 Troubleshooting Installations ........................................ 95 4.6 Summary .................................................... 100 5. Configuring Kali Linux 103 5.1 Configuring the Network ........................................... 104 5.1.1 On the Desktop with NetworkManager .................................. 104 5.1.2 On the Command Line with Ifupdown ................................... 105 5.1.3 On the Command Line with systemd-networkd .............................. 106 5.2 Managing Unix Users and Unix Groups .................................. 107 5.2.1 Creating User Accounts .......................................... 107 5.2.2 Modifying an Existing Account or Password ................................ 108 5.2.3 Disabling an Account ............................................ 109 5.2.4 Managing Unix Groups ........................................... 109 5.3 Configuring Services ............................................. 109 5.3.1 Configuring a Specific Program ....................................... 110 5.3.2 Configuring SSH for Remote Logins .................................... 110 5.3.3 Configuring PostgreSQL Databases ..................................... 111 Connection Type and Client Authentication ................................ 111 Creating Users and Databases ...................................... 112 Managing PostgreSQL