示例#1
0
    def _add_command_args(self, commands):
        commands.add_argument(
            '--cracked',
            action='store_true',
            dest='cracked',
            help=Color.s('Display previously-cracked access points'))
        commands.add_argument('-cracked',
                              help=argparse.SUPPRESS,
                              action='store_true',
                              dest='cracked')

        commands.add_argument(
            '--check',
            action='store',
            metavar='file',
            nargs='?',
            const='<all>',
            dest='check_handshake',
            help=Color.
            s('Check a .cap file (or all hs/*.cap files) for WPA handshakes'))
        commands.add_argument('-check',
                              help=argparse.SUPPRESS,
                              action='store',
                              nargs='?',
                              const='<all>',
                              dest='check_handshake')

        commands.add_argument(
            '--crack',
            action='store_true',
            dest='crack_handshake',
            help=Color.s('Show commands to crack a captured handshake'))
示例#2
0
    def dependency_check(self):
        ''' Check that required programs are installed '''
        required_apps = [
            'airmon-ng', 'iwconfig', 'ifconfig', 'aircrack-ng', 'aireplay-ng',
            'airodump-ng', 'tshark'
        ]
        optional_apps = [
            'packetforge-ng', 'reaver', 'bully', 'cowpatty', 'pyrit', 'stdbuf',
            'macchanger'
        ]
        missing_required = False
        missing_optional = False

        for app in required_apps:
            if not Process.exists(app):
                missing_required = True
                Color.pl('{!} {R}error: required app {O}%s{R} was not found' %
                         app)

        for app in optional_apps:
            if not Process.exists(app):
                missing_optional = True
                Color.pl(
                    '{!} {O}warning: recommended app {R}%s{O} was not found' %
                    app)

        if missing_required:
            Color.pl('{!} {R}required app(s) were not found, exiting.{W}')
            sys.exit(-1)

        if missing_optional:
            Color.pl('{!} {O}recommended app(s) were not found')
            Color.pl('{!} {O}wifite may not work as expected{W}')
示例#3
0
    def set_led(self, x, y, z, color):

        ix, iy, iz = rounds(x, y, z)
        if not is_in_cube(ix, iy, iz):
            return

        src_color = Color.object_to_color(color)

        if src_color.a == 0.0:
            return

        new_color = None
        if src_color.a != 1.0:

            dest_color = self.led_cube[ix][iy][iz]
            
            # alpha blend
            newr = dest_color.r * (1.0 - src_color.a) + src_color.r * src_color.a
            newg = dest_color.g * (1.0 - src_color.a) + src_color.g * src_color.a
            newb = dest_color.b * (1.0 - src_color.a) + src_color.b * src_color.a

            new_color = Color(newr, newg, newb)
        else:
            new_color = src_color

        if new_color.is_black():
            return
        self.led_cube[ix][iy][iz] = new_color
        led.SetLed(ix, iy, iz, int(new_color))
示例#4
0
    def __init__(self, device, name="no-name"):
        """

        :param name:
        :param device:
        :type device: sphero.SpheroAPI
        """
        super(TraceableSphero, self).__init__(name)

        # FILTER USED FOR TRACKING
        self.filter = FilterGlow()

        # THE OBJECT FOR THE DEVICE
        self.device = device

        device.configure_locator(0, 0, 0, auto=False)
        self.device.set_sensor_streaming_cb(self.on_sphero_data)

        # DRAW TRACKED PATCH ATTRIBUTES
        self.draw_tracked = False
        self.draw_n_max_tracked_samples = 5

        # VELOCITY ATTRIBUTES
        self.draw_velocity = False
        self.velocity_vector = Vector2D(0, 0)
        self.velocity_color = Color((0, 255, 0))
        self.max_velocity_len = 20

        # IMU ATTRIBUTES
        self.draw_imu = True
        self.imu_vector = Vector2D(1.0, 1.0)
        self.imu_yaw = None
        self.imu_vector_len = 15
        self.imu_color = Color((0, 0, 255))
示例#5
0
    def load_from_file(file_path, scene_speed, statistics_panel_width):
        with open(file_path) as f:
            line_number = 1

            for line in f:
                words = line.split()

                # skip empty lines
                if len(words) == 0:
                    line_number += 1
                    continue

                # skip comments in file
                if words[0][0] == '#':
                    line_number += 1
                    continue

                if words[0] == 'Scene':
                    width = int(words[1])
                    height = int(words[2])
                    scene = Scene(width, height, scene_speed,
                                  statistics_panel_width)
                # elif words[0] == 'SensorDrivenRobot':
                #     x = float(words[1])
                #     y = float(words[2])
                #     robot = SensorDrivenRobot(x, y, ROBOT_SIZE, ROBOT_WHEEL_RADIUS)
                #     robot.label = line_number
                #     scene.put(robot)
                elif words[0] == 'Box':
                    x = int(words[1])
                    y = int(words[2])
                    size = int(words[3])
                    box = Box(x, y, size, Color.random_bright())
                    box.label = line_number
                    scene.put(box)
                elif words[0] == 'Wall':
                    x1 = int(words[1])
                    y1 = int(words[2])
                    x2 = int(words[3])
                    y2 = int(words[4])

                    point1 = Point(x1, y1)
                    point2 = Point(x2, y2)
                    wall = Wall(point1, point2, Color.random_bright())
                    wall.label = line_number
                    scene.put(wall)
                elif words[0] == 'Light':
                    x = int(words[1])
                    y = int(words[2])
                    emitting_power = int(words[3])
                    light = Light(x, y, emitting_power, Color.YELLOW,
                                  Color.BLACK)
                    light.label = line_number
                    scene.put(light)

                line_number += 1

        f.closed
        return scene
示例#6
0
    def print_banner(self):
        """ Displays ASCII art of the highest caliber.  """
        Color.pl('''\
{G}  .     {GR}{D}     {W}{G}     .    {W}
{G}.´  ·  .{GR}{D}     {W}{G}.  ·  `.  {G}wifite {D}%s{W}
{G}:  :  : {GR}{D} (¯) {W}{G} :  :  :  {W}{D}automated wireless auditor
{G}`.  ·  `{GR}{D} /¯\ {W}{G}´  ·  .´  {C}{D}https://github.com/derv82/wifite2
{G}  `     {GR}{D}/¯¯¯\{W}{G}     ´    {W}
''' % Configuration.version)
示例#7
0
 def check_handshake(self, capfile):
     ''' Analyzes .cap file for handshake '''
     if capfile == '<all>':
         Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
         try:
             capfiles = [
                 os.path.join('hs', x) for x in os.listdir('hs')
                 if x.endswith('.cap')
             ]
         except OSError, e:
             capfiles = []
         if len(capfiles) == 0:
             Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
    def _draw_neighbors(self, agent_positions, agent_neighbors_indicies):
        for i in range(len(agent_positions)):
            agent_x = agent_positions[i][0]
            agent_y = agent_positions[i][1]

            color = Color(47, 72, 88)

            if i in agent_neighbors_indicies:
                color = Color(0, 255, 0)
            elif i == 0:
                color = Color(0, 0, 0)

            draw.filled_circle(agent_x, agent_y, self._rad, color)
示例#9
0
    def __init__(self, pos: Vect2d, name: str, color: Color, creature_id: int) -> None:
        """Constructeur

        Args:
            pos (Vect2d): position de la créature
            name (str): nom de la créature
            color (Color): couleur de la créature
            creature_id (int): id de la famille de la créature
        """

        self.family = [self]
        self.invincibility_family_time = time.time()
        self.creature_id = creature_id
        self.killer_id = None

        self.pos = pos.copy()
        self.speed = Vect2d(0, 0)
        self.direction = Vect2d(0, 0)
        self.split_speed = 0
        self.inertia = 0

        self.radius = self.BASE_RADIUS
        self.color = color
        self.opposite_color = Color.oppositeColor(color)
        self.name = name
        self.img = Skins.getRandomSkin()

        self.score = Creature.BASE_SCORE
        self.is_alive = True
    def get_heatmap_color(self, value):
        heatmap = [[47, 72, 88], [0, 109, 137], [0, 148, 163], [0, 187, 157],
                   [0, 223, 117], [0, 255, 0]]

        idx1 = 0
        idx2 = 0
        fract_between = 0

        if value <= 0:
            idx1 = idx2 = 0
        elif value >= 1:
            idx1 = idx2 = len(heatmap) - 1
        else:
            value = value * (len(heatmap) - 1)
            idx1 = floor(value)
            idx2 = idx1 + 1
            fract_between = value - float(idx1)

        r = (heatmap[idx2][0] -
             heatmap[idx1][0]) * fract_between + heatmap[idx1][0]
        g = (heatmap[idx2][1] -
             heatmap[idx1][1]) * fract_between + heatmap[idx1][1]
        b = (heatmap[idx2][2] -
             heatmap[idx1][2]) * fract_between + heatmap[idx1][2]

        return Color(int(r), int(g), int(b))
示例#11
0
    def reset(cls) -> None:
        """Réinitialise la map"""

        cls.start_time = time.time()

        cls.game_finished = False

        cls.player_infos = {}

        cls.all_cells = []

        cls.ref_time = -1 * cls.DELTA_T_NEW_CELL

        cls.grid = [[[] for y in range(cls.grid_size.y)]
                    for x in range(cls.grid_size.x)]

        cls.creatures = {}

        cls.player_id = cls.generateId()
        cls.focused_creature_id = cls.player_id

        player = Player(Vect2d(cls.size.x / 2, cls.size.y / 2), "Player",
                        Color.randomColor(), cls.player_id)

        cls.creatures[cls.player_id] = [player]
        # Création du joueur

        cls.bushes = []

        for i in range(config.NB_BUSHES):
            cls.createBush()
示例#12
0
    def create_boxes(self, number_to_add=1):
        for i in range(number_to_add):
            x = random.randint(0, self.scene.width)
            y = random.randint(0, self.scene.height)

            size = random.randint(self.BOX_SIZE_MIN, self.BOX_SIZE_INTERVAL)
            box = self.build_box(x, y, size, Color.random_bright())
            self.scene.put(box)
示例#13
0
    def dump():
        ''' (Colorful) string representation of the configuration '''
        from util.color import Color

        max_len = 20
        for key in Configuration.__dict__.keys():
            max_len = max(max_len, len(key))

        result = Color.s('{W}%s  Value{W}\n' %
                         'Configuration Key'.ljust(max_len))
        result += Color.s('{W}%s------------------{W}\n' % ('-' * max_len))

        for (key, val) in sorted(Configuration.__dict__.iteritems()):
            if key.startswith('__') or type(
                    val) == staticmethod or val is None:
                continue
            result += Color.s("{G}%s {W} {C}%s{W}\n" %
                              (key.ljust(max_len), val))
        return result
示例#14
0
	def draw(self, surface):
		self.grid.draw(surface)
		self.pieces.draw(surface)
		
		for piece in self.pieces:
			if piece.isSelected():
				for cell in piece.getValidMoves():
					cell.highlight(surface, Color.rainbow(), 2)
					
				self.getCellFromPos(piece.pos).highlight(surface, (0,255,0), 2)
示例#15
0
 def __init__(self, x, y, length, wheel_radius):
     direction = random.uniform(-pi, pi)
     super().__init__(x, y, length, Color.random_color(127, 127, 127),
                      Color.BLACK, direction)
     self.length = length
     self.wheel_radius = wheel_radius
     self.speed_left_wheel = 0.0  # angular velocity of left wheel
     self.speed_right_wheel = 0.0  # angular velocity of left wheel
     self._delta = 0.01
     self.deltax = None
     self.deltay = None
示例#16
0
    def draw(self, surface):
        self.grid.draw(surface)
        self.pieces.draw(surface)

        for piece in self.pieces:
            if piece.isSelected():
                for cell in piece.getValidMoves():
                    cell.highlight(surface, Color.rainbow(), 2)

                self.getCellFromPos(piece.pos).highlight(
                    surface, (0, 255, 0), 2)
示例#17
0
def run():
    w = Wifite()
    w.print_banner()

    try:
        w.main()

    except Exception, e:
        Color.pl('\n{!} {R}Error:{O} %s{W}' % str(e))

        if Configuration.verbose > 0 or True:
            Color.pl('\n{!} {O}Full stack trace below')
            from traceback import format_exc
            Color.p('\n{!}    ')
            err = format_exc().strip()
            err = err.replace('\n', '\n{!} {C}   ')
            err = err.replace('  File', '{W}File')
            err = err.replace('  Exception: ', '{R}Exception: {O}')
            Color.pl(err)

        Color.pl('\n{!} {R}Exiting{W}\n')
示例#18
0
    def __init__(self, w, h, title):  #{

        colorama.init()

        os.system("mode {cols},{rows}".format(cols=w, rows=h))
        os.system("title " + title)
        #sys.stdout.write("\x1b]2;{name}\x07".format(name=title))
        #sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=h, cols=w))
        sys.stdout.write("\033[{col}m{char}\033[0m".format(col=Color.RGB(
            252, 127, 0).getShort(),
                                                           char='YELLOW'))
        sys.stdout.write("\033[31;1;5mCOLOR\033[0m")
        sys.stdout.write("\033[44m\033[36mWORDS\033[0m\n")
示例#19
0
    def add_walls(self, number_to_add=1):
        for i in range(number_to_add):
            x1 = random.randint(0, self.scene.width)
            y1 = random.randint(0, self.scene.height)
            point1 = Point(x1, y1)

            x2 = random.randint(0, self.scene.width)
            y2 = random.randint(0, self.scene.height)
            point2 = Point(x2, y2)

            wall = self.build_wall(point1, point2,
                                   Color.random_color(127, 127, 127))
            self.scene.put(wall)
示例#20
0
    def main(self):
        ''' Either performs action based on arguments, or starts attack scanning '''

        if os.getuid() != 0:
            Color.pl('{!} {R}error: {O}wifite{R} must be run as {O}root{W}')
            Color.pl('{!} {O}re-run as: sudo ./Wifite.py{W}')
            Configuration.exit_gracefully(0)

        self.dependency_check()

        Configuration.initialize(load_interface=False)

        if Configuration.show_cracked:
            self.display_cracked()

        elif Configuration.check_handshake:
            self.check_handshake(Configuration.check_handshake)
        elif Configuration.crack_handshake:
            CrackHandshake()
        else:
            Configuration.get_interface()
            self.run()
示例#21
0
    def user_wants_to_continue(self, targets_remaining, attacks_remaining=0):
        ''' Asks user if attacks should continue onto other targets '''
        if attacks_remaining == 0 and targets_remaining == 0:
            # No targets or attacksleft, drop out
            return

        prompt_list = []
        if attacks_remaining > 0:
            prompt_list.append(
                Color.s('{C}%d{W} attack(s)' % attacks_remaining))
        if targets_remaining > 0:
            prompt_list.append(
                Color.s('{C}%d{W} target(s)' % targets_remaining))
        prompt = ' and '.join(prompt_list)
        Color.pl('{+} %s remain, do you want to continue?' % prompt)

        prompt = Color.s('{+} type {G}c{W} to {G}continue{W}' +
                         ' or {R}s{W} to {R}stop{W}: ')

        if raw_input(prompt).lower().startswith('s'):
            return False
        else:
            return True
示例#22
0
    def __init__(self, pos: Vect2d) -> None:
        """
        Constructeur

        Args:
            pos (Vect2d): position de la cellule
        """

        self.color = Color.randomColor()
        # On prend une couleur aléatoire

        self.pos = pos

        self.radius = self.BASE_RADIUS
        self.score = 1
示例#23
0
    def __init__(self, settings, max_width, max_height, max_nth_initial_radius=3):
        pos_coordinate = RandomCoordinate(max_width, max_height)
        vector = RandomVector(settings)
        color = Color.random_color() if settings.random_color else Color.PURPLE

        width = randint(1, settings.max_bubble_line_width)
        max_radius = randint(1, settings.max_bubble_radius)
        max_generated_radius = max_radius // max_nth_initial_radius
        if max_generated_radius < 1:
            max_generated_radius = 1

        if settings.max_bubble_line_width < max_generated_radius:
            radius = randint(settings.max_bubble_line_width, max_generated_radius)
        else:
            radius = settings.max_bubble_line_width

        super().__init__(pos_coordinate, vector, color, radius, width, max_radius)
示例#24
0
    def display_cracked(self):
        ''' Show cracked targets from cracked.txt '''
        name = CrackResult.cracked_file
        if not os.path.exists(name):
            Color.pl('{!} {O}file {C}%s{O} not found{W}' % name)
            return

        with open(name, 'r') as fid:
            cracked_targets = json.loads(fid.read())

        if len(cracked_targets) == 0:
            Color.pl('{!} {R}no results found in {O}%s{W}' % name)
        else:
            Color.pl('{+} displaying {G}%d {C}cracked target(s){W}\n' %
                     len(cracked_targets))
            for item in cracked_targets:
                cr = CrackResult.load(item)
                cr.dump()
                Color.pl('')
示例#25
0
    def createEnemy(cls) -> None:
        """Crée un nouvel ennemi en évitant le spawn-kill, apparition sur une
        autre créature"""

        ok = False
        timed_out = False
        compt = 0

        while not ok and not timed_out:
            ok = True

            pos = Vect2d(
                random.randrange(Creature.BASE_RADIUS * 2,
                                 cls.size.x - Creature.BASE_RADIUS * 2),
                random.randrange(Creature.BASE_RADIUS * 2,
                                 cls.size.y - Creature.BASE_RADIUS * 2))

            for k in cls.creatures.keys():
                creatures_list = cls.creatures[k]

                for creature in creatures_list:
                    if Vect2d.dist(pos, creature.pos) < (Creature.BASE_RADIUS +
                                                         creature.radius) * 2:
                        ok = False

            if compt == 10:
                timed_out = True

            compt += 1

        if not timed_out:
            enemy_id = cls.generateId()

            if cls.all_usernames is None:
                size = random.randint(3, 5)
                name = cls.generateNewName(size)
            else:
                name = cls.all_usernames[random.randrange(
                    len(cls.all_usernames))]

            enemy = Enemy(pos, name, Color.randomColor(), enemy_id)

            cls.creatures[enemy_id] = [enemy]
示例#26
0
def buttonStart_Display(button: Button, mouse_pos: Vect2d) -> bool:
    """Affichage du bouton Start

    Args:
        button (Button): bouton start
        mouse_pos (Vect2d): position de la souris
    
    Returns:
        hand_cursor (bool): si la souris doit être affichée comme une main ou un curseur
    """

    if button.isMouseOver(mouse_pos):
        # Arc-en-ciel
        hand_cursor = True
        button.color_sat = (button.color_sat - 3 + 100) % 100
    else:
        # Flash épileptique
        hand_cursor = False
        button.color_sat = 100
        button.color_hue = (button.color_hue + 1) % 360

    button_color = Color.HSVToRGB(button.color_hue, button.color_sat, 100)

    min_size = max(button.size.x, button.size.y)
    # Taille minimale entre la largeur et la hauteur

    font_size = min_size * 50 / 400

    Display.drawRect(button.pos, button.size, color=button_color, fill=True)
    # Rectangle du bouton

    Display.drawText(button.text,
                     button.pos + button.size / 2,
                     color=Color.BLACK,
                     size=font_size)
    # Texte du bouton

    return hand_cursor
示例#27
0
    def display(self) -> None:
        """Affichage du buisson"""

        c = Color.linearGradient(Color.BUSH_COLOR_FULL,
                                 Color.BUSH_COLOR_DEAD,
                                 1-(self.health-1)/(Bush.BASE_HEALTH-1))

        for i in range(self.health):
            # Les pics du buisson
            angle = i/self.health*2*math.pi + self.angle

            offset = Vect2d(math.cos(angle), math.sin(angle))*Bush.RADIUS*(1+Bush.SHARPNESS/3)

            Display.drawTriangle(pos=self.pos + offset,
                                 color=c,
                                 radius=Bush.RADIUS*Bush.SHARPNESS,
                                 angle=2*math.pi/self.health*i + self.angle,
                                 base_pos=Camera.pos)

        # Le cercle du buisson
        Display.drawCircle(pos=self.pos,
                           color=c,
                           radius=Bush.RADIUS,
                           base_pos=Camera.pos)
    def draw_agents(self, agent_positions, agent_goal_velocities,
                    agent_velocities):
        for i in range(len(agent_positions)):
            # print(agent_positions[i])
            agent_x = agent_positions[i][0]
            agent_y = agent_positions[i][1]

            v_i = agent_velocities[i]
            norm_v_i = np.linalg.norm(v_i)

            goal_v_i = agent_goal_velocities[i]
            norm_goal_v_i = np.linalg.norm(goal_v_i)

            normalized_v = norm_v_i / 2
            draw.filled_circle(agent_x, agent_y, self._rad,
                               self.get_heatmap_color(normalized_v))

            draw.line(agent_positions[i],
                      agent_positions[i] + 1.5 * self._rad * v_i / norm_v_i,
                      self.get_heatmap_color(normalized_v))
            draw.line(
                agent_positions[i],
                agent_positions[i] + self._rad * goal_v_i / norm_goal_v_i,
                Color(255, 255, 255))
