Exemple #1
0
    def __init__(
        self,
        paths,
        extensions,
        suffixes=None,
        prefixes=None,
        lowercase=False,
        uppercase=False,
        capitalization=False,
        forcedExtensions=False,
        noDotExtensions=False,
        excludeExtensions=[],
        noExtension=False,
    ):

        self.entries = []
        self.currentIndex = 0
        self.condition = threading.Lock()
        self._extensions = extensions
        self._excludeExtensions = excludeExtensions
        self._prefixes = prefixes
        self._suffixes = suffixes
        self._paths = paths
        self._forcedExtensions = forcedExtensions
        self._noDotExtensions = noDotExtensions
        self._noExtension = noExtension
        self.lowercase = lowercase
        self.uppercase = uppercase
        self.capitalization = capitalization
        self.dictionaryFiles = [File(path) for path in self.paths]
        self.generate()
Exemple #2
0
 def __init__(self, path, extensions, lowercase=False):
     self.entries = []
     self.currentIndex = 0
     self.condition = threading.Lock()
     self._extensions = extensions
     self._path = path
     self.lowercase = lowercase
     self.dictionaryFile = File(self.path)
     self.generate(lowercase=self.lowercase)
    def __init__(self, script_path):
        self.script_path = script_path
        self.parseConfig()

        options = self.parseArguments()

        if options.url == None:
            if options.urlList != None:
                with File(options.urlList) as urlList:
                    if not urlList.exists():
                        print("The file with URLs does not exist")
                        exit(0)
Exemple #4
0
 def __init__(self, paths, directory, filename, extension, extensions=[], lowercase=False, forcedExtensions=False):
     self.entries = []
     self.directory = directory
     self.filename = filename
     self.extension = extension
     self.currentIndex = 0
     self.condition = threading.Lock()
     self._extensions = extensions
     self._paths = paths
     self._forcedExtensions = forcedExtensions
     self.lowercase = lowercase
     self.dictionaryFiles = [File(path) for path in self.paths]
     self.generate()
