{"id":13616164,"url":"https://github.com/EONRaider/blackhat-python3","last_synced_at":"2025-04-14T00:31:57.182Z","repository":{"id":37606213,"uuid":"259726383","full_name":"EONRaider/blackhat-python3","owner":"EONRaider","description":"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.","archived":false,"fork":false,"pushed_at":"2024-07-19T09:00:13.000Z","size":51731,"stargazers_count":2133,"open_issues_count":2,"forks_count":425,"subscribers_count":72,"default_branch":"master","last_synced_at":"2025-04-11T15:57:09.732Z","etag":null,"topics":["blackhat-python","blackhat-python-source-code","cybersecurity","ethical-hacking","hacking-tools","network-programming","network-security","python-hacking"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EONRaider.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-28T19:02:20.000Z","updated_at":"2025-04-10T08:57:13.000Z","dependencies_parsed_at":"2024-10-01T00:40:51.995Z","dependency_job_id":"ed6063c4-7850-496b-ad04-605044492e7c","html_url":"https://github.com/EONRaider/blackhat-python3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EONRaider%2Fblackhat-python3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EONRaider%2Fblackhat-python3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EONRaider%2Fblackhat-python3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EONRaider%2Fblackhat-python3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EONRaider","download_url":"https://codeload.github.com/EONRaider/blackhat-python3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631687,"owners_count":21136562,"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":["blackhat-python","blackhat-python-source-code","cybersecurity","ethical-hacking","hacking-tools","network-programming","network-security","python-hacking"],"created_at":"2024-08-01T20:01:24.431Z","updated_at":"2025-04-14T00:31:52.159Z","avatar_url":"https://github.com/EONRaider.png","language":"Python","readme":"# Python 3 \"Black Hat Python\" Source Code\n\nSource code for the book \"Black Hat Python\" by Justin Seitz. The code has been\n fully converted to Python 3, reformatted to comply with PEP8 standards and refactored to eliminate dependency issues involving the implementation of deprecated libraries.\n\nAlthough many optimizations could have been implemented in the source code\n presented\nthroughout the book, the code was left unaltered as much as possible so that\nsuch modifications can be applied by the reader as he sees fit. The code as\nit is needs some serious refactoring efforts ranging from docstrings to type\nhinting and exception handling, not to mention enhancements like context\n managers, but these issues by themselves may come to benefit the reader if \n he has the intention of implementing them. It also presents many bugs\n originating from indentation that have been corrected if fatal errors were \n to be avoided during runtime.\n \n*A conversion similar to this one has been made available by myself on the\n source code of the book \"Violent Python\", by TJ O'Connor. Check it out\n  [here](https://github.com/EONRaider/violent-python3) if you haven't done it\n   yet.*\n\n## Usage\nSimply choose a directory (DIR) in which to clone the project using\n`git clone`, create a new virtual environment or `venv` for it (recommended\n) and install the requirements using `pip install`.\n\n```\nuser@host:~/DIR$ git clone https://github.com/EONRaider/blackhat-python3\nuser@host:~/DIR$ python3 -m venv venv\nuser@host:~/DIR$ source venv/bin/activate\n(venv) user@host:~/DIR$ pip install -r requirements.txt\n```\n\n## Notes\n- Some listings presented on the book were missing from the author's code\n repository available from \"no starch press\" website and were\nadded to their respective chapters. A more accurate naming convention has\nbeen applied to the files as necessary in order to relate them to the code\npresented in the book.\n- Minor bugs that generated warnings by the interpreter have been fixed\n throughout the code without altering its characteristics.\n- Auxiliary files that were required to make the code work were added to their \nrespective chapters.\n- As a personal side-note, it could have been possible for the author\n to have written cleaner code without jeopardizing the quickness of\n  implementation that is required for ethical hacking engagements. Why he\n   opted for not doing so remains of unknown reason.\n\n## Refactoring\n\nCritical bug fixes that had to be made in order to properly implement the\n source code and avoid fatal errors:\n- `chapter02/bh_sshserver.py` required the RSA key contained in the `test_rsa.key` file, now included in the corresponding directory.\n- `chapter03/sniffer_ip_header_decode.py` \u0026 `sniffer_with_icmp.py` \u0026 `scanner.py` all had serious\n issues in the definition of IP packet sizes and portability between 32/64-bit \n architectures due to problems in the implementation of `struct`. More about these \n issues on [this thread on Stack Overflow.](https://stackoverflow.com/questions/29306747/python-sniffing-from-black-hat-python-book#29307402)\n- `chapter03/scanner.py` used the `netaddr` library, which is not\n maintained anymore and presents many incompatibilities with Python 3. \n For that reason the code has been refactored and now uses the `ipaddress`\n  module from Python's `stdlib`.\n- `chapter04/arper.py` \u0026 `mail_sniffer.py` used the `scapy` library, which is\n not compatible with Python 3. For that reason the code has been refactored and \n now uses the `kamene` library.\n- `chapter04/pic_carver.py` now uses the `opencv-python` library instead of\n`cv2`. The \"cv2.cv\" module was deprecated and has been replaced. The parameter\n\"cv2.cv.CV_HAAR_SCALE_IMAGE\" from the original code was replaced by \n\"cv2.CASCADE_SCALE_IMAGE\" because of [this commit](https://github.com/ragulin/face-recognition-server/commit/7b9773be352cbcd8a3aff50c7371f8aaf737bc5c).\n- `chapter05/content_bruter.py` required a wordlist to work. It has been added\nto the chapter under `all.txt`\n- `chapter05/joomla_killer.py` required a wordlist to work. It has been added\nto the chapter under `cain.txt`\n- `chapter06/bhp_bing.py` \u0026 `bhp_fuzzer.py` \u0026 `bhp_wordlist.py` have been\n reformatted to comply with PEP8, though some warnings will still be\n  triggered due to the necessity to conform class names to camel-casing in\n   this specific application on Burp Suite.\n- `chapter06/jython-standalone-2.7.2.jar` is available as a more updated\n version of the file relative to the one presented in the book.\n- `chapter07/git_trojan.py` was refactored to replace the `imp` library (now\n deprecated) for `types`. A subdirectory structure with the necessary\n  configuration files has been implemented as instructed in the book. The\n   \"trojan_config\" variable was missing the relative path to the `config` subdirectory. A call to \"to_tree\" method was added to line 60 in order to\n   avoid an AttributeError exception generated by the original code.\n   Instructions on how to generate an access token\n   instead of using one's password in case 2FA is being used were included as comments.\n- `chapter08/keylogger.py` requires the `PyHook` library to work. A wheel file\n has been included with the 1.6.2 version. If necessary, other versions can\n  be downloaded from [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook).\n- `chapter09/ie_exfil.py` threw errors due to the handling of the plaintext\n variable (which can appear as a string or as a binary string) when handed over \n to the \"encrypt_string\" function. Additionally, the use of the `base64` library was\n  corrected. *Contribution from [Enraged](https://github.com/Enraged) at \n  [this commit](https://github.com/EONRaider/blackhat-python3/pull/2/commits/fcab6afc19fc4ea01b8c5c475e7b8c5e4b158df6).*\n\n## Translations\nContributions in other languages can be checked here:\n- Translated to [Turkish](https://github.com/EONRaider/blackhat-python3/tree/turkish-language) by [Bedirhan Budak](https://github.com/bedirhanbudak)\n\n## Contributing\n\nAs a matter of common sense, first try to discuss the change you wish to make to\nthis repository via an issue.\n\n1. Ensure the modifications you wish to introduce actually lead to a pull\nrequest. The change of one line or two should be requested through an issue\n instead.\n2. If necessary, update the README.md file with details relative to changes to\n the project structure.\n3. Make sure the commit messages that include the modifications follow a\n standard. If you don't know how to proceed, [here](https://chris.beams.io/posts/git-commit/)\n  is a great reference on how to do it.\n4. Your request will be reviewed as soon as possible (usually within 48 hours).\n\n","funding_links":[],"categories":["HarmonyOS","Python"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEONRaider%2Fblackhat-python3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEONRaider%2Fblackhat-python3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEONRaider%2Fblackhat-python3/lists"}