在Catalina上安装Mitmf并转换成python3运行

mitmf不兼容MacOS,虽然最后没有成功,还是把解决问题的方法记录下来吧。

1.安装依赖报错

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % sudo python3 -m pip install -r requirements.txt

WARNING: The directory '/Users/zyjsuper/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple

Collecting pyinotify

  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e3/c0/fd5b18dde17c1249658521f69598f3252f11d9d7a980c5be8619970646e1/pyinotify-0.9.6.tar.gz (60 kB)

     |████████████████████████████████| 60 kB 827 kB/s 

    ERROR: Command errored out with exit status 1:

     command: /Library/Developer/CommandLineTools/usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-yxkvp8_s/pyinotify/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-yxkvp8_s/pyinotify/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-pip-egg-info-9cdauhxg

         cwd: /private/tmp/pip-install-yxkvp8_s/pyinotify/

    Complete output (1 lines):

    inotify is not available on macosx-10.14-x86_64

    ----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决办法:

zhaoyuanjis-MacBook-Air:~ root# wget https://pypi.tuna.tsinghua.edu.cn/packages/e3/c0/fd5b18dde17c1249658521f69598f3252f11d9d7a980c5be8619970646e1/pyinotify-0.9.6.tar.gz

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % tar xvf pyinotify-0.9.6.tar.gz 

zyjsuper@zhaoyuanjis-MacBook-Air pyinotify-0.9.6 % python3 setup.py install

inotify is not available on macosx-10.14-x86_64

zyjsuper@zhaoyuanjis-MacBook-Air pyinotify-0.9.6 % grep 'not available' *

grep: common: Is a directory

grep: old: Is a directory

grep: python2: Is a directory

grep: python3: Is a directory

setup.py:    sys.stderr.write("inotify is not available on %s\n" % platform)

修改setup.py,将if判断条件改成:

# check linux platform

if not platform.startswith('linux') and not platform.startswith('macosx'):

    sys.stderr.write("inotify is not available on %s\n" % platform)

    sys.exit(1)

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % sudo python3 setup.py  install

 

2.导入bdfactory失败

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % python3 mitmf.py

Traceback (most recent call last):

  File "mitmf.py", line 36, in <module>

    from plugins import *

  File "/Users/zyjsuper/Tools/MITMf/plugins/filepwn.py", line 72, in <module>

    from libs.bdfactory import pebin

ImportError: cannot import name 'pebin' from 'libs.bdfactory' (unknown location)

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % cd ./MITMf/libs/bdfactory

zyjsuper@zhaoyuanjis-MacBook-Air bdfactory % git clone https://github.com/secretsquirrel/the-backdoor-factory

zyjsuper@zhaoyuanjis-MacBook-Air bdfactory % mv the-backdoor-factory/* .

 3.将所有py文件转换为python3格式

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % sudo python3 -m pip install 2to3

zyjsuper@zhaoyuanjis-MacBook-Air MITMf % find  .  -name "*.py" |xargs 2to3 -w  

 

4.切换到root用户执行mitmf.py报错“找不到模块”

zhaoyuanjis-MacBook-Air:~ root# mitmf 

Traceback (most recent call last):

  File "/usr/local/bin/mitmf", line 36, in <module>

    from plugins import *

  File "/Users/zyjsuper/Tools/MITMf/plugins/screenshotter.py", line 27, in <module>

    from plugins.inject import Inject

  File "/Users/zyjsuper/Tools/MITMf/plugins/inject.py", line 24, in <module>

    from bs4 import BeautifulSoup

ModuleNotFoundError: No module named 'bs4'

zhaoyuanjis-MacBook-Air:~ root# cp -r  /Users/zyjsuper/Library/Python/3.7/lib/python/site-packages/*  /Library/Python/3.7/site-packages/

 

5.argparse.ArgumentParser()用法报错

zhaoyuanjis-MacBook-Air:~ root# mitmf 

Traceback (most recent call last):

  File "/usr/local/bin/mitmf", line 50, in <module>

    formatter_class=RawTextHelpFormatter)

TypeError: __init__() got an unexpected keyword argument 'version'

修改下面这段代码:添加注释。

parser = argparse.ArgumentParser(description="MITMf v{} - '{}'".format(mitmf_version, mitmf_codename),

                               #  version="{} - '{}'".format(mitmf_version, mitmf_codename),

                                 usage='mitmf.py -i interface [mitmf options] [plugin name] [plugin options]',

                                 epilog="Use wisely, young Padawan.",

                                 formatter_class=RawTextHelpFormatter)

参考:https://blog.csdn.net/the_time_runner/article/details/97941409

 

6.写日志找不到路径

zhaoyuanjis-MacBook-Air:~ root# mitmf -i en0

Traceback (most recent call last):

  File "/usr/local/bin/mitmf", line 78, in <module>

    log = logger().setup_logger("MITMf", formatter)

  File "/Users/zyjsuper/Tools/MITMf/core/logger.py", line 35, in setup_logger

    fileHandler = logging.FileHandler(logfile)

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1092, in __init__

    StreamHandler.__init__(self, self._open())

  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/logging/__init__.py", line 1121, in _open

    return open(self.baseFilename, self.mode, encoding=self.encoding)

FileNotFoundError: [Errno 2] No such file or directory: '/private/var/root/logs/mitmf.log'

zhaoyuanjis-MacBook-Air:~ root# mkdir /private/var/root/logs

 7.MacOS不支持inotify的模块

zhaoyuanjis-MacBook-Air:MITMf root# python3 mitmf.py -i en0 --spoof --arp --gateway 192.168.1.1 

[*] MITMf v0.9.8 - 'The Dark Side'

|

|_ Net-Creds v1.0 online

|_ Spoof v0.6

sh: iptables: command not found

|  |_ ARP spoofing enabled

Traceback (most recent call last):

  File "mitmf.py", line 123, in <module>

    plugin.start_config_watch()

  File "/Users/zyjsuper/Tools/MITMf/core/configwatcher.py", line 34, in start_config_watch

    wm = pyinotify.WatchManager()

  File "/Library/Python/3.7/site-packages/pyinotify-0.9.6-py3.7-macosx-10.14-x86_64.egg/pyinotify.py", line 1764, in __init__

    raise OSError(err % self._inotify_wrapper.str_errno())

OSError: Cannot initialize new instance of inotify, Errno=Invalid argument (EINVAL)

把涉及到调用inotify到地方注释掉。此例注释掉 plugin.start_config_watch()。

8.python3没有UserDict.DictMixin模块

Traceback (most recent call last):

  File "mitmf.py", line 165, in <module>

    from core.servers.HTTP import HTTP

  File "/Users/zyjsuper/Tools/MITMf/core/servers/HTTP.py", line 27, in <module>

    from core.responder.packets import NTLM_Challenge

  File "/Users/zyjsuper/Tools/MITMf/core/responder/packets.py", line 21, in <module>

    from .odict import OrderedDict

  File "/Users/zyjsuper/Tools/MITMf/core/responder/odict.py", line 17, in <module>

    from UserDict import DictMixin

ModuleNotFoundError: No module named 'UserDict'

修改/Users/zyjsuper/Tools/MITMf/core/responder/odict.py这个文件,

将导入替换为:from collections import UserDict

sed -i 's/DictMixin/UserDict/g' odict.py

 iterkeys = UserDict.keys

    itervalues = UserDict.values

    iteritems = UserDict.items

 

posted @ 2020-05-04 18:22  heycomputer  阅读(600)  评论(0编辑  收藏  举报