def get_default_device(destaddr):
    """
    If any default device is available in options use that, otherwise,
    Return the first (default) network device, which is usually 'eth0' under
    Linux and Windows and varies under BSD.
    address.recognize(destaddr) == address.IPv4:
    address.recognize(destaddr) == address.IPv6:

    @return: name of the first device.
    """

    # TODO: read device from options
    #device = "eth0"
    devices = pypcap.findalldevs()
    exp = re.compile('usb*', re.IGNORECASE)
    for dev in devices:
        if re.match(exp, dev) or dev == 'any':
            print
        else:
            if address.recognize(destaddr) == address.IPv4:
                if destaddr == '127.0.0.1':
                    device = 'lo'
                    break
                else:
                    saddr = netifaces.ifaddresses(dev)[
                        netifaces.AF_INET][0]['addr']
                    if saddr == '127.0.0.1':
                        device = dev
                        continue
                    else:
                        device = dev
                        break
            elif address.recognize(destaddr) == address.IPv6:
                if destaddr == '::1' or destaddr == '0000:0000:0000:0000:0000:0000:0000:0001' or destaddr == '0:0:0:0:0:0:0:1':
                    device = 'lo'
                    break
                else:
                    saddr = netifaces.ifaddresses(dev)[
                        netifaces.AF_INET6][0]['addr']
                    saddr_re = re.compile('fe80*', re.IGNORECASE)
                    if saddr == '::1':
                        continue
                    elif re.match(saddr_re, saddr):
                        device = dev
                        continue
                    else:
                        device = dev
                        break
            else:
                device = devices[0]

    print devices
    print device
    #device = netifaces.interfaces()[0]
    return device
Ejemplo n.º 2
0
def get_default_device(destaddr):
    """
    If any default device is available in options use that, otherwise,
    Return the first (default) network device, which is usually 'eth0' under
    Linux and Windows and varies under BSD.
    address.recognize(destaddr) == address.IPv4:
    address.recognize(destaddr) == address.IPv6:

    @return: name of the first device.
    """

    # TODO: read device from options
    #device = "eth0"
    devices = pypcap.findalldevs()
    exp = re.compile('usb*', re.IGNORECASE)
    for dev in devices:
        if re.match(exp,dev) or dev == 'any':
            print 
        else:
            if address.recognize(destaddr) == address.IPv4:
                if destaddr == '127.0.0.1':
                    device = 'lo'
                    break
                else:
                    saddr = netifaces.ifaddresses(dev)[netifaces.AF_INET][0]['addr']
                    if saddr == '127.0.0.1':
                        device = dev
                        continue
                    else:
                        device = dev
                        break
            elif address.recognize(destaddr) == address.IPv6:
                if destaddr == '::1' or destaddr == '0000:0000:0000:0000:0000:0000:0000:0001' or destaddr == '0:0:0:0:0:0:0:1':
                    device = 'lo'
                    break
                else:
                    saddr = netifaces.ifaddresses(dev)[netifaces.AF_INET6][0]['addr']
                    saddr_re = re.compile('fe80*', re.IGNORECASE)
                    if saddr == '::1':
                        continue
                    elif re.match(saddr_re , saddr):
                        device = dev
                        continue
                    else:
                        device = dev
                        break
            else:
                 device = devices[0]
                        
    print devices
    print device
    #device = netifaces.interfaces()[0]
    return device
Ejemplo n.º 3
0
 def set_addr(self, addr):
     """
     """
     if addr:
         addr_type = address.recognize(addr)
         if addr_type:
             self.__addr = addr_type(addr)
     else:
         self.__addr = None
Ejemplo n.º 4
0
 def set_addr(self, addr):
     """
     """
     if addr:
         addr_type = address.recognize(addr)
         if addr_type:
             self.__addr = addr_type(addr)
     else:
         self.__addr = None