Exemple #5
0
    def __init__(self, script_path):
        self.script_path = script_path
        self.parseConfig()
        options = self.parseArguments()
        if options.url == None:
            if options.urlList != None:
                with File(options.urlList) as urlList:
                    if not urlList.exists():
                        print("The file with URLs does not exist")
                        exit(0)
                    if not urlList.isValid():
                        print('The wordlist is invalid')
                        exit(0)
                    if not urlList.canRead():
                        print('The wordlist cannot be read')
                        exit(0)
                    self.urlList = list(urlList.getLines())
            elif options.url == None:
                print('URL target is missing, try using -u <url> ')
                exit(0)
        else:
            self.urlList = [options.url]
        if options.extensions == None:
            print(
                'No extension specified. You must specify at least one extension'
            )
            exit(0)
        with File(options.wordlist) as wordlist:
            if not wordlist.exists():
                print('The wordlist file does not exist')
                exit(0)
            if not wordlist.isValid():
                print('The wordlist is invalid')
                exit(0)
            if not wordlist.canRead():
                print('The wordlist cannot be read')
                exit(0)
        if options.httpProxy is not None:
            if options.httpProxy.startswith('http://'):
                self.proxy = options.httpProxy
            else:
                self.proxy = 'http://{0}'.format(options.httpProxy)
        else:
            self.proxy = None
        if options.headers is not None:
            try:
                self.headers = dict(
                    (key.strip(), value.strip())
                    for (key, value) in (header.split(':', 1)
                                         for header in options.headers))
            except Exception as e:
                print('Invalid headers')
                exit(0)
        else:
            self.headers = {}

        self.extensions = list(
            oset([
                extension.strip()
                for extension in options.extensions.split(',')
            ]))
        self.useragent = options.useragent
        self.useRandomAgents = options.useRandomAgents
        self.cookie = options.cookie
        if options.threadsCount < 1:
            print('Threads number must be a number greater than zero')
            exit(0)
        self.threadsCount = options.threadsCount
        if options.excludeStatusCodes is not None:
            try:
                self.excludeStatusCodes = list(
                    oset([
                        int(excludeStatusCode.strip())
                        if excludeStatusCode else None for excludeStatusCode in
                        options.excludeStatusCodes.split(',')
                    ]))
            except ValueError:
                self.excludeStatusCodes = []
        else:
            self.excludeStatusCodes = []
        self.wordlist = options.wordlist
        self.lowercase = options.lowercase
        self.forceExtensions = options.forceExtensions
        self.simpleOutputFile = options.simpleOutputFile
        self.plainTextOutputFile = options.plainTextOutputFile
        self.jsonOutputFile = options.jsonOutputFile
        self.delay = options.delay
        self.timeout = options.timeout
        self.ip = options.ip
        self.maxRetries = options.maxRetries
        self.recursive = options.recursive
        self.suppressEmpty = options.suppressEmpty
        if options.scanSubdirs is not None:
            self.scanSubdirs = list(
                oset([
                    subdir.strip() for subdir in options.scanSubdirs.split(',')
                ]))
            for i in range(len(self.scanSubdirs)):
                while self.scanSubdirs[i].startswith("/"):
                    self.scanSubdirs[i] = self.scanSubdirs[i][1:]
                while self.scanSubdirs[i].endswith("/"):
                    self.scanSubdirs[i] = self.scanSubdirs[i][:-1]
            self.scanSubdirs = list(
                oset([subdir + "/" for subdir in self.scanSubdirs]))
        else:
            self.scanSubdirs = None
        if not self.recursive and options.excludeSubdirs is not None:
            print(
                '--exclude-subdir argument can only be used with -r|--recursive'
            )
            exit(0)
        elif options.excludeSubdirs is not None:
            self.excludeSubdirs = list(
                oset([
                    subdir.strip()
                    for subdir in options.excludeSubdirs.split(',')
                ]))
            for i in range(len(self.excludeSubdirs)):
                while self.excludeSubdirs[i].startswith("/"):
                    self.excludeSubdirs[i] = self.excludeSubdirs[i][1:]
                while self.excludeSubdirs[i].endswith("/"):
                    self.excludeSubdirs[i] = self.excludeSubdirs[i][:-1]
            self.excludeSubdirs = list(oset(self.excludeSubdirs))
        else:
            self.excludeSubdirs = None
        self.redirect = options.noFollowRedirects
        self.requestByHostname = options.requestByHostname
