Example #1
0
    def __init__(self, args):

        self.options = {
            'url': args.url,
            'prefix': '',
            'user_agent': args.user_agent,
            'proxy': args.proxy,
            'verbosity': args.verbosity,
            'threads': 10,
            'chunk_size': 10,  # same as threads
            'run_all': args.run_all,
            'match_all': args.match_all,
            'stop_after': args.stop_after,
            'no_cache_load': args.no_cache_load,
            'no_cache_save': args.no_cache_save,
        }

        self.data = {
            'cache': Cache(),
            'results': Results(self.options),
            'fingerprints': Fingerprints(),
            'matcher': Match(),
            'colorizer': Color(),
            'printer': Printer(args.verbosity, Color()),
            'detected_cms': set(),
            'error_pages': set(),
            'queue': queue.Queue(),
            'requested': queue.Queue()
        }

        self.data['results'].set_printer(self.data['printer'])
        self.data['requester'] = Requester(self.options, self.data)
Example #2
0
def generateFourPlayerSet():
    """
    Generate a board 9x9 with all the pieces
    :return:
    """

    green = Color("Green", "#01D758")
    blue = Color("Blue", "#0131B4")
    red = Color("Red", "#DB1702")
    yellow = Color("Yellow", "#FCDC12")

    board = Board((9, 9))

    board.cells[0][0].pions = [Chief((0, 0), yellow)]
    board.cells[0][1].pions = [Assassin((0, 1), yellow)]
    board.cells[0][2].pions = [Militant((0, 2), yellow)]
    board.cells[1][0].pions = [Reporter((1, 0), yellow)]
    board.cells[1][1].pions = [Diplomat((1, 1), yellow)]
    board.cells[1][2].pions = [Militant((1, 2), yellow)]
    board.cells[2][0].pions = [Militant((2, 0), yellow)]
    board.cells[2][1].pions = [Militant((2, 1), yellow)]
    board.cells[2][2].pions = [Necromobile((2, 2), yellow)]

    board.cells[0][6].pions = [Militant((0, 6), green)]
    board.cells[0][7].pions = [Assassin((0, 7), green)]
    board.cells[0][8].pions = [Chief((0, 8), green)]
    board.cells[1][6].pions = [Militant((1, 6), green)]
    board.cells[1][7].pions = [Diplomat((1, 7), green)]
    board.cells[1][8].pions = [Reporter((1, 8), green)]
    board.cells[2][6].pions = [Necromobile((2, 6), green)]
    board.cells[2][7].pions = [Militant((2, 7), green)]
    board.cells[2][8].pions = [Militant((2, 8), green)]

    board.cells[6][0].pions = [Chief((6, 0), blue)]
    board.cells[6][1].pions = [Assassin((6, 1), blue)]
    board.cells[6][2].pions = [Militant((6, 2), blue)]
    board.cells[7][0].pions = [Reporter((7, 0), blue)]
    board.cells[7][1].pions = [Diplomat((7, 1), blue)]
    board.cells[7][2].pions = [Militant((7, 2), blue)]
    board.cells[8][0].pions = [Militant((8, 0), blue)]
    board.cells[8][1].pions = [Militant((8, 1), blue)]
    board.cells[8][2].pions = [Necromobile((8, 2), blue)]

    board.cells[6][6].pions = [Militant((6, 6), red)]
    board.cells[6][7].pions = [Assassin((6, 7), red)]
    board.cells[6][8].pions = [Chief((6, 8), red)]
    board.cells[7][6].pions = [Militant((7, 6), red)]
    board.cells[7][7].pions = [Diplomat((7, 7), red)]
    board.cells[7][8].pions = [Reporter((7, 8), red)]
    board.cells[8][6].pions = [Necromobile((8, 6), red)]
    board.cells[8][7].pions = [Militant((8, 7), red)]
    board.cells[8][8].pions = [Militant((8, 8), red)]
Example #3
0
File: wig.py Project: r00tb0x/wig
    def __init__(self, args):

        urls = None
        interactive = True

        if args.input_file is not None:
            interactive = False

            with open(args.input_file, 'r') as input_file:
                urls = []
                for url in input_file.readlines():
                    u = url.strip()
                    urls.append(u if '://' in u else 'http://' + u)

        elif '://' not in args.url:
            args.url = 'http://' + args.url

        self.options = {
            'url': args.url,
            'urls': urls,
            'interactive': interactive,
            'prefix': '',
            'user_agent': args.user_agent,
            'proxy': args.proxy,
            'verbosity': args.verbosity,
            'threads': 10,
            'batch_size': 20,
            'run_all': args.run_all,
            'match_all': args.match_all,
            'stop_after': args.stop_after,
            'no_cache_load': args.no_cache_load,
            'no_cache_save': args.no_cache_save,
            'write_file': args.output_file
        }

        self.data = {
            'cache': Cache(),
            'results': Results(self.options),
            'fingerprints': Fingerprints(),
            'matcher': Match(),
            'colorizer': Color(),
            'printer': Printer(args.verbosity, Color()),
            'detected_cms': set(),
            'error_pages': set(),
            'requested': queue.Queue()
        }

        if self.options['write_file'] is not None:
            self.json_outputter = OutputJSON(self.options, self.data)
Example #4
0
 def __init__(self):
     self.name = 'player'
     self.depth = 0
     self.doors = random.randint(MIN_DOORS, MAX_DOORS)
     self.color = Color().become_random_color()
     self.sitting = False
     self.locale = Localization()
Example #5
0
    def __init__(self, host, profile, verbose, desperate):
        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.check_url()
        self.redirect()
        self.cache.set_host(self.host)

        if desperate:
            self.desperate = Desperate()
        else:
            self.desperate = None
Example #6
0
File: log.py Project: xstpl/wig
class Log(object):
	def __init__(self):
		self.logs = defaultdict(lambda: defaultdict(set))
		self.colorizer = Color()

	def __str__(self):
		out = ""

		for url in self.logs:
			out += "Url: " + url
			for cms in self.logs[url]:
				lst = self.colorizer.format("[" + ", ".join(self.logs[url][cms]) + "]", 'red', False)
				out += "  %s: %s" % (cms, lst)
			out +=  "\n"

		return out

	def add(self, logs):
		for url in logs:
			for cms in logs[url]:
				for version in logs[url][cms]:
					self.logs[url][cms].add(str(version))
Example #7
0
File: results.py Project: kenni/wig
    def __init__(self, options):
        self.width = None
        self.color = Color()
        self.printer = None
        self.results = {}

        # the storage for 'string' and 'regex' matched fingerprints
        # since these don't need extra processing they are added directly
        # to the final scores
        self.scores = defaultdict(lambda: defaultdict(lambda: Counter()))
        #		      ^ Category          ^ Name              ^ Version

        # md5 fingerprints are based on content that might not hav been changed
        # across different versions of the cms. The score of a match is based on
        # the number of 'hits' for that URL. The finale score for a cms version will be:
        #  1 / number_of_hits
        #
        self.md5_matches = defaultdict(lambda: defaultdict(lambda: set()))
        #		           ^ Url               ^ cms               ^ versions

        self.sitemap = Sitemap()

        self.site_info = {'ip': '', 'title': '', 'cookies': ''}
Example #8
0
 def __init__(self, color, value, available=True, in_play=False):
     self.color = Color(color)
     self.value = value
     self.available = available
     self.in_play = in_play
Example #9
0
	def __init__(self):
		self.width = None
		self.color = Color()
		self.results = defaultdict(lambda: defaultdict(lambda: defaultdict(float)))
Example #10
0
class Results(object):

	def __init__(self):
		self.width = None
		self.color = Color()
		self.results = defaultdict(lambda: defaultdict(lambda: defaultdict(float)))
		#              ^Category   ^Plugin     ^Version    ^weight  

	def add(self, category, plugin, data, weight=False):
		v = data['version']
		dw = data['count']

		if type(v) == bool: v = ""

		if type(weight) == bool:
			w = 1.0/dw if weight else dw
			self.results[category][plugin][v] += w
		elif type(weight) == int or type(weight) == float:
			self.results[category][plugin][v] += weight
		else:
			pass

	def get_results(self):
		return self.results

	def set_width(self, width):
		self.width = width

	def __str__(self):
		out = "\n"
		o_cat = sorted([c for c in self.results])

		for category in o_cat:

			#out += "{0:<20}".format(category, )
			start = "___ " + self.color.format(category, 'red', False) + " "
			out +=	start + "_" * (self.width - (len(category) + 5)) + "\n"
			plugin_list = []

			o_plug = sorted([p for p in self.results[category]])
			for plugin in o_plug:
				v = self.results[category][plugin]

				# get only most relevant results
				# sort by weight
				versions = sorted(v.items(), key=lambda x:x[1], reverse=True)

				# pick only the first(s) element
				relevant = []
				for i in versions:
					if i[1] == versions[0][1]:

						# do not append blank output strings
						if len(relevant) > 0  and i[0] == "":
							continue

						relevant.append(i[0])
					else:
						break

				plug_str = "%s: " % (plugin, )
				ver_str =  ", ".join(relevant)

				plugin_list.append(plug_str + ver_str)
			
			out += "\n".join(plugin_list) + "\n\n"

		return out[:-1]
Example #11
0
File: log.py Project: xstpl/wig
	def __init__(self):
		self.logs = defaultdict(lambda: defaultdict(set))
		self.colorizer = Color()
Example #12
0
 def __init__(self):
     self.width = None
     self.color = Color()
     self.results = defaultdict(
         lambda: defaultdict(lambda: defaultdict(float)))
Example #13
0
class Results(object):
    def __init__(self):
        self.width = None
        self.color = Color()
        self.results = defaultdict(
            lambda: defaultdict(lambda: defaultdict(float)))
        #              ^Category           ^Plugin             ^Version    ^weight

    def add(self, category, plugin, data, weight=False):
        v = data['version']
        dw = data['count']

        if type(v) == bool: v = ""

        if type(weight) == bool:
            w = 1.0 / dw if weight else dw
            self.results[category][plugin][v] += w
        elif type(weight) == int or type(weight) == float:
            self.results[category][plugin][v] += weight
        else:
            pass

    def get_results(self):
        return self.results

    def set_width(self, width):
        self.width = width

    def __str__(self):
        out = "\n"
        o_cat = sorted([c for c in self.results])

        for category in o_cat:

            #out += "{0:<20}".format(category, )
            start = "___ " + self.color.format(category, 'red', False) + " "
            out += start + "_" * (self.width - (len(category) + 5)) + "\n"
            plugin_list = []

            o_plug = sorted([p for p in self.results[category]])
            for plugin in o_plug:
                v = self.results[category][plugin]

                # get only most relevant results
                # sort by weight
                versions = sorted(v.items(), key=lambda x: x[1], reverse=True)

                # pick only the first(s) element
                relevant = []
                for i in versions:
                    # ugly temp hack
                    if category == 'Desperate':
                        relevant.append(i[0])

                    elif i[1] == versions[0][1]:

                        # do not append blank output strings
                        if len(relevant) > 0 and i[0] == "":
                            continue

                        relevant.append(i[0])
                    else:
                        break

                plug_str = "%s: " % (plugin, )
                ver_str = ", ".join(relevant)

                plugin_list.append(plug_str + ver_str)

            out += "\n".join(plugin_list) + "\n\n"

        return out[:-1]
Example #14
0
class State:

    # Initializes the starting values.
    def __init__(self):
        self.name = 'player'
        self.depth = 0
        self.doors = random.randint(MIN_DOORS, MAX_DOORS)
        self.color = Color().become_random_color()
        self.sitting = False
        self.locale = Localization()
    
    def print_depth(self):
        if self.depth == 1:
            print self.locale.get_string('depth-one',[])
        else:
            print self.locale.get_string('depth-general',[self.depth])
        
    def print_desc(self):
        if self.sitting:
            print self.locale.get_string('desc-sitting',[])
        else:
            print self.locale.get_string('desc-room',[self.doors])
    
    def print_state(self):
        self.print_depth()
        self.print_desc()
    
    def next_state(self):
        self.doors = random.randint(MIN_DOORS, MAX_DOORS)
        self.depth += 1
        self.sitting = False
        self.color.become_random_color()

    def sit(self):
        self.sitting = True

    def stand(self):
        self.sitting = False

    def check_valid_door(self, args):
        if all([i in '1234567890' for i in args]) and args != '':
            i = int(args)
            if 0 <= i and i < self.doors:
                return True
        else:
            return False

    def create_save(self, save_name):
        # Remove leading '.' and whitespace in any number
        save_name = save_name.lstrip().lstrip('.')
        if not save_name.endswith('.json'):
            save_name += '.json'
        save_file = io.open('saves/' + save_name, 'wb')
        
        save_dict = {'name': self.name, 'depth': self.depth, 'doors': self.doors, 'color': self.color.get_rgb(), 'sitting': self.sitting, 'locale-name': self.locale.locale_name}
        try:
            json.dump(save_dict, save_file, separators=(',',':'))
            save_file.close()
        except (IOError) as err:
            return self.locale.get_string('save-failure',[save_name])
        return self.locale.get_string('save-success',[save_name])

    def load_save(self, save_name):
        save_name =  save_name.lstrip().lstrip('.')
        if  os.path.isfile('saves/' + save_name):
            save_file = io.open('saves/' + save_name, 'r')
            save_dict = json.load(save_file)
            
            name = depth = doors = color = sitting = locale_name = None
            
            try:
                name = save_dict['name']
                depth = save_dict['depth']
                doors = save_dict['doors']
                color = save_dict['color']
                sitting = save_dict['sitting']
                locale_name = save_dict['locale-name']
                
            except (KeyError):
                return self.locale.get_string('load-bad-save',[save_name])
            
            self.name = name
            self.depth = depth
            self.doors = doors
            self.color.set_rgb(color)
            self.sitting = sitting
            self.locale.set_locale(locale_name)
            
            return self.locale.get_string('load-success',[save_name])
            
        else:
            return self.locale.get_string('load-failure',[save_name])

    def get_available_saves(self):
        output = ''
        valid_paths = glob.iglob('saves/*.json')
        for path in valid_paths:
            split = path.partition('/')
            output += split[2] + '\n'
        return output[:-1]

    def remove_save(self, save_name):
        # Remove leading '.' and whitespace for some safety of other files
        save_name = save_name.lstrip().lstrip('.')
        save_path = 'saves/' + save_name
        if os.path.isfile(save_path) and save_name.endswith('.json'):
            os.remove(save_path)
            return self.locale.get_string('remove-save-success',[save_name])
        else:
            return self.locale.get_string('remove-save-failure',[save_name])