Ejemplo n.º 5
0
	def start(self):
		"""
		"""        
		self.result.get_hosts_list().clear_hosts()
		targets = []
		addr_list = []
		if self.target.find('/') == -1:
			print "It does not contain /"
			if address.recognize(self.target) == address.Unknown:
				if address.is_name(self.target):
					l = probe.get_addr_from_name(self.target)
					for i in l:
						try:
							targets.append(host.Host(i, self.target))
							addr_list.append(i)
							host_str = '%s\n%s' % (i, self.target)
							self.result.get_hosts_list().add_host(host_str)
						except:
							print "Unimplemented support to address: %s." % i
				else:
					print "Error : Does not recoginise target"
			else:
				targets.append(host.Host(self.target))
				addr_list.append(self.target)
				self.result.get_hosts_list().add_host(self.target)
		else:
			for ip in IPNetwork(self.target):
				ip_str = '%s' % ip
				targets.append(host.Host(ip_str))
				addr_list.append(ip_str)
				self.result.get_hosts_list().add_host(ip_str)

		
		#addr = iter(addr_list)
		destaddr = addr_list[0]
		device = get_default_device(destaddr)
		#print "Destination Address-"
		#print(destaddr)
		if address.recognize(destaddr) == address.IPv4:
			saddr = get_ip_address(device)
		elif address.recognize(destaddr) == address.IPv6:
			temp_addr = get_ipv6_address(device)
			if temp_addr.find('%') != -1:
				saddr = temp_addr.split('%')[0]
				#saddr = "2001:0:53aa:64c:2c70:cf79:c44e:bda4"
			else:
				saddr = temp_addr
		else:
			print "Unknown address format"
		
			
		print "Source address -",
		print(saddr)

		opts = options.Options()
		opts.add("-c",device)
		opts.add("--forge-addr",saddr)
		# synproxy option
		opts.add("-y")
		        
		for target in targets:
			z = zion.Zion(opts,  [target])
			p = Process(target=z.run, args=(self.q2,))
			p.start()
Ejemplo n.º 6
0
	def start(self):
		"""
		"""
		z = zion.Zion(options.Options(), [])

		self.result.get_hosts_view().get_scans_page().clean()
		self.result.clear_port_list()

		# clear previous hosts in the list
		self.result.get_hosts_list().clear_hosts()

		# verify address to scan
		addr_list = []
		
		if self.target.find('/') == -1:
			if address.recognize(self.target) == address.Unknown:
				if address.is_name(self.target):
					l = probe.get_addr_from_name(self.target)
					for i in l:
						try:
							z.append_target(host.Host(i, self.target))
							host_str = '%s\n%s' % (i, self.target)
							addr_list.append(i)
							self.result.get_hosts_list().add_host(host_str)
						except:
							print "Unimplemented support to address: %s." % i
				else:
					print "Error : Does not recoginise target"
			else:
				z.append_target(host.Host(self.target))
				addr_list.append(self.target)
				self.result.get_hosts_list().add_host(self.target)
		else:
			for ip in IPNetwork(self.target):
				ip_str = '%s' % ip
				z.append_target(host.Host(ip_str))
				addr_list.append(ip_str)
				self.result.get_hosts_list().add_host(ip_str)
		
		
		#addr = iter(addr_list)
		print addr_list
		destaddr = addr_list[0]
		# configure zion options
		device = get_default_device(destaddr)
		
		if address.recognize(destaddr) == address.IPv4:
			saddr = get_ip_address(device)
		elif address.recognize(destaddr) == address.IPv6:
			temp_addr = get_ipv6_address(device)
			print(temp_addr)
			if temp_addr.find('%') != -1:
				saddr = temp_addr.split('%')[0]
				#saddr = "2001:0:53aa:64c:389d:9c27:87c7:55a8"
			else:
				saddr = temp_addr
		else:
			print "Unknown address format"
		
		##saddr = "2001:0:53aa:64c:38d3:b950:c44e:b128"
		#saddr = get_ip_address(device)
		#print "----------------------"
		#print saddr
		#print destaddr
		
		z.get_option_object().add("-c",device)
		z.get_option_object().add("-d")
		z.get_option_object().add("--forge-addr",saddr)

		p = Process(target=z.run, args=(self.q2,))
		p.start()
    def start(self):
        """
		"""
        self.result.get_hosts_list().clear_hosts()
        targets = []
        addr_list = []
        if self.target.find('/') == -1:
            print "It does not contain /"
            if address.recognize(self.target) == address.Unknown:
                if address.is_name(self.target):
                    l = probe.get_addr_from_name(self.target)
                    for i in l:
                        try:
                            targets.append(host.Host(i, self.target))
                            addr_list.append(i)
                            host_str = '%s\n%s' % (i, self.target)
                            self.result.get_hosts_list().add_host(host_str)
                        except:
                            print "Unimplemented support to address: %s." % i
                else:
                    print "Error : Does not recoginise target"
            else:
                targets.append(host.Host(self.target))
                addr_list.append(self.target)
                self.result.get_hosts_list().add_host(self.target)
        else:
            for ip in IPNetwork(self.target):
                ip_str = '%s' % ip
                targets.append(host.Host(ip_str))
                addr_list.append(ip_str)
                self.result.get_hosts_list().add_host(ip_str)

        #addr = iter(addr_list)
        destaddr = addr_list[0]
        device = get_default_device(destaddr)
        #print "Destination Address-"
        #print(destaddr)
        if address.recognize(destaddr) == address.IPv4:
            saddr = get_ip_address(device)
        elif address.recognize(destaddr) == address.IPv6:
            temp_addr = get_ipv6_address(device)
            if temp_addr.find('%') != -1:
                saddr = temp_addr.split('%')[0]
                #saddr = "2001:0:53aa:64c:2c70:cf79:c44e:bda4"
            else:
                saddr = temp_addr
        else:
            print "Unknown address format"

        print "Source address -",
        print(saddr)

        opts = options.Options()
        opts.add("-c", device)
        opts.add("--forge-addr", saddr)
        # synproxy option
        opts.add("-y")

        for target in targets:
            z = zion.Zion(opts, [target])
            p = Process(target=z.run, args=(self.q2, ))
            p.start()
