def addtoqueue(self, rule, target, remove=False): success = False target = target.encode('ascii') job = rule.strip().split(' ')[0] job_type = job.split('|')[0].lower() job_info = job.split('|') while (len(job) < 3): job_info.append('') if (not self.verifyjob(job_type, job_info)): return success if (util.ip.validate_ipv6(target) and (not self.ipv6)): dsz.ui.Echo(('Target %s is an IPv6 address; redirector has no IPv6 address, not queueing' % (target, job_type)), dsz.WARNING) return False if (util.ip.validate_ipv6(target) and (not self.supportipv6(job_type))): dsz.ui.Echo(('Target %s is an IPv6 address; %s does not support IPv6, not queueing' % (target, job_type)), dsz.WARNING) return False if (target in self.local_addresses): dsz.ui.Echo(('Target %s is one of the IP addresses on our redirector, not queueing' % target), dsz.WARNING) return False elif (util.ip.validate_ipv6(target) and (util.ip.expand_ipv6(target) in self.local_addresses)): dsz.ui.Echo(('Target %s is one of the IP addresses on our redirector, not queueing' % target), dsz.WARNING) return False excludes = scanbase.get_excludes(self.session) if (target in excludes): return False success = scanbase.write_job(self.session, job, target) scanbase.set_jobtype(self.session, job_type) if (not success): dsz.ui.Echo(('Job %s for target %s already exists' % (job, target)), dsz.WARNING) return success
def addlisttoqueue(self, target_dict): excludes = scanbase.get_excludes(self.session) for rule in target_dict.keys(): target_list = target_dict[rule] job = rule.strip().split(' ')[0] job_type = job.split('|')[0].lower() job_info = job.split('|') while (len(job) < 3): job_info.append('') if (not self.verifyjob(job_type, job_info)): continue job_list = [] for target in target_list: if (util.ip.validate_ipv6(target) and (not self.ipv6)): dsz.ui.Echo(('Target %s is an IPv6 address; redirector has no IPv6 address, not queueing' % (target, job_type)), dsz.WARNING) return False if (util.ip.validate_ipv6(target) and (not self.supportipv6(job_type))): dsz.ui.Echo(('Target %s is an IPv6 address; %s does not support IPv6, not queueing' % (target, job_type)), dsz.WARNING) return False if (target in self.local_addresses): dsz.ui.Echo(('Target %s is one of the IP addresses on our redirector, not queueing' % target), dsz.WARNING) continue elif (util.ip.validate_ipv6(target) and (util.ip.expand_ipv6(target) in self.local_addresses)): dsz.ui.Echo(('Target %s is one of the IP addresses on our redirector, not queueing' % target), dsz.WARNING) continue if (target in excludes): continue job_list.append([job, target]) scanbase.set_jobtype(self.session, job_type) scanbase.write_job_list(self.session, job_list)
def display_excludes(self): excludes = scanbase.get_excludes(self.session) for target in excludes: dsz.ui.Echo(target)