Example #1
0
    def _initialize_nat_simple(self):

        from core.utils import iptables, NetworkManager, set_ip_forwarding
        from core.hostapd_mana import HostAPDMana, DHCPDMana

        hostapd = HostAPDMana.get_instance()
        network_manager = NetworkManager.get_instance()
        dhcpd = DHCPDMana.get_instance()

        os.system('killall dnsmasq')
    
        network_manager.stop()
        os.system('rfkill unblock wlan')

        os.system('ifconfig %s up' % self.phy)

        hostapd.configure_karma(phy=self.phy,
                            essid=self.essid,
                            bssid=self.bssid,
                            channel=self.channel)
        #hostapd.start()
        time.sleep(5)
        os.system('ifconfig %s 10.0.0.1 netmask 255.255.255.0' % self.phy)
        os.system('route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1')

        dhcpd.select_conf('dhcpd.conf')
        #dhcpd.start(self.phy)
        
        set_ip_forwarding(1)
        
        print 'setting up iptables'
        iptables().ROGUE_AP_NAT(upstream=self.upstream, phy=self.phy)

        if not iptables().http and self.options.filter is None:
            iptables().HTTP(self.options.listen_port)
Example #2
0
    def _initialize_nat_simple(self):

        from core.utils import iptables, NetworkManager, set_ip_forwarding
        from core.hostapd_mana import HostAPDMana, DHCPDMana

        hostapd = HostAPDMana.get_instance()
        network_manager = NetworkManager.get_instance()
        dhcpd = DHCPDMana.get_instance()

        os.system('killall dnsmasq')

        network_manager.stop()
        os.system('rfkill unblock wlan')

        os.system('ifconfig %s up' % self.phy)

        hostapd.configure_karma(phy=self.phy,
                                essid=self.essid,
                                bssid=self.bssid,
                                channel=self.channel)
        #hostapd.start()
        time.sleep(5)
        os.system('ifconfig %s 10.0.0.1 netmask 255.255.255.0' % self.phy)
        os.system('route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1')

        dhcpd.select_conf('dhcpd.conf')
        #dhcpd.start(self.phy)

        set_ip_forwarding(1)

        print 'setting up iptables'
        iptables().ROGUE_AP_NAT(upstream=self.upstream, phy=self.phy)

        if not iptables().http and self.options.filter is None:
            iptables().HTTP(self.options.listen_port)
Example #3
0
    def initialize(self, options):
        '''Called if plugin is enabled, passed the options namespace'''
        self.options            = options
        self.protocol_instances = []

        from core.utils import iptables, shutdown, set_ip_forwarding
        #Makes scapy more verbose
        debug = False

        if options.arp:
            if not options.gateway:
                shutdown("[Spoof] --arp argument requires --gateway")

            from core.poisoners.ARP import ARPpoisoner
            arp = ARPpoisoner(options)
            arp.debug = debug
            self.tree_info.append('ARP spoofing enabled')
            self.protocol_instances.append(arp)

        elif options.dhcp:
            from core.poisoners.DHCP import DHCPpoisoner

            if options.targets:
                shutdown("[Spoof] --targets argument invalid when DCHP spoofing")

            dhcp = DHCPpoisoner(options)
            dhcp.debug = debug
            self.tree_info.append('DHCP spoofing enabled')
            self.protocol_instances.append(dhcp)

        elif options.icmp:
            from core.poisoners.ICMP import ICMPpoisoner

            if not options.gateway:
                shutdown("[Spoof] --icmp argument requires --gateway")

            if not options.targets:
                shutdown("[Spoof] --icmp argument requires --targets")

            icmp = ICMPpoisoner(options)
            icmp.debug = debug
            self.tree_info.append('ICMP spoofing enabled')
            self.protocol_instances.append(icmp)

        if options.dns:
            self.tree_info.append('DNS spoofing enabled')
            if iptables().dns is False and options.filter is None:
                iptables().DNS(self.config['MITMf']['DNS']['port'])

        if not options.arp and not options.icmp and not options.dhcp and not options.dns:
            shutdown("[Spoof] Spoof plugin requires --arp, --icmp, --dhcp or --dns")

        set_ip_forwarding(1)

        if iptables().http is False and options.filter is None:
            iptables().HTTP(options.listen_port)

        for protocol in self.protocol_instances:
            protocol.start()
