def net_mode(): ori_str = conf.NETWORK_STR try: _list = IPy.IP(ori_str) except Exception as e: sys.exit(logger.error('Invalid IP/MASK,%s' % e)) for each in _list: th.queue.put(str(each))
def handle_addr(addr): ''' Handle addr user input, return IP list. ''' try: return IPy.IP(addr) except ValueError: print '[-] Invalid CIDR.' sys.exit(0)
def setTarget(): ori_str = conf.TARGET = sys.argv[1] for each in ori_str: if each.isalpha(): conf.MODE = TARGET_MODE.DOMAIN break else: conf.MODE = TARGET_MODE.IP try: _list = IPy.IP(ori_str) except Exception, e: sys.exit(logger.error('Invalid IP, %s' % e))
def check_target(self): """Check targets and add in queue""" ok = 0 if self.ip != None: try: _list = IPy.IP(self.ip) except Exception, e: logger.error('Invalid IP/MASK, %s' % e) return False for i in _list: self.targets.put(str(i)) ok = 1
def net_mode(): ori_str = conf.NETWORK_STR try: _list = IPy.IP(ori_str) except Exception, e: sys.exit(logger.error('Invalid IP/MASK,%s' % e))
def collect_ip_range(ip_list, netmask='255.255.255.0'): ''' Collect IP range by IP list. ''' ip_range_list = [str(IPy.IP(ip).make_net(netmask)) for ip in ip_list] return list(set(ip_range_list))
def cidr_mode(): ori_str = conf.NETWORK_STR try: _list = IPy.IP(ori_str) #使用IPy插件得到IP列表 except Exception, e: sys.exit(logger.error('Invalid IP/MASK,%s' % e))