Results 1 to 5 of 5

Thread: Mitmf. ImportError: No module named parse

  1. #1
    Join Date
    2020-Jul
    Posts
    6

    Mitmf. ImportError: No module named parse

    Good day. I am working with Kali Linux. I recently started looking into middleman attacks (Mitmf tool that works with python 2.7.0), but after the first attack, there was a problem with the python module.
    Code:
    Traceback (most recent call last): 
    File "mitmf.py", line 139, in <module>
    from core.sslstrip.StrippingProxy import StrippingProxy
    File "/home/test/Рабочий стол/MITMf/core/sslstrip/StrippingProxy.py", line 20, in <module>
    from ClientRequest import ClientRequest
    File "/home/test/Рабочий стол/MITMf/core/sslstrip/ClientRequest.py", line 25, in <module>
    import dns.resolver
    File "build/bdist.linux-x86_64/egg/dns/resolver.py", line 19, in <module>
    ImportError: No module named parse
    On Kali Linux, I have two python versions - 2.7.0 and 3.8. Before that, I also had problems with python modules when installing mitmf, but I successfully solved them one by one by downloading and installing from Github.
    With the parse module, this trick did not work. I tried installing it with different names - urlparse, etc., but to no avail.
    There is little information about it on the Internet, plus I don't know where python modules are stored in Kali Linux.
    Please help a novice pentester.

  2. #2
    Join Date
    2013-Jul
    Posts
    844
    Could you note the source of your mitmf.

    MTeams

  3. #3
    Join Date
    2020-Jul
    Posts
    6
    Quote Originally Posted by mmusket33 View Post
    Could you note the source of your mitmf.

    MTeams
    Code:
    #!/usr/bin/env python2.7
    
    # Copyright (c) 2014-2016 Moxie Marlinspike, Marcello Salvati
    #
    # This program is free software; you can redistribute it and/or
    # modify it under the terms of the GNU General Public License as
    # published by the Free Software Foundation; either version 3 of the
    # License, or (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful, but
    # WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    # General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    # USA
    #
    
    import logging
    logging.getLogger("scapy.runtime").setLevel(logging.ERROR) #Gets rid of IPV6 Error when importing scapy
    logging.getLogger("requests").setLevel(logging.WARNING) #Disables "Starting new HTTP Connection (1)" log message
    
    import argparse
    import sys
    import os
    import threading
    import core.responder.settings as settings
    
    from argparse import RawTextHelpFormatter
    from twisted.web import http
    from twisted.internet import reactor
    from core.logger import logger
    from core.banners import get_banner
    from plugins import *
    
    print get_banner()
    
    mitmf_version = '0.9.8'
    mitmf_codename = 'The Dark Side'
    
    if os.geteuid() != 0:
        sys.exit("[-] The derp is strong with this one\nTIP: you may run MITMf as root.")
    
    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)
    
    #add MITMf options
    sgroup = parser.add_argument_group("MITMf", "Options for MITMf")
    sgroup.add_argument("--log-level", type=str,choices=['debug', 'info'], default="info", help="Specify a log level [default: info]")
    sgroup.add_argument("-i", dest='interface', required=True, type=str, help="Interface to listen on")
    sgroup.add_argument("-c", dest='configfile', metavar="CONFIG_FILE", type=str, default="./config/mitmf.conf", help="Specify config file to use")
    sgroup.add_argument("-p", "--preserve-cache", action="store_true", help="Don't kill client/server caching")
    sgroup.add_argument("-r", '--read-pcap', type=str, help='Parse specified pcap for credentials and exit')
    sgroup.add_argument("-l", dest='listen_port', type=int, metavar="PORT", default=10000, help="Port to listen on (default 10000)")
    sgroup.add_argument("-f", "--favicon", action="store_true", help="Substitute a lock favicon on secure requests.")
    sgroup.add_argument("-k", "--killsessions", action="store_true", help="Kill sessions in progress.")
    sgroup.add_argument("-F", "--filter", type=str, help='Filter to apply to incoming traffic', nargs='+')
    
    #Initialize plugins and pass them the parser NameSpace object
    plugins = [plugin(parser) for plugin in plugin.Plugin.__subclasses__()]
    
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)
    
    options = parser.parse_args()
    
    #Set the log level
    logger().log_level = logging.__dict__[options.log_level.upper()]
    
    from core.logger import logger
    formatter = logging.Formatter("%(asctime)s %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
    log = logger().setup_logger("MITMf", formatter)
    
    from core.netcreds import NetCreds
    
    if options.read_pcap:
        NetCreds().parse_pcap(options.read_pcap)
    
    #Check to see if we supplied a valid interface, pass the IP and MAC to the NameSpace object
    from core.utils import get_ip, get_mac, shutdown
    options.ip  = get_ip(options.interface)
    options.mac = get_mac(options.interface)
    
    settings.Config.populate(options)
    
    log.debug("MITMf started: {}".format(sys.argv))
    
    #Start Net-Creds
    print "[*] MITMf v{} - '{}'".format(mitmf_version, mitmf_codename)
    
    NetCreds().start(options.interface, options.ip)
    print "|"
    print "|_ Net-Creds v{} online".format(NetCreds.version)
    
    from core.proxyplugins import ProxyPlugins
    
    ProxyPlugins().all_plugins = plugins
    for plugin in plugins:
    
        #load only the plugins that have been called at the command line
        if vars(options)[plugin.optname] is True:
    
            ProxyPlugins().add_plugin(plugin)
    
            print "|_ {} v{}".format(plugin.name, plugin.version)
            if plugin.tree_info:
                for line in xrange(0, len(plugin.tree_info)):
                    print "|  |_ {}".format(plugin.tree_info.pop())
    
            plugin.setup_logger()
            plugin.initialize(options)
    
            if plugin.tree_info:
                for line in xrange(0, len(plugin.tree_info)):
                    print "|  |_ {}".format(plugin.tree_info.pop())
    
            plugin.start_config_watch()
    
    if options.filter:
        from core.packetfilter import PacketFilter
        pfilter = PacketFilter(options.filter)
        print "|_ PacketFilter online"
        for filter in options.filter:
            print "   |_ Applying filter {} to incoming packets".format(filter)
        try:
            pfilter.start()
        except KeyboardInterrupt:
            pfilter.stop()
            shutdown()
    
    else:
        from core.sslstrip.CookieCleaner import CookieCleaner
        from core.sslstrip.StrippingProxy import StrippingProxy
        from core.sslstrip.URLMonitor import URLMonitor
    
        URLMonitor.getInstance().setFaviconSpoofing(options.favicon)
        URLMonitor.getInstance().setCaching(options.preserve_cache)
        CookieCleaner.getInstance().setEnabled(options.killsessions)
    
        strippingFactory          = http.HTTPFactory(timeout=10)
        strippingFactory.protocol = StrippingProxy
    
        reactor.listenTCP(options.listen_port, strippingFactory)
    
        for plugin in plugins:
            if vars(options)[plugin.optname] is True:
                plugin.reactor(strippingFactory)
    
        print "|_ Sergio-Proxy v0.2.1 online"
        print "|_ SSLstrip v0.9 by Moxie Marlinspike online"
    
        #Start mitmf-api
        from core.mitmfapi import mitmfapi
        print "|"
        print "|_ MITMf-API online"
        mitmfapi().start()
    
        #Start the HTTP Server
        from core.servers.HTTP import HTTP
        HTTP().start()
        print "|_ HTTP server online"
    
        #Start DNSChef
        from core.servers.DNS import DNSChef
        DNSChef().start()
        print "|_ DNSChef v{} online".format(DNSChef.version)
    
        #Start the SMB server
        from core.servers.SMB import SMB
        SMB().start()
        print "|_ SMB server online\n"
    
        #start the reactor
        reactor.run()
        print "\n"
    
        shutdown()

  4. #4
    Join Date
    2013-Jul
    Posts
    844

  5. #5
    Join Date
    2021-Feb
    Posts
    1
    Hello Guys, I am new to this forum and I am new to penetration testing as well.

    I am writing a MITM attack program using python and scapy to spoof any computer connected to the same network as I am and send packets to then as well as the router. but the issue I have is related to the Kali Linux's Network-Manager.

    Whenever I run my code, I always get the error saying:

    <Results: TCP:0 UDP:0 ICMP:0 Other:0>
    None

    Traceback (most recent call last):
    File "spoof_archive.py", line 121, in <module>

    File "spoof_archive.py", line 107, in start_spoof
    try:
    File "spoof_archive.py", line 85, in send_packet

    File "spoof_archive.py", line 38, in get_mac
    print(answered.summary())
    File "/usr/lib/python2.7/dist-packages/scapy/plist.py", line 89, in __getitem__
    return self.res.__getitem__(item)
    IndexError: list index out of range


    NOTE: From the error message, i was able to detect that the error was thrown on the fifth line of the code i will share below. This means that the scapy.srp() method is not working properly and not returning the answers from the ARP request sent.

    After a lot of debugging and googling, I finally noticed that my code runs properly if i run this Linux command "sudo service network-manager restart" together with time.sleep(3) which is a python method.

    However, this method slows down my program and it will have to restart my network-manager every 5 seconds which is not advisable because my wlan0 interface will have to be shutdown and switched on again.


    defget_mac(ip):

    arp_req = scapy.ARP(pdst=ip)

    broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
    broadcast_arp_request = broadcast/arp_req

    answered = scapy.srp(broadcast_arp_request, timeout=1, verbose=False)[0] # this is where the error is being thrown.

    return answered[0][1].hwsrc




    P.S: I am using a Kali Linux 2018 machine, on a 4GB RAM, 500GB Memory space Toshiba PC with AMD Radeon Processor 1.0

Similar Threads

  1. BDFPROXY "No module named libmproxy" problem
    By Parnoid in forum TroubleShooting Archive
    Replies: 0
    Last Post: 2023-03-29, 22:23
  2. snoopy-ng Kali 2.X - No module named libmproxy
    By dawz0r in forum General Archive
    Replies: 3
    Last Post: 2016-07-29, 21:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •