Exemplo n.º 1
0
class Wig():

	def __init__(self, host, profile, verbose, desperate, plugin_name=None):
		self.plugins = self.load_plugins()
		self.host = host
		self.results = Results()
		self.cache = Cache()		
		self.profile = Profile(profile)
		self.colorizer = Color()
		self.logs = Log()
		self.verbose = verbose
		self.plugin_name = plugin_name

		self.check_url()
		self.redirect()
		self.cache.set_host(self.host)

		if desperate:
			self.desperate = Desperate()
		else:
			self.desperate = None


	def redirect(self):
		# detects redirection if this happend
		try:
			r = requests.get(self.host, verify=False)
		except:
			print("Invalid URL or host not found. Exiting...")
			sys.exit(0)

		if not r.url == self.host:

			# ensure that sub-folders and files are removed
			parts = r.url.split('//')
			http, url = parts[0:2]

			# remove subfolders and/or files
			# http://example.com/test -> http://example.com/
			if '/' in url:
				redirected = http + '//' + url.split('/')[0] + '/'
			else:
				redirected = http + '//' + url + '/'

			self.host = redirected

	
	def check_url(self):
		# adds http:// to input if not present
		if not self.host.startswith("http"):
			self.host = "http://" + self.host


	def load_plugins(self):
		# load all the plugins listed in plugins/__init__.py
		all_plugins = []
		for p in plugins.__all__:
			plugin_path = "plugins." + p
			__import__(plugin_path)
			all_plugins.append(sys.modules[plugin_path])

		return all_plugins


	def run(self):
		t = time.time()
		num_fps = 0
		num_plugins = 0
		# loops over all the plugins loaded
		for plugin in self.plugins:

			# a loaded plugin might have more than one plugin, so 'ps' is a list
			ps = plugin.get_instances(self.host, self.cache, self.results)
			num_plugins += len(ps)
			for p in ps:

				# give a status of which plugin is run
				print(p.name, end="                                                \r")
				sys.stdout.flush()

				# applies the choosen profile by removing fingerprints from the 
				# fingerprint set if these do not match the choosen profile
				p.set_profile(self.profile, self.plugin_name)

				# the main plugin method
				p.run()
				num_fps += p.get_num_fps()

				# check if running desperate mode.
				if self.desperate:
					# add the plugins fingerprints to the global fingerprint database
					self.desperate.add_fingerprints(p.get_items_for_desperate_mode())


				# add logs
				self.logs.add( p.get_logs() )


		if self.desperate:
			self.desperate.set_cache(self.cache)
			self.desperate.run()
			for i in self.desperate.get_matches():
				self.results.add('Desperate', i['cms'], i, i['count'])

		# check the response headers for information
		ch = CheckHeaders(self.cache, self.results, self.logs)
		ch.run()

		run_time = "%.1f" % (time.time() - t)
		num_urls = self.cache.get_num_urls()

		status = "Time: %s sec | Plugins: %s | Urls: %s | Fingerprints: %s" % (run_time, num_plugins, num_urls, num_fps)
		bar = "_"*len(status)
		self.results.set_width(len(status))

		print(self.results)
		print(bar)
		print(status + "\n")

		if self.verbose:
			print(bar)
			print(self.logs)
Exemplo n.º 2
0
class Wig():
    def __init__(self, host, profile, verbose, desperate, plugin_name=None):
        self.plugins = self.load_plugins()
        self.host = host
        self.results = Results()
        self.cache = Cache()
        self.profile = Profile(profile)
        self.colorizer = Color()
        self.logs = Log()
        self.verbose = verbose
        self.plugin_name = plugin_name

        self.check_url()
        self.redirect()
        self.cache.set_host(self.host)

        if desperate:
            self.desperate = Desperate()
        else:
            self.desperate = None

    def redirect(self):
        # detects redirection if this happend
        try:
            r = requests.get(self.host, verify=False)
        except:
            print("Invalid URL or host not found. Exiting...")
            sys.exit(0)

        if not r.url == self.host:

            # ensure that sub-folders and files are removed
            parts = r.url.split('//')
            http, url = parts[0:2]

            # remove subfolders and/or files
            # http://example.com/test -> http://example.com/
            if '/' in url:
                redirected = http + '//' + url.split('/')[0] + '/'
            else:
                redirected = http + '//' + url + '/'

            self.host = redirected

    def check_url(self):
        # adds http:// to input if not present
        if not self.host.startswith("http"):
            self.host = "http://" + self.host

    def load_plugins(self):
        # load all the plugins listed in plugins/__init__.py
        all_plugins = []
        for p in plugins.__all__:
            plugin_path = "plugins." + p
            __import__(plugin_path)
            all_plugins.append(sys.modules[plugin_path])

        return all_plugins

    def run(self):
        t = time.time()
        num_fps = 0
        num_plugins = 0
        # loops over all the plugins loaded
        for plugin in self.plugins:

            # a loaded plugin might have more than one plugin, so 'ps' is a list
            ps = plugin.get_instances(self.host, self.cache, self.results)
            num_plugins += len(ps)
            for p in ps:

                # give a status of which plugin is run
                print(p.name,
                      end="                                                \r")
                sys.stdout.flush()

                # applies the choosen profile by removing fingerprints from the
                # fingerprint set if these do not match the choosen profile
                p.set_profile(self.profile, self.plugin_name)

                # the main plugin method
                p.run()
                num_fps += p.get_num_fps()

                # check if running desperate mode.
                if self.desperate:
                    # add the plugins fingerprints to the global fingerprint database
                    self.desperate.add_fingerprints(
                        p.get_items_for_desperate_mode())

                # add logs
                self.logs.add(p.get_logs())

        if self.desperate:
            self.desperate.set_cache(self.cache)
            self.desperate.run()
            for i in self.desperate.get_matches():
                self.results.add('Desperate', i['cms'], i, i['count'])

        # check the response headers for information
        ch = CheckHeaders(self.cache, self.results, self.logs)
        ch.run()

        run_time = "%.1f" % (time.time() - t)
        num_urls = self.cache.get_num_urls()

        status = "Time: %s sec | Plugins: %s | Urls: %s | Fingerprints: %s" % (
            run_time, num_plugins, num_urls, num_fps)
        bar = "_" * len(status)
        self.results.set_width(len(status))

        print(self.results)
        print(bar)
        print(status + "\n")

        if self.verbose:
            print(bar)
            print(self.logs)