Example #4
0
    def start(self):
        set_ip_forwarding(1)
        iptables().NFQUEUE()

        self.nfqueue = NetfilterQueue()
        self.nfqueue.bind(0, self.modify)

        self.nfqueue.run()
Example #5
0
    def start(self):
        set_ip_forwarding(1)
        iptables().NFQUEUE()

        self.nfqueue = NetfilterQueue()
        self.nfqueue.bind(1, self.modify)

        self.nfqueue.run()
Example #6
0
    def on_shutdown(self):
        from core.utils import iptables, set_ip_forwarding

        for protocol in self.protocol_instances:
            if hasattr(protocol, 'stop'):
                protocol.stop()

        iptables().flush()

        set_ip_forwarding(0)
Example #7
0
    def start(self):
        set_ip_forwarding(1)
        iptables().NFQUEUE()

        self.nfqueue = NetfilterQueue()
        self.nfqueue.bind(1, self.modify)

        t = threading.Thread(name='packetparser', target=self.nfqueue.run)
        t.setDaemon(True)
        t.start()
Example #8
0
    def on_shutdown(self):
        from core.utils import iptables, set_ip_forwarding

        for protocol in self.protocol_instances:
            if hasattr(protocol, 'stop'):
                protocol.stop()

        iptables().flush()

        set_ip_forwarding(0)
Example #9
0
    def start(self):
        set_ip_forwarding(1)
        iptables().NFQUEUE()

        self.nfqueue = NetfilterQueue()
        self.nfqueue.bind(1, self.modify)

        t = threading.Thread(name='packetparser', target=self.nfqueue.run)
        t.setDaemon(True)
        t.start()
Example #10
0
    def start(self):
        set_ip_forwarding(1)
        iptables().NFQUEUE(self.mode)
        self.q = nfqueue.queue()
        self.q.open()
        self.q.bind(socket.AF_INET)
        self.q.set_callback(self.modify)
        self.q.create_queue(0)

        while True:
            self.q.try_run()
        print("stopped")
Example #11
0
 def stop(self):
     self.nfqueue.unbind()
     set_ip_forwarding(0)
     iptables().flush()
Example #12
0
 def stop(self):
     self.nfqueue.unbind()
     set_ip_forwarding(0)
     iptables().flush()
Example #13
0
    def initialize(self, options):
        '''Called if plugin is enabled, passed the options namespace'''
        self.options = options
        self.protocol_instances = []

        from core.utils import iptables, shutdown, set_ip_forwarding
        #Makes scapy more verbose
        debug = False

        if options.arp:
            if not options.gateway:
                shutdown("[Spoof] --arp argument requires --gateway")

            from core.poisoners.ARP import ARPpoisoner
            arp = ARPpoisoner(options)
            arp.debug = debug
            self.tree_info.append('ARP spoofing enabled')
            self.protocol_instances.append(arp)

        elif options.dhcp:
            from core.poisoners.DHCP import DHCPpoisoner

            if options.targets:
                shutdown(
                    "[Spoof] --targets argument invalid when DCHP spoofing")

            dhcp = DHCPpoisoner(options)
            dhcp.debug = debug
            self.tree_info.append('DHCP spoofing enabled')
            self.protocol_instances.append(dhcp)

        elif options.icmp:
            from core.poisoners.ICMP import ICMPpoisoner

            if not options.gateway:
                shutdown("[Spoof] --icmp argument requires --gateway")

            if not options.targets:
                shutdown("[Spoof] --icmp argument requires --targets")

            icmp = ICMPpoisoner(options)
            icmp.debug = debug
            self.tree_info.append('ICMP spoofing enabled')
            self.protocol_instances.append(icmp)

        if options.dns:
            self.tree_info.append('DNS spoofing enabled')
            if iptables().dns is False:
                iptables().DNS(self.config['MITMf']['DNS']['port'])

        if not options.arp and not options.icmp and not options.dhcp and not options.dns:
            shutdown(
                "[Spoof] Spoof plugin requires --arp, --icmp, --dhcp or --dns")

        set_ip_forwarding(1)

        if iptables().http is False:
            iptables().HTTP(options.listen_port)

        for protocol in self.protocol_instances:
            protocol.start()
Example #14
0
 def stop(self):
     self.q.unbind(socket.AF_INET)
     self.q.close()
     set_ip_forwarding(0)
     iptables().flush()
     sys.exit('closing...')