Example #1
0
    def __init__(self,
                 config_in=None,
                 DEBUG=False,
                 VERBOSE=False,
                 legacy=False):
        self.debug = DEBUG
        self.verbose = VERBOSE
        self.legacy = legacy
        self.win_config = []
        self.errlog = []
        self.it = Interact()

        if config_in is not None:

            self.configs = config(config=config_in, VERBOSE=self.verbose)
            Validation(config_in, verbose=self.verbose).validate()
            if self.verbose:
                self.set_firewall = SetFirewall(config_in=config_in, verbose=2)
            else:
                self.set_firewall = SetFirewall(config_in=config_in, verbose=0)
            self.target_ranges = self.configs.configs.get('target_range', '')
            self.trusted_range = self.configs.configs.get('trusted_range', '')
            self.nostrike = self.configs.configs.get('nostrike', '')

            if self.debug:
                print self.configs
        else:
            raise Exception("[-] Please specify a configuration path!")

        self.GREEN_PLUS = "[{gp}+{endc}]".format(gp=bcolors.OKGREEN,
                                                 endc=bcolors.ENDC)
Example #2
0
    def __init__(self,
                 subnet=None,
                 config_in=None,
                 threads=4,
                 shuffle=False,
                 verbose=False):
        super(pingSweep, self).__init__(verbose=verbose)
        if subnet is not None:
            try:
                self.subnet_raw = subnet
                self.subnet = list(ipaddr.IPNetwork(subnet))
            except:
                raise Exception(
                    'Please ensure your subnet is in proper format: 192.168.1.0/24'
                )
        # TODO ADD NOSTRIKE AND MAKE OUTPUT FOR SCANNER NESSUS COMPATIBLE (IP,\n,IP)
        self.threads = threads
        self.queue = Queue()
        self.alive = 0
        self.alive_hosts = []
        self.shuffle = random
        self.it = Interact()
        self.root_check = self.it.root_check(debug=False)
        self.parse_args()
        self.config_in = config_in
        self.shuffle = shuffle
        self.verbose = verbose

        print config_in
        if config_in is not None:
            self.configs = config(config=config_in, VERBOSE=self.verbose)
            #Validation(config_in, verbose=self.verbose).validate()
            self.target_ranges = self.configs.configs.get('target_range', '')
            self.trusted_range = self.configs.configs.get('trusted_range', '')
            self.nostrike = self.configs.configs.get('nostrike', '')
        else:
            #print("[-] Please specify a configuration path!")
            self.nostrike = None

        self.GREEN_PLUS = "[{green}+{endc}]".format(green=bcolors.OKGREEN,
                                                    endc=bcolors.ENDC)
        self.WARN = "[{red}!{endc}]".format(red=bcolors.WARNING,
                                            endc=bcolors.ENDC)
        self.INFO = "[{obc}INFO{endc}]".format(obc=bcolors.OKBLUE,
                                               endc=bcolors.ENDC)
Example #3
0
    def validate(self):
        if self.config is not None:
            config_obj = config(config=self.config)
        key_map = self.field_type
        captured_errors = []
        missing_keys = []
        print("{bold}[VALIDATING CONFIGURATION]{endc}\n".format(
            bold=bcolors.OKBLUE, endc=bcolors.ENDC))
        for key in key_map:
            try:
                conf_key = config_obj.configs.get(key)
                if conf_key is None:
                    missing_keys.append(key)
                if conf_key:
                    for value in config_obj.configs.get(key):
                        valid = False
                        if key_map[key] == 'ip':
                            valid = self.ip_validator(value)
                        elif key_map[key] == 'subnet':
                            valid = self.network_validator(value)
                        elif key_map[key] == 'int':
                            valid = value.isdigit()
                        elif key_map[key] == 'hostname':
                            valid = self.hostname_check(value)
                        elif key_map[key] == 'mac':
                            valid = self.mac_check(value)
                        elif key_map[key] == 'eth_iface':
                            valid = self.eth_iface_check(value)
                        else:
                            pass
                        if valid == False:
                            FAIL = "[{red}FAIL{endred}] in configuration :: Check {key} setting: {value}".format(
                                key=key,
                                value=value,
                                red=bcolors.FAIL,
                                endred=bcolors.ENDC)
                            captured_errors.append(FAIL)
                            if self.verbose:
                                print(FAIL)
                        else:
                            if self.verbose:
                                print(
                                    "[{green}OK{endgreen}] {value} is a valid setting for {key}"
                                    .format(value=value,
                                            key=key,
                                            green=bcolors.OKGREEN,
                                            endgreen=bcolors.ENDC))
            except Exception as e:
                print e
        if missing_keys:
            for key in missing_keys:
                WARNING = "{warning_c}[WARNING]{warning_end} No setting for {key} was found.".format(
                    warning_c=bcolors.WARNING,
                    warning_end=bcolors.ENDC,
                    key=key)
                print(WARNING)

        if captured_errors:
            CONFIG_ERROR = "{error_count} errors detect. Please verify your settings in {config}".format(
                error_count=len(captured_errors), config=self.config)
            if self.verbose:
                print("\n\n" + "=" * 10 + 'ERROR REPORT' + "=" * 10)
                for error in captured_errors:
                    print(error)
            print CONFIG_ERROR
            exit()
        else:
            print(
                "{newline}[{green}VALID CONFIG{endgreen}] No Errors Detected.".
                format(newline="=" * 30 + '\n',
                       green=bcolors.OKGREEN,
                       endgreen=bcolors.ENDC))
        return