In this tutorial, I will show you how to install MITMf in Kali Linux 2021 using a simple script I made to automate the whole installation process as well as the manual installation if you prefer to do it yourself.
Most MITMf installation guides for Kali I found online are setting up the VirtualEnvWrapper incorrectly reason why you will get a lot of dependency errors as well as you won’t be able to launch MITMf again once you closed the terminal.
The MITMf installation script and manual method were successfully tested on Kali Linux 2021.1, 2021.2, and 2021.3 via ZSH shell. Unless things are drastically changed in the future Kali Linux releases, I don’t see any reason why both automated and manual methods won’t work.
If you are running Kali Linux on a virtual machine, I advise you to take a snapshot before proceeding with the installation process.
Without further ado, let’s install MITMf in Kali Linux 2021.
What is MITMf?
MITMf stands for man-in-the-middle framework. The MITMf tool was initially built to provide a modular and flexible attack framework while adding more features and updated MITM techniques than traditional tools like Mallory and Ettercap. Here are some of the most notable hallmarks:
- advanced packet filtering and manipulation
- supports LLMNR, NBT-NS, and MDNS poisoning attacks
- supports WPAD rogue server
- supports FTP, Telnet, SMTP, SNMP, POP, IMAP,
- IRC, Kerberos credentials [net-creds], and NTLMv1/v2.
- supports on-the-fly configurations without having to stop MITMf.
- has built-in DNS, SMB, and HTTP servers that various plugins can control.
- includes an altered version of the SSLStrip proxy that allows for HSTS bypass and HTTP customization.
You can see why MITMf quickly became popular as the go-to man-in-the-middle attacks. Though various modern tools were developed in the meantime, I can understand why most of us still prefer MITMf – be it for nostalgia or simply familiarity use.
Kali Linux 2021 removed MITMf from its latest releases as MITMf is no longer maintained upstream [due to its reliance on Python 2.7 deprecated as of January 1st, 2020] and replaced it with Bettercap as a man-in-the-middle (MITM) attack framework in Kali.
Luckily for us, there is quite an easy way to bring MITMf back to life on Kali Linux 2021.x, similar to what we did with Zenmap installation on Kali Linux.
Install MITMf in Kali Linux 2021 [Manual Installation]
To install MITMf in Kali Linux manually, open a terminal and execute the following steps in the ZSH shell as a root user.
1. Switch to the root user:
sudo -i
2. Update Kali Linux 2021.x:
apt-get update && apt-get upgrade -y
3. Install Python2 MITMf dependencies in Kali Linux 2021.x
apt-get install python-dev-is-python2 python-setuptools libpcap0.8-dev libnetfilter-queue-dev libssl-dev libjpeg-dev libxml2-dev libxslt1-dev libcapstone4 libcapstone-dev -y
4. Install Python 2.7 pip. Execute both commands below in the following order:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
5. Install VirtualEnvWrapper. This extension contains wrappers for establishing and removing virtual environments and controlling your development process, making it simpler to work on several projects at once without generating dependency conflicts.
pip2 install virtualenvwrapper
6. Export the VirtualEnvWrapper for Python 2.7:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
7. Source the VirtualEnvWrapper for Python 2.7:
source `which virtualenvwrapper.sh`
8. Create a virtual environment for MITMf:
mkvirtualenv MITMf -p /usr/bin/python2.7
9. Download the MITMf latest release from GitHub:
git clone https://github.com/byt3bl33d3r/MITMf
10. Set the git submodules path for MITMf.
cd MITMf && git submodule init && git submodule update --recursive
NOTE: Make sure you type <double-dash>recursive in case you get a syntax error here.
11. Install MITMf Python2 requirements:
pip2 install -r requirements.txt
12. This is an important step: open a new terminal without closing the existing one and switch to the root user [sudo -i]. Go to the MITMf folder [cd MITMf] and execute the following command:
pip2 install pyinotify configobj twisted pillow pefile python-magic capstone
13. Launch MITMf in Kali Linux 2021.x:
python mitmf.py -v
You can reboot the system now and check if MITMf can be executed from the /root/MITMf folder. If you followed all the steps above, you should have a working MITMf.
In case you are still getting ImportError: No module named errors, check the Troubleshooting section down below to find the fix.
Using this method you will have to launch MITMf as root user and from the /root/MITMf path. You can create a launcher on your desktop to automate the process if you want.
Install MITMf in Kali Linux 2021 [Automated Installation]
If you prefer the easy way, you can install MITMf on Kali Linux 2021.x by simply downloading the MITMf installation script and executing it on your system by following the instructions below.
You can place and run the MITMf installation script anywhere on your machine [Home, Desktop, Documents folder, etc.]. The script compiles all the MITMf installation commands used in the manual installation above. Here is how the MITMf installation script looks like:
!/bin/sh
apt-get install python-dev-is-python2 python-setuptools libpcap0.8-dev libnetfilter-queue-dev libssl-dev libjpeg-dev libxml2-dev libxslt1-dev libcapstone4 libcapstone-dev -y
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
pip2 install virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
source `which virtualenvwrapper.sh`
mkvirtualenv MITMf -p /usr/bin/python2.7
git clone https://github.com/byt3bl33d3r/MITMf
cd MITMf && git submodule init && git submodule update --recursive
pip2 install -r requirements.txt
pip2 install pyinotify configobj twisted pillow pefile python-magic capstone
python mitmf.py -v
- Download the install_MITMf.sh script and unpack the zip file in your prefered location. Alternatively copy the code snipped above and paste it into an empty file [right click > Create Document > Empty file] in Kali Linux. Save the file with the extension .sh
- Right-click on the install_MITMf.sh and select Properties. Navigate to the Permissions tab and check the Allow this file to run as a program checkbox.
- In the same folder where you placed the install_MITMf.sh script and select the Open terminal here option
- Execute the install_MITMf.sh command as root:
sudo ./install_MITMf.sh
Sit down and wait for the magic to happen!
5. You can run the MITMf tool from the MITMf folder created in the same folder where you run the install_MITMf.sh script. Open a terminal there and execute:
sudo python mitmf.py -v
This method allows you to run MITMf in Kali Linux as root [sudo] or normal user.
And hey, this website has now a YouTube channel. I can’t force you to subscribe or like my videos. I can only say that you’re gonna miss some awesome stuff otherwise :).
Click Play to watch this guide on YouTube.
Troubleshooting MITMf Installation
Here is a list of the most common MITMf installation errors you might encounter during the installation. Most issues are caused by missing pip2 requirements therefore simply executing pip install <package name> will fix the error(s).
No module named PIL
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/upsidedownternet.py", line 21, in <module>
from PIL import Image, ImageFile
ImportError: No module named PIL
To fix the PIL [Pillow] import error execute in the terminal:
pip2 install pillow
No module named chardet
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/screenshotter.py", line 27, in <module>
from plugins.inject import Inject
File "/root/MITMf/plugins/inject.py", line 22, in <module>
import chardet
ImportError: No module named chardet
To fix the chardet import error execute in the terminal:
pip2 install chardet
No module named bs4
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/screenshotter.py", line 27, in <module>
from plugins.inject import Inject
File "/root/MITMf/plugins/inject.py", line 24, in <module>
from bs4 import BeautifulSoup
ImportError: No module named bs4
To fix the bs4 import error execute in the terminal:
pip2 install bs4
No module named pefile
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/filepwn.py", line 60, in <module>
import pefile
ImportError: No module named pefile
To fix the pefile import error execute in the terminal:
pip2 install pefile
No module named magic
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/filepwn.py", line 70, in <module>
import magic
ImportError: No module named magic
To fix the magic [python-magic] import error execute in the terminal:
pip2 install python-magic
No module named capstone
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/MITMf/plugins/filepwn.py", line 72, in <module>
from libs.bdfactory import pebin
File "/root/MITMf/libs/bdfactory/pebin.py", line 49, in <module>
from intel.intelCore import intelCore
File "/root/MITMf/libs/bdfactory/intel/intelCore.py", line 38, in <module>
from capstone import *
ImportError: No module named capstone
To fix the capstone import error execute in the terminal:
pip2 install capstone
No module named scapy.all
Traceback (most recent call last):
File "mitmf.py", line 80, in <module>
from core.netcreds import NetCreds
File "/root/MITMf/core/netcreds.py", line 17, in <module>
from scapy.all import *
ImportError: No module named scapy.all
To fix the scapy.all import error execute in the terminal:
pip2 install scapy
No module named pyinotify
Traceback (most recent call last):
File "mitmf.py", line 29, in <module>
import core.responder.settings as settings
File "/root/MITMf/core/responder/settings.py", line 24, in <module>
from core.configwatcher import ConfigWatcher
File "/root/MITMf/core/configwatcher.py", line 20, in <module>
import pyinotify
ImportError: No module named pyinotify
To fix the pyinotify import error execute in the terminal:
pip2 install pyinotify
No module named configobj
Traceback (most recent call last):
File "mitmf.py", line 29, in <module>
import core.responder.settings as settings
File "/root/MITMf/core/responder/settings.py", line 24, in <module>
from core.configwatcher import ConfigWatcher
File "/root/MITMf/core/configwatcher.py", line 22, in <module>
from configobj import ConfigObj
ImportError: No module named configobj
To fix the configobj import error execute in the terminal:
pip2 install configobj
Wrapping Up
I decided to write this guide after numerous failed attempts to install MITMf in Kali Linux 2021.3 following various guides on the Internet. This guide was extensively tested on Kali Linux 2021.1, 2021.2, and Kali Linux 2021.3.
I will keep an eye on the new Kali Linux releases and keep this guide updated accordingly.
It took me about four days [and nights] to find a good working solution to installing MITMf in Kali Linux. If you found this guide useful, do me a favor and share this guide around as well as like and subscribe to my new YouTube channel.
Stay safe!