示例#29
0
    def load_from_arguments():
        ''' Sets configuration values based on Argument.args object '''
        from args import Arguments

        args = Arguments(Configuration).args
        if args.random_mac:
            Configuration.random_mac = True
            Color.pl(
                '{+} {C}option:{W} using {G}random mac address{W} when scanning & attacking'
            )
        if args.channel:
            Configuration.target_channel = args.channel
            Color.pl(
                '{+} {C}option:{W} scanning for targets on channel {G}%s{W}' %
                args.channel)
        if args.interface:
            Configuration.interface = args.interface
            Color.pl('{+} {C}option:{W} using wireless interface {G}%s{W}' %
                     args.interface)
        if args.target_bssid:
            Configuration.target_bssid = args.target_bssid
            Color.pl('{+} {C}option:{W} targeting BSSID {G}%s{W}' %
                     args.target_bssid)
        if args.five_ghz == True:
            Configuration.five_ghz = True
            Color.pl(
                '{+} {C}option:{W} including {G}5Ghz networks{W} in scans')
        if args.show_bssids == True:
            Configuration.show_bssids = True
            Color.pl(
                '{+} {C}option:{W} showing {G}bssids{W} of targets during scan'
            )
        if args.no_deauth == True:
            Configuration.no_deauth = True
            Color.pl(
                '{+} {C}option:{W} will {R}not{W} {O}deauth{W} clients during scans or captures'
            )
        if args.num_deauths and args.num_deauths > 0:
            Configuration.num_deauths = args.num_deauths
            Color.pl(
                '{+} {C}option:{W} will send {G}%d{W} deauth packets when deauthing'
                % Configuration.num_deauths)
        if args.target_essid:
            Configuration.target_essid = args.target_essid
            Color.pl('{+} {C}option:{W} targeting ESSID {G}%s{W}' %
                     args.target_essid)
        if args.ignore_essid is not None:
            Configuration.ignore_essid = args.ignore_essid
            Color.pl(
                '{+} {C}option:{W} {O}ignoring ESSIDs that include {R}%s{W}' %
                args.ignore_essid)
        if args.scan_time:
            Configuration.scan_time = args.scan_time
            Color.pl(
                '{+} {C}option:{W} ({G}pillage{W}) attack all targets after {G}%d{W}s'
                % args.scan_time)
        if args.verbose:
            Configuration.verbose = args.verbose
            Color.pl('{+} {C}option:{W} verbosity level {G}%d{W}' %
                     args.verbose)
        if args.kill_conflicting_processes:
            Configuration.kill_conflicting_processes = True
            Color.pl(
                '{+} {C}option:{W} kill conflicting processes {G}enabled{W}')

        # WEP
        if args.wep_filter:
            Configuration.wep_filter = args.wep_filter
        if args.wep_pps:
            Configuration.wep_pps = args.wep_pps
            Color.pl(
                '{+} {C}option:{W} using {G}%d{W} packets-per-second on WEP attacks'
                % args.wep_pps)
        if args.wep_timeout:
            Configuration.wep_timeout = args.wep_timeout
            Color.pl(
                '{+} {C}option:{W} WEP attack timeout set to {G}%d seconds{W}'
                % args.wep_timeout)
        if args.require_fakeauth:
            Configuration.require_fakeauth = True
            Color.pl(
                '{+} {C}option:{W} fake-authentication is {G}required{W} for WEP attacks'
            )
        if args.wep_crack_at_ivs:
            Configuration.wep_crack_at_ivs = args.wep_crack_at_ivs
            Color.pl(
                '{+} {C}option:{W} will start cracking WEP keys at {G}%d IVs{W}'
                % args.wep_crack_at_ivs)
        if args.wep_restart_stale_ivs:
            Configuration.wep_restart_stale_ivs = args.wep_restart_stale_ivs
            Color.pl(
                '{+} {C}option:{W} will restart aireplay after {G}%d seconds{W} of no new IVs'
                % args.wep_restart_stale_ivs)
        if args.wep_restart_aircrack:
            Configuration.wep_restart_aircrack = args.wep_restart_aircrack
            Color.pl(
                '{+} {C}option:{W} will restart aircrack every {G}%d seconds{W}'
                % args.wep_restart_aircrack)

        # WPA
        if args.wpa_filter:
            Configuration.wpa_filter = args.wpa_filter
        if args.wordlist:
            if os.path.exists(args.wordlist):
                Configuration.wordlist = args.wordlist
                Color.pl(
                    '{+} {C}option:{W} using wordlist {G}%s{W} to crack WPA handshakes'
                    % args.wordlist)
            else:
                Configuration.wordlist = None
                Color.pl(
                    '{+} {C}option:{O} wordlist {R}%s{O} was not found, wifite will NOT attempt to crack handshakes'
                    % args.wordlist)
        if args.wpa_deauth_timeout:
            Configuration.wpa_deauth_timeout = args.wpa_deauth_timeout
            Color.pl(
                '{+} {C}option:{W} will deauth WPA clients every {G}%d seconds{W}'
                % args.wpa_deauth_timeout)
        if args.wpa_attack_timeout:
            Configuration.wpa_attack_timeout = args.wpa_attack_timeout
            Color.pl(
                '{+} {C}option:{W} will stop WPA handshake capture after {G}%d seconds{W}'
                % args.wpa_attack_timeout)
        if args.ignore_old_handshakes:
            Configuration.ignore_old_handshakes = True
            Color.pl(
                "{+} {C}option:{W} will {O}ignore{W} existing handshakes (force capture)"
            )
        if args.wpa_handshake_dir:
            Configuration.wpa_handshake_dir = args.wpa_handshake_dir
            Color.pl('{+} {C}option:{W} will store handshakes to {G}%s{W}' %
                     args.wpa_handshake_dir)
        if args.wpa_strip_handshake:
            Configuration.wpa_strip_handshake = True
            Color.pl(
                "{+} {C}option:{W} will {G}strip{W} non-handshake packets")

        # WPS
        if args.wps_filter:
            Configuration.wps_filter = args.wps_filter
        if args.wps_only:
            Configuration.wps_only = True
            Color.pl(
                '{+} {C}option:{W} will *only* attack non-WEP networks with {G}WPS attacks{W} (no handshake capture)'
            )
        if args.no_wps:
            Configuration.no_wps = args.no_wps
            Color.pl(
                '{+} {C}option:{W} will {O}never{W} use {C}WPS attacks{W} (Pixie-Dust/PIN) on targets'
            )
        if args.use_bully:
            Configuration.use_bully = args.use_bully
            Color.pl(
                '{+} {C}option:{W} use {C}bully{W} instead of {C}reaver{W} for WPS Attacks'
            )
        if args.wps_pixie_timeout:
            Configuration.wps_pixie_timeout = args.wps_pixie_timeout
            Color.pl(
                '{+} {C}option:{W} WPS pixie-dust attack will timeout after {G}%d seconds{W}'
                % args.wps_pixie_timeout)
        if args.wps_pixie_step_timeout:
            Configuration.wps_pixie_step_timeout = args.wps_pixie_step_timeout
            Color.pl(
                '{+} {C}option:{W} Any step in the pixie-dust attack will timeout after {G}%d seconds{W}'
                % args.wps_pixie_step_timeout)
        if args.wps_fail_threshold:
            Configuration.wps_fail_threshold = args.wps_fail_threshold
            Color.pl(
                '{+} {C}option:{W} will stop WPS attack after {G}%d failures{W}'
                % args.wps_fail_threshold)
        if args.wps_timeout_threshold:
            Configuration.wps_timeout_threshold = args.wps_timeout_threshold
            Color.pl(
                '{+} {C}option:{W} will stop WPS attack after {G}%d timeouts{W}'
                % args.wps_timeout_threshold)
        if args.wps_skip_rate_limit == False:
            Configuration.wps_skip_rate_limit = False
            Color.pl(
                '{+} {C}option:{W} will {G}continue{W} WPS attacks when rate-limited'
            )

        # Adjust encryption filter
        Configuration.encryption_filter = []
        if Configuration.wep_filter:
            Configuration.encryption_filter.append('WEP')
        if Configuration.wpa_filter:
            Configuration.encryption_filter.append('WPA')
        if Configuration.wps_filter:
            Configuration.encryption_filter.append('WPS')

        if len(Configuration.encryption_filter) == 3:
            Color.pl(
                '{+} {C}option:{W} targeting {G}all encrypted networks{W}')
        elif len(Configuration.encryption_filter) == 0:
            # Default to scan all types
            Configuration.encryption_filter = ['WEP', 'WPA', 'WPS']
        else:
            Color.pl('{+} {C}option:{W} ' +
                     'targeting {G}%s-encrypted{W} networks' %
                     '/'.join(Configuration.encryption_filter))

        # Adjust WEP attack list
        Configuration.wep_attacks = []
        import sys
        seen = set()
        for arg in sys.argv:
            if arg in seen: continue
            seen.add(arg)
            if arg == '-arpreplay': Configuration.wep_attacks.append('replay')
            if arg == '-fragment': Configuration.wep_attacks.append('fragment')
            if arg == '-chopchop': Configuration.wep_attacks.append('chopchop')
            if arg == '-caffelatte':
                Configuration.wep_attacks.append('caffelatte')
            if arg == '-p0841': Configuration.wep_attacks.append('p0841')
            if arg == '-hirte': Configuration.wep_attacks.append('hirte')

        if len(Configuration.wep_attacks) == 0:
            # Use all attacks
            Configuration.wep_attacks = [
                'replay', 'fragment', 'chopchop', 'caffelatte', 'p0841',
                'hirte'
            ]
        elif len(Configuration.wep_attacks) > 0:
            Color.pl('{+} {C}option:{W} using {G}%s{W} WEP attacks' %
                     '{W}, {G}'.join(Configuration.wep_attacks))

        # Commands
        if args.cracked: Configuration.show_cracked = True
        if args.check_handshake:
            Configuration.check_handshake = args.check_handshake
        if args.crack_handshake: Configuration.crack_handshake = True
示例#30
0
        if capfile == '<all>':
            Color.pl('{+} checking all handshakes in {G}"./hs"{W} directory\n')
            try:
                capfiles = [
                    os.path.join('hs', x) for x in os.listdir('hs')
                    if x.endswith('.cap')
                ]
            except OSError, e:
                capfiles = []
            if len(capfiles) == 0:
                Color.pl('{!} {R}no .cap files found in {O}"./hs"{W}\n')
        else:
            capfiles = [capfile]

        for capfile in capfiles:
            Color.pl('{+} checking for handshake in .cap file {C}%s{W}' %
                     capfile)
            if not os.path.exists(capfile):
                Color.pl('{!} {O}.cap file {C}%s{O} not found{W}' % capfile)
                return
            hs = Handshake(capfile,
                           bssid=Configuration.target_bssid,
                           essid=Configuration.target_essid)
            hs.analyze()
            Color.pl('')

    def run(self):
        '''
            Main program.
            1) Scans for targets, asks user to select targets
            2) Attacks each target
        '''
示例#31
0
    def run(self):
        '''
            Main program.
            1) Scans for targets, asks user to select targets
            2) Attacks each target
        '''
        s = Scanner()
        if s.target:
            # We found the target we want
            targets = [s.target]
        else:
            targets = s.select_targets()

        attacked_targets = 0
        targets_remaining = len(targets)
        for idx, t in enumerate(targets, start=1):
            attacked_targets += 1
            targets_remaining -= 1

            Color.pl(
                '\n{+} ({G}%d{W}/{G}%d{W})' % (idx, len(targets)) +
                ' starting attacks against {C}%s{W} ({C}%s{W})' %
                (t.bssid, t.essid if t.essid_known else "{O}ESSID unknown"))
            if 'WEP' in t.encryption:
                attack = AttackWEP(t)
            elif 'WPA' in t.encryption:
                if t.wps:
                    attack = AttackWPS(t)
                    result = False
                    try:
                        result = attack.run()
                    except Exception as e:
                        Color.pl("\n{!} {R}Error: {O}%s" % str(e))
                        if Configuration.verbose > 0 or Configuration.print_stack_traces:
                            Color.pl('\n{!} {O}Full stack trace below')
                            from traceback import format_exc
                            Color.p('\n{!}    ')
                            err = format_exc().strip()
                            err = err.replace('\n', '\n{!} {C}   ')
                            err = err.replace('  File', '{W}File')
                            err = err.replace('  Exception: ',
                                              '{R}Exception: {O}')
                            Color.pl(err)
                    except KeyboardInterrupt:
                        Color.pl('\n{!} {O}interrupted{W}\n')
                        if not self.user_wants_to_continue(
                                targets_remaining, 1):
                            break

                    if result and attack.success:
                        # We cracked it.
                        attack.crack_result.save()
                        continue
                    else:
                        # WPS failed, try WPA handshake.
                        attack = AttackWPA(t)
                else:
                    # Not using WPS, try WPA handshake.
                    attack = AttackWPA(t)
            else:
                Color.pl(
                    "{!} {R}Error: {O}unable to attack: encryption not WEP or WPA"
                )
                continue

            try:
                attack.run()
            except Exception, e:
                Color.pl("\n{!} {R}Error: {O}%s" % str(e))
                if Configuration.verbose > 0 or True:
                    Color.pl('\n{!} {O}Full stack trace below')
                    from traceback import format_exc
                    Color.p('\n{!}    ')
                    err = format_exc().strip()
                    err = err.replace('\n', '\n{!} {C}   ')
                    err = err.replace('  File', '{W}File')
                    err = err.replace('  Exception: ', '{R}Exception: {O}')
                    Color.pl(err)
            except KeyboardInterrupt:
                Color.pl('\n{!} {O}interrupted{W}\n')
                if not self.user_wants_to_continue(targets_remaining):
                    break