Exemple #6
0
    def __init__(self, script_path):
        self.script_path = script_path
        self.parseConfig()

        options = self.parseArguments()

        self.clean_view = options.clean_view
        self.full_url = options.full_url
        
        if options.url == None:

            if options.urlList != None:

                with File(options.urlList) as urlList:

                    if not urlList.exists():
                        print("The file with URLs does not exist")
                        exit(0)

                    if not urlList.isValid():
                        print("The file with URLs is invalid")
                        exit(0)

                    if not urlList.canRead():
                        print("The file with URLs cannot be read")
                        exit(0)

                    self.urlList = list(urlList.getLines())

            elif options.url == None:
                print("URL target is missing, try using -u <url> ")
                exit(0)

        else:
            self.urlList = [options.url]


        if not options.extensions and not options.defaultExtensions:
            print('No extension specified. You must specify at least one extension or try using default extension list.')
            exit(0)

        if not options.extensions and options.defaultExtensions:
            options.extensions = self.defaultExtensions

        # Enable to use multiple dictionaries at once
        for dictFile in options.wordlist.split(','):
            with File(dictFile) as wordlist:
                if not wordlist.exists():
                    print('The wordlist file does not exist')
                    exit(1)

                if not wordlist.isValid():
                    print('The wordlist is invalid')
                    exit(1)

                if not wordlist.canRead():
                    print('The wordlist cannot be read')
                    exit(1)

        if options.proxyList is not None:
            with File(options.proxyList) as plist:
                if not plist.exists():
                    print('The proxylist file does not exist')
                    exit(1)

                if not plist.isValid():
                    print('The proxylist is invalid')
                    exit(1)

                if not plist.canRead():
                    print('The proxylist cannot be read')
                    exit(1)

            self.proxylist = open(options.proxyList).read().splitlines()


        elif options.httpProxy is not None:
            if options.httpProxy.startswith("http://"):
                self.proxy = options.httpProxy
            else:
                self.proxy = "http://{0}".format(options.httpProxy)

        else:
            self.proxy = None

        if options.headers is not None:
            try:
                self.headers = dict(
                    (key.strip(), value.strip())
                    for (key, value) in (
                        header.split(":", 1) for header in options.headers
                    )
                )
            except Exception as e:
                print("Invalid headers")
                exit(0)

        else:
            self.headers = {}

        self.extensions = list(
            oset([extension.strip() for extension in options.extensions.split(",")])
        )
        self.useragent = options.useragent
        self.useRandomAgents = options.useRandomAgents
        self.cookie = options.cookie

        if options.threadsCount < 1:
            print('Threads number must be a number greater than zero')
            exit(1)


        self.threadsCount = options.threadsCount

        if options.includeStatusCodes:

            try:
                self.includeStatusCodes = list(
                    oset([int(includeStatusCode.strip()) if includeStatusCode else None for includeStatusCode in
                          options.includeStatusCodes.split(',')]))
                
            except ValueError:
                self.includeStatusCodes = []

        else:
            self.includeStatusCodes = []
            
        if options.excludeExtensions:

            try:
                self.excludeExtensions = list(
                    oset(
                        [
                            excludeExtension.strip() if excludeExtension else None
                            for excludeExtension in options.excludeExtensions.split(",")
                        ]
                    )
                )
                
            except ValueError:
                self.excludeExtensions = []

        else:
            self.excludeExtensions = []

        if options.excludeStatusCodes:

            try:
                self.excludeStatusCodes = list(
                    oset(
                        [
                            int(excludeStatusCode.strip())
                            if excludeStatusCode
                            else None
                            for excludeStatusCode in options.excludeStatusCodes.split(
                                ","
                            )
                        ]
                    )
                )
                
            except ValueError:
                self.excludeStatusCodes = []

        else:
            self.excludeStatusCodes = []

        if options.excludeTexts:
            try:
                self.excludeTexts = list(

                    oset(
                        [
                            excludeTexts.strip() if excludeTexts else None
                            for excludeTexts in options.excludeTexts.split(",")
                        ]
                    )
                )

            except ValueError:
                self.excludeTexts = []
        else:
            self.excludeTexts = []


        if options.excludeRegexps:
            try:
                self.excludeRegexps = list(
                    oset(
                        [
                            excludeRegexps.strip() if excludeRegexps else None
                            for excludeRegexps in options.excludeRegexps.split(",")
                        ]
                    )
                )

            except ValueError:
                self.excludeRegexps = []
        else:
            self.excludeRegexps = []


        self.suffixes = [] if not options.suffixes else list(oset([suffix.strip() for suffix in options.suffixes.split(',')]))
        self.wordlist = list(oset([wordlist.strip() for wordlist in options.wordlist.split(',')]))

        self.lowercase = options.lowercase
        self.uppercase = options.uppercase
        self.forceExtensions = options.forceExtensions
        self.data = options.data
        self.noDotExtensions = options.noDotExtensions
        self.simpleOutputFile = options.simpleOutputFile
        self.plainTextOutputFile = options.plainTextOutputFile
        self.jsonOutputFile = options.jsonOutputFile
        self.quietMode = options.quietMode
        self.delay = options.delay
        self.timeout = options.timeout
        self.ip = options.ip
        self.maxRetries = options.maxRetries
        self.recursive = options.recursive
        self.suppressEmpty = options.suppressEmpty
        self.minimumResponseSize = options.minimumResponseSize
        self.maximumResponseSize = options.maximumResponseSize


        if options.scanSubdirs is not None:
            self.scanSubdirs = list(
                oset([subdir.strip() for subdir in options.scanSubdirs.split(",")])
            )

            for i in range(len(self.scanSubdirs)):

                while self.scanSubdirs[i].startswith("/"):
                    self.scanSubdirs[i] = self.scanSubdirs[i][1:]

                while self.scanSubdirs[i].endswith("/"):
                    self.scanSubdirs[i] = self.scanSubdirs[i][:-1]

            self.scanSubdirs = list(oset([subdir + "/" for subdir in self.scanSubdirs]))

        else:
            self.scanSubdirs = None

        if not self.recursive and options.excludeSubdirs is not None:
            print("--exclude-subdir argument can only be used with -r|--recursive")
            exit(0)


        elif options.excludeSubdirs is not None:
            self.excludeSubdirs = list(
                oset([subdir.strip() for subdir in options.excludeSubdirs.split(",")])
            )

            for i in range(len(self.excludeSubdirs)):

                while self.excludeSubdirs[i].startswith("/"):
                    self.excludeSubdirs[i] = self.excludeSubdirs[i][1:]

                while self.excludeSubdirs[i].endswith("/"):
                    self.excludeSubdirs[i] = self.excludeSubdirs[i][:-1]
            self.excludeSubdirs = list(oset(self.excludeSubdirs))

        else:
            self.excludeSubdirs = None
            
        
        if len(set(self.extensions).intersection(self.excludeExtensions)):
            print("Exclude extensions can not contain any extension that already in the extensions")
            exit(0)
            

        self.redirect = options.noFollowRedirects
        self.requestByHostname = options.requestByHostname
        self.httpmethod = options.httpmethod

        self.recursive_level_max = options.recursive_level_max
