Source code for the book "Black Hat Python" by Justin Seitz. The code has been fully converted to Python 3, reformatted to comply with PEP8 standards and refactored to eliminate dependency issues involving the implementation of deprecated libraries.
Source code for the book “Black Hat Python” by Justin Seitz. The code has been
fully converted to Python 3, reformatted to comply with PEP8 standards and refactored to eliminate dependency issues involving the implementation of deprecated libraries.
Although many optimizations could have been implemented in the source code
presented
throughout the book, the code was left unaltered as much as possible so that
such modifications can be applied by the reader as he sees fit. The code as
it is needs some serious refactoring efforts ranging from docstrings to type
hinting and exception handling, not to mention enhancements like context
managers, but these issues by themselves may come to benefit the reader if
he has the intention of implementing them. It also presents many bugs
originating from indentation that have been corrected if fatal errors were
to be avoided during runtime.
A conversion similar to this one has been made available by myself on the
source code of the book “Violent Python”, by TJ O’Connor. Check it out
here if you haven’t done it
yet.
Simply choose a directory (DIR) in which to clone the project using
git clone
, create a new virtual environment or venv
for it (recommended
) and install the requirements using pip install
.
user@host:~/DIR$ git clone https://github.com/EONRaider/blackhat-python3
user@host:~/DIR$ python3 -m venv venv
user@host:~/DIR$ source venv/bin/activate
(venv) user@host:~/DIR$ pip install -r requirements.txt
Critical bug fixes that had to be made in order to properly implement the
source code and avoid fatal errors:
chapter02/bh_sshserver.py
required the RSA key contained in the test_rsa.key
file, now included in the corresponding directory.chapter03/sniffer_ip_header_decode.py
& sniffer_with_icmp.py
& scanner.py
all had seriousstruct
. More about thesechapter03/scanner.py
used the netaddr
library, which is notipaddress
stdlib
.chapter04/arper.py
& mail_sniffer.py
used the scapy
library, which iskamene
library.chapter04/pic_carver.py
now uses the opencv-python
library instead ofcv2
. The “cv2.cv” module was deprecated and has been replaced. The parameterchapter05/content_bruter.py
required a wordlist to work. It has been addedall.txt
chapter05/joomla_killer.py
required a wordlist to work. It has been addedcain.txt
chapter06/bhp_bing.py
& bhp_fuzzer.py
& bhp_wordlist.py
have beenchapter06/jython-standalone-2.7.2.jar
is available as a more updatedchapter07/git_trojan.py
was refactored to replace the imp
library (nowtypes
. A subdirectory structure with the necessaryconfig
subdirectory. A call to “to_tree” method was added to line 60 in order tochapter08/keylogger.py
requires the PyHook
library to work. A wheel filechapter09/ie_exfil.py
threw errors due to the handling of the plaintextbase64
library wasContributions in other languages can be checked here:
As a matter of common sense, first try to discuss the change you wish to make to
this repository via an issue.