{"id":16973570,"url":"https://github.com/carloocchiena/blackhat_python_book_code","last_synced_at":"2025-04-12T03:33:35.099Z","repository":{"id":109539626,"uuid":"421456403","full_name":"carloocchiena/blackhat_python_book_code","owner":"carloocchiena","description":"Source code and exercises from the book \"Black Hat Python\" by Justin Seitz.","archived":false,"fork":false,"pushed_at":"2024-06-19T10:43:46.000Z","size":1848,"stargazers_count":133,"open_issues_count":0,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T23:11:38.182Z","etag":null,"topics":["cybersecurity","hacking","networking","penetration-testing","pentesting","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carloocchiena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-26T14:22:55.000Z","updated_at":"2025-02-28T13:11:07.000Z","dependencies_parsed_at":"2024-06-19T20:05:02.495Z","dependency_job_id":null,"html_url":"https://github.com/carloocchiena/blackhat_python_book_code","commit_stats":{"total_commits":208,"total_committers":1,"mean_commits":208.0,"dds":0.0,"last_synced_commit":"eb87e1acc978733521e1b210fdae5da7b43eab50"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carloocchiena%2Fblackhat_python_book_code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carloocchiena%2Fblackhat_python_book_code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carloocchiena%2Fblackhat_python_book_code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carloocchiena%2Fblackhat_python_book_code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carloocchiena","download_url":"https://codeload.github.com/carloocchiena/blackhat_python_book_code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248513160,"owners_count":21116765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cybersecurity","hacking","networking","penetration-testing","pentesting","python","python3"],"created_at":"2024-10-14T01:02:17.907Z","updated_at":"2025-04-12T03:33:35.075Z","avatar_url":"https://github.com/carloocchiena.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Code and exercises from the book \"Black Hat Python: Python Programming for Hackers and Pentesters\", refactored and ported to Python 3 \nExamples, source code and exercises from the book \"Black Hat Python\" by Justin Seitz.\n\n![](https://img.shields.io/github/stars/carloocchiena/blackhat_python_book_code?style=social)\n\n![](https://img.shields.io/tokei/lines/github/carloocchiena/blackhat_python_book_code)\n\n![image](https://user-images.githubusercontent.com/57464184/138901408-984413ab-2648-4dbe-b40c-37ac7b59fc63.png)\n\n--------------------------------\n### About the book\nThe book is a milestone for pentesting with Python.\u003cbr\u003e\nAlthough its publication is quite recent (2014), it is all written in Python 2.7.\u003cbr\u003e\n\nYou can find the book on \u003ca href=\"https://www.amazon.it/Black-Hat-Python-Programming-Pentesters-ebook/dp/B00QL616DW#customerReviews\"\u003eAmazon\u003c/a\u003e, \nwhile the official book page is on \u003ca href=\"https://nostarch.com/black-hat-python2E#updates\"\u003eNo Starch Press\u003c/a\u003e website.\u003cbr\u003e\n\nYou should be able to download the book's source code from here http://www.nostarch.com/download/BHP-Code.zip, but apparently the link is broken or the file has been deleted (checked October 2021).\u003cbr\u003e\nPlease note that I did the whole job straight from book pages with no codes available (and believe me, my nearsightedness did not appreciate XD).\u003cbr\u003e\n\nNo Starch Press is offering also an Errata Corrige on the book code, but at the moment (November 2021) this section is actually 3 rows long :).\n\n--------------------------------\n\n### Reason for this repo\nI quite enjoyed the book, but as 2021 it looks quite outdated, not just for the choice of using Python 2.7.\u003cbr\u003e\n\nDeliberately, as expressed by the author, the scripts are written _rought \u0026 dirty_ to simulate the approach he uses during a penetration testing.\u003cbr\u003e\nHowever, this sometimes leads to code that is not very understandable, and not very efficient.\u003cbr\u003e\n\nSince I had to convert all the source codes anyway, to run them on my machine (Kali Linux VM + Win10 OS + Win10 VM + Python 3.9) I decided to go extra-mile and save them in a repo, in the meantime trying to optimize the code and making it a little more elegant (see below).\n\nThe code in the book does not always run flawlessy. It may depends on the local configuration on your machine, the test you are running, and also, outdated code presented in the book. So expect a bit of tweak here and there.\u003cbr\u003e As a rule of thumb I found of great help the many \u003ca href=\"https://stackoverflow.com/search?q=black+hat+python+book\"\u003ethreads already opened on Stack Overflow\u003c/a\u003e.\u003cbr\u003e \nSome good advices also from \u003ca href=\"https://medium.com/search?q=black%20hat%20python\"\u003eMedium Black Hat Python\u003c/a\u003e.\u003cbr\u003e\nI also starred this repo from EONRaider for reference, that I might use in the case I'll be getting stuck:\n\u003ca href=\"https://github.com/EONRaider/blackhat-python3\"\u003eEON RIDER Repo\u003c/a\u003e.\n\n--------------------------------\n\n### Improvement made from the book's code\n- Refactoring to Python 3 and code testing (unless otherwise specified)\n- Update to PEP8 standards\n- Upgraded readability (es. comments, indentation, variable names, file names)\n- Update of obsolete methods (es. print -s %)\n- Better context management (es. open with, server.close()) \n- Disregard of unsupported libs \n- Minor tweaks and bugs found while testing the code \n- Search for additional files requested throughout the book and not provided, or provided at outdated links, and included in individual chapters\n- Additional information and resources that I searched for and found useful as I made my way through the book\n\n--------------------------------\n\n### What you'll find in the repo\nChapter summary and titles are my own, for clarity. The book uses different titles and has no chapter summary.\u003cbr\u003e\nWhen needed, an additional `README.md`has been added inside each chapter folder for clarification and further details. \n\n#### Chapter 1: Intro\n- This is an introductory chapter and it's mostly about installing Linux VM and Python. No coding here.\n\n#### Chapter 2: Networking Basics\n- bhp_net.py\n- bhp_server.py\n- bhp_reverse_ssh_cmd.py\n- bhp_ssh_cmd.py\n- rforward.py\n- tcp_server.py\n- tcp_client.py\n- tcp_proxy.py\n- udp_client.py\n- test_rsa.key\n\n#### Chapter 3: Sniffing Tools\n- scanner.py\n- sniffer.py\n- sniffer_ip_header_decode.py\n- sniffer_with_icmp.py\n\n#### Chapter 4: Scapy \u0026 ARP Poisoning (with an extra flavour of image reco)\n- arper.py\n- mail_sniffer.py\n- pic_carver.py\n\n#### Chapter 5: CMS Brute Force\n- content_bruter.py\n- joomla_killer.py\n- web_app_mapper.py\n- wordpress_killer.py\n\n#### Chapter 6: Burp Suite Integrations \n- bhp_bing.py\n- bhp_fuzzer.py\n- bhp_wordlist.py\n\n#### Chapter 7: GitHub Trojan\n- folder structure\n- git_trojan.py\n\n#### Chapter 8: Trojan for Windows OS\n- keylogger.py\n- sandbox_detector.py\n- screenshotter.py\n- shell_exec.py\n\n#### Chapter 9: Hacking thru Internet Explorer\n- cred_server.py\n- decryptor.py\n- ie_exfil.py\n- keygen.py\n- mitb.py\n\n#### Chapter 10: Windows Process Monitoring and File Injection\n- file_monitor.py\n- process_monitor.py\n\n#### Chapter 11: Windows Forensics\n- grab_hashes.py\n- code_coverage.py\n- grab_hashes.py\n\n--------------------------------\n\n### Contributions\nAll contributions are welcome :).\u003cbr\u003e\nSince I have not (yet?) made a specific routine for that, please follow a best-practice, common-sense based approach, opening an Issue first and starting a discussion on the change you'd wish to make.\u003cbr\u003e\nAs a starting point, in each chapter folder I stated any known issues if any. \u003cbr\u003e\nA list of contributor will be displayed in the README of the repository.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarloocchiena%2Fblackhat_python_book_code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarloocchiena%2Fblackhat_python_book_code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarloocchiena%2Fblackhat_python_book_code/lists"}