Exemple #7
0
    def __init__(self, script_path):
        self.script_path = script_path
        self.parse_config()
        options = self.parse_arguments()
        self.debug = options.debug

        # Parse Target URL
        if options.url is None:
            if options.url_list is not None:
                with File(options.url_list) as url_list:
                    if not url_list.is_valid():
                        print("The file with URLs does not exist")
                        exit(0)

                    if not url_list.is_readable():
                        print('The file with URLs cannot be read')
                        exit(0)

                    self.urlList = list(url_list.get_lines())

            elif options.url == None:
                print('URL target is missing, try using -u <url> ')
                exit(0)
        else:
            self.url_list = [options.url]

        # Parse connection settings

        # Proxy
        if options.http_proxy is not None:
            if options.http_proxy.startswith('http://'):
                self.proxy = options.http_proxy
            else:
                self.proxy = 'http://{0}'.format(options.http_proxy)
        else:
            self.proxy = None

        # Headers
        if options.headers is not None:
            try:
                self.headers = dict(
                    (key.strip(), value.strip())
                    for (key, value) in (header.split(':', 1)
                                         for header in options.headers))
            except Exception as e:
                print('Invalid headers')
                exit(1)
        else:
            self.headers = {}

        self.useragent = options.useragent
        self.use_random_agents = options.use_random_agents
        self.cookie = options.cookie

        if options.threads_count < 1:
            print('Threads number must be a number greater than zero')
            exit(0)

        self.threads_count = options.threads_count
        self.delay = options.delay
        self.timeout = options.timeout

        self.max_retries = options.max_retries
        self.redirect = options.no_follow_redirects
        if (options.dns_cache and options.ip_addr) or (self.dns_cache
                                                       and options.dns_cache):
            print("DNS Cache and IP address cannot be used together.")
            exit(0)

        self.dns_cache = options.dns_cache
        self.ip_addr = options.ip_addr

        # Parse usernames argument

        self.usernames = [
            username.strip() for username in options.usernames.split(',')
        ]

        # Parse Wordlist Settings
        dict_args = {
            'Usernames Wordlist': 'username_wordlist',
            'Passwords Wordlist': 'userpass_wordlist',
            'UserPass Combo Wordlist': 'userpass_wordlist'
        }

        for wordlist_label, wordlist_var in dict_args.items():
            if len(getattr(options, wordlist_var)) == 0:
                setattr(self, wordlist_var, [])
            try:
                stripped_values = [
                    value.strip() for value in getattr(options, wordlist_var)
                ]
                setattr(self, wordlist_var, stripped_values)
            except:
                print('{0} Unhandled error'.format(wordlist_label))
                exit(1)

            for f in getattr(self, wordlist_var):
                with File(f) as wordlist:
                    if not wordlist.is_valid():

                        print('The {0} file does not exist'.format(
                            wordlist_label))
                        exit(1)
                    if not wordlist.is_readable():
                        print('The {0} file cannot be read'.format(
                            wordlist_label))
                        exit(1)

        self.userpass_wordlist_separator = options.userpass_wordlist_separator