class ZionProfilePrompt(ZionProfile):
    """
    """
    def __init__(self, target=None):
        """
        """
        ZionProfile.__init__(self, target)

        # hide attractor box
        self.result.get_hosts_view().get_scans_page().hide_attractor_box()

        self.__command_hbox = HIGHBox()
        self.__command_label = gtk.Label(_('Command:'))
        self.command_entry = gtk.Entry()

        self.__command_hbox._pack_noexpand_nofill(self.__command_label)
        self.__command_hbox._pack_expand_fill(self.command_entry)

        self._pack_noexpand_nofill(self.__command_hbox)

    def check_scan(self):
        """
        """
        if self.command_entry.get_text().strip():
            return True
        return False

    def start(self):
        """
        """
        zion_options = options.Options()

        # get command options
        command = self.command_entry.get_text().strip()
        try:
            opts, addrs = getopt.gnu_getopt(command.split(),
                                            options.OPTIONS_SHORT,
                                            options.OPTIONS_LONG)
        except getopt.GetoptError, e:
            print 'Error: %s.' % e

        for o in opts:
            opt, value = o
            zion_options.add(opt, value)

        # hide attractor box if not needed
        if zion_options.has(options.OPTION_DETECT) or zion_options.has(
                options.OPTION_SYNPROXY):
            self.result.get_hosts_view().get_scans_page().show_attractor_box()

        z = zion.Zion(zion_options, [])

        for a in addrs:
            if address.recognize(a) == address.Unknown:
                l = probe.get_addr_from_name(a)
                for i in l:
                    try:
                        z.append_target(host.Host(i, a))
                    except:
                        print "Unimplemented support to address: %s." % i
            else:
                z.append_target(host.Host(a))

        # run zion
        p = Process(target=z.run, args=(self.q2, ))
        p.start()
    def start(self):
        """
		"""
        z = zion.Zion(options.Options(), [])

        self.result.get_hosts_view().get_scans_page().clean()
        self.result.clear_port_list()

        # clear previous hosts in the list
        self.result.get_hosts_list().clear_hosts()

        # verify address to scan
        addr_list = []

        if self.target.find('/') == -1:
            if address.recognize(self.target) == address.Unknown:
                if address.is_name(self.target):
                    l = probe.get_addr_from_name(self.target)
                    for i in l:
                        try:
                            z.append_target(host.Host(i, self.target))
                            host_str = '%s\n%s' % (i, self.target)
                            addr_list.append(i)
                            self.result.get_hosts_list().add_host(host_str)
                        except:
                            print "Unimplemented support to address: %s." % i
                else:
                    print "Error : Does not recoginise target"
            else:
                z.append_target(host.Host(self.target))
                addr_list.append(self.target)
                self.result.get_hosts_list().add_host(self.target)
        else:
            for ip in IPNetwork(self.target):
                ip_str = '%s' % ip
                z.append_target(host.Host(ip_str))
                addr_list.append(ip_str)
                self.result.get_hosts_list().add_host(ip_str)

        #addr = iter(addr_list)
        print addr_list
        if len(addr_list) == 0:
            return
        destaddr = addr_list[0]
        # configure zion options
        device = get_default_device(destaddr)

        if address.recognize(destaddr) == address.IPv4:
            saddr = get_ip_address(device)
        elif address.recognize(destaddr) == address.IPv6:
            temp_addr = get_ipv6_address(device)
            print(temp_addr)
            if temp_addr.find('%') != -1:
                saddr = temp_addr.split('%')[0]
                #saddr = "2001:0:53aa:64c:389d:9c27:87c7:55a8"
            else:
                saddr = temp_addr
        else:
            print "Unknown address format"

        ##saddr = "2001:0:53aa:64c:38d3:b950:c44e:b128"
        #saddr = get_ip_address(device)
        #print "----------------------"
        #print saddr
        #print destaddr

        z.get_option_object().add("-c", device)
        z.get_option_object().add("-d")
        z.get_option_object().add("--forge-addr", saddr)

        p = Process(target=z.run, args=(self.q2, ))
        p.start()