Skip to main content

MQTwister

A Tool for Man-in-the-Middle (MitM) Attacks on the MQTT Protocol.

Python License GitHub issues GitHub pull requests REUSE status

GitHub stars GitHub watchers GitHub forks

Table of Contents

About this project

MQTwister is an open-source tool for performing Man-in-the-Middle attacks on IoT systems based on the MQTT protocol.

To do this, MQTwister scans incoming packets and applies user-defined substitution rules in real time using its own syntax. In the case of connection packets, MQTwister also records the credentials (ID, username, and password), allowing for network information gathering.

MQTwister is primarily focused on packet processing and is expected to be used after performing the necessary preliminary actions to allow the running machine to intercept communication between an MQTT client and the broker.

Setup

Install from PyPI

MQTwister is published on PyPI, install it with:

python -m pip install mqtwister

Using requirements.txt

For a classic installation, the file requirements.txt is provided.

  1. Clone the repository:

    git clone https://github.com/danielfeitopin/mqtwister.git
    cd mqtwister
    
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Using Pipenv

For added convenience, the files Pipfile and Pipfile.lock are also provided.

  1. Clone the repository:

    git clone https://github.com/danielfeitopin/mqtwister.git
    cd mqtwister
    
  2. Install dependencies:

    pipenv install
    

Usage

To use MQTwister follow the next steps:

  1. Configure the tool by editing the mqtwister/config.py with your preferences (such as default network interface, target port, logging level and language).

  2. Run the tool using the mqtwister package as a module:

    python -m mqtwister
    
  3. Configure session parameters using the user interface.

  4. Add substitution rules using the ad hoc syntax item="value" item.action(args), in which "item" may be topic or payload and "action" one of the available options (more info in substitution_rules.md).

  5. Start the sniffer to begin the message tampering and credential collection.

License

📃 This project is and its code are licensed under the GNU General Public License version 2 (GPL-2.0). The documentation files and other resources are licensed under the Creative Commons Attribution Share Alike 4.0 International License (CC-BY-SA-4.0). A copy of these licenses can be found in the LICENSE file, and in the LICENSES folder.

Permissions Conditions Limitations
🟢 Commercial use 🔵 Disclose source 🔴 Liability
🟢 Distribution 🔵 License and copyright notice 🔴 Warranty
🟢 Modification 🔵 Same license
🟢 Private use 🔵 State changes

Table based on choosealicense.com

Why this license?

The initial intention was to license this project under the GNU General Public License version 3 (GPLv3) due to its enhanced legal protections, ethical considerations, and long-term sustainability. However, after reviewing the dependencies, it was determined that one of them is licensed under "GPLv2 only," which is incompatible with GPLv3.

To ensure compliance and compatibility with all dependencies, the project is licensed under GPLv2. This decision aligns with the licensing terms of the included components while preserving the principles of open-source software. The permissive BSD-3-Clause-licensed components used in the project remain compatible with GPLv2, as their terms allow integration into projects under more restrictive copyleft licenses.


Used dependencies and their licenses

Third party packages:

Component License
psutil_badge psutil_license_badge
scapy_badge scapy_license_badge

Third party dev-packages:

Component License
pytest_badge pytest_license_badge

Contributing

🤝 Contributions are welcome! If you have improvements or bug fixes, feel free to submit a pull request.

❓ For support, please refer to the SUPPORT file for details on how to get help with this project.

📜 Please make sure to review the CONTRIBUTING guidelines and the GOVERNANCE document before getting started.

✅ By participating in this project, you agree to abide by our Code of Conduct.

🔒 Security is a top priority for this project. If you discover any vulnerabilities or have concerns regarding the security of this tool, please report them responsibly by following the SECURITY guidelines.

Support this project

⭐ If you find this project useful, please consider giving it a star on GitHub. Your support helps to improve and maintain the project!

Contact

📧 Feel free to get in touch with me!

GitHub LinkedIn

Metadata

Release files for mqtwister 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mqtwister 0.1.0
File Size Uploaded Provenance
mqtwister-0.1.0.tar.gz 270.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mqtwister 0.1.0
File Interpreter ABI Platform
mqtwister-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 304.3 kB

Release files / mqtwister-0.1.0.tar.gz

Download URL mqtwister-0.1.0.tar.gz
Size 270.4 kB
Tags Source
SHA-256 checksum
How to use checksums
909ca188f567e24bd5d8749dca81e8fea8d6422d6a0b63419137829e48ed7277
BLAKE2b-256 checksum
How to use checksums
8f8d65f4b8d0057e71e8edd68e84c0278232a58cc787b0672eef952ce0b7dcf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / mqtwister-0.1.0-py3-none-any.whl

Download URL mqtwister-0.1.0-py3-none-any.whl
Size 33.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3eafe2e7496a8b9067a5adf309ba647a63779527034a29e90d6bd1444f733b7
BLAKE2b-256 checksum
How to use checksums
439df648e320d99829f6a67c5d04705a532b5102f37d28cbdb523f041dc99f24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for mqtwister 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page