Book Image

Learning Python for Forensics

By : Chapin Bryce
Book Image

Learning Python for Forensics

By: Chapin Bryce

Overview of this book

This book will illustrate how and why you should learn Python to strengthen your analysis skills and efficiency as you creatively solve real-world problems through instruction-based tutorials. The tutorials use an interactive design, giving you experience of the development process so you gain a better understanding of what it means to be a forensic developer. Each chapter walks you through a forensic artifact and one or more methods to analyze the evidence. It also provides reasons why one method may be advantageous over another. We cover common digital forensics and incident response scenarios, with scripts that can be used to tackle case work in the field. Using built-in and community-sourced libraries, you will improve your problem solving skills with the addition of the Python scripting language. In addition, we provide resources for further exploration of each script so you can understand what further purposes Python can serve. With this knowledge, you can rapidly develop and deploy solutions to identify critical information and fine-tune your skill set as an examiner.
Table of Contents (24 chapters)
Learning Python for Forensics
Credits
About the Authors
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Python for Windows


Python does not come installed by default on Windows machines. At the time of writing this, Python 2.7.11 is the most recent 2.X line and can be installed by downloading the python-2.7.11.msi file from https://www.python.org/downloads/. We recommend installing the 64-bit version if supported by your hardware.

After executing the Python installer, you can run Python by clicking on the python.exe file located in the C:\Python27 directory or from the command prompt at C:\Users\LPF>C:\Python27\python.exe. This path may vary depending on customizations during installation.

The third, and easiest, method to run Python is to just type python in the Command Prompt. To do this, we must add the location of the Python executable to our PATH variable. Python includes an automatic way of doing this, simply run the win_add2path.py script in the command prompt. After the script runs, close and open a new command prompt to load the new PATH variable before typing python.

C:\Users\LPF>C:\Python27\Tools\Scripts\win_add2path.py

You can also perform this manually by right-clicking My Computer, or This PC on Windows 8.1, and selecting Properties. On the left-hand side panel, select Advanced system settings followed by Environment Variables.

In the System variables box, select the Path variable and add the following (with the exception of the quotes) to the end ";C:\Python27;C:\Python27\Scripts". The Python27 directory contains the python executable, which we often invoke from the command line. The Scripts directory contains multiple scripts such as pip and easy_install, which make installing third-party modules a breeze. With this now complete, you have successfully installed Python.

If you did this incorrectly, you would receive the following error when typing python into the command prompt:

C:\Users\LPF>python
'python' is not recognized as an internal or external command,  operable program or batc
h file.

Make sure that you've closed and opened a new command prompt after updating the PATH variable. In addition, ensure that you've added the correct path information for the Python27 and Scripts folders as illustrated earlier.