Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python for Offensive PenTest

You're reading from   Python for Offensive PenTest A practical guide to ethical hacking and penetration testing using Python

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788838979
Length 176 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Hussam Khrais Hussam Khrais
Author Profile Icon Hussam Khrais
Hussam Khrais
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. Warming up – Your First Antivirus-Free Persistence Shell FREE CHAPTER 2. Advanced Scriptable Shell 3. Password Hacking 4. Catch Me If You Can! 5. Miscellaneous Fun in Windows 6. Abuse of Cryptography by Malware 7. Other Books You May Enjoy

Antivirus free keylogger


In this section, we will code a simple software keylogger, purely in Python. To do so, we will be using a library called pyHook. The pyHook library wraps the low-level mouse and keyboard hooks in Windows. As per the pyHook documentation, any application that wishes to receive notification from a global input event must have a Windows message pump. For this, we need another library, called pywin.

So, let's start by installing these libraries.

Installing pyHook and pywin

You can download the pyHook library from http://sourceforge.net/projects/pyhook/files/pyhook/1.5.1/ and install it easily following the on-screen instructions.  

Note

Make sure that you do not have another Python instance running in the background or you will get an error during installation.

The pywin library can also be installed in the same manner. You can download the library from https://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/.

Adding code to keylogger

The following is the script for...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image