pyrcrack package

Submodules

pyrcrack.cracking module

Cracking utilities

This module contains everything related to cracking. Actually, this makes:

  • Aircrack
  • Wesside

That’s so because wesside has its own cracking option.

class pyrcrack.cracking.Aircrack(attack=False, file_=False, **kwargs)[source]

Bases: pyrcrack.Air

Aircrack-ng is a powerful wireless cracking tool. Supporting two main attack types (against wep or wpa) it accepts different options for each.

That means you’ll only be able to use specific options for specific attacks.

The rest of the params are gotten using *args, **kwargs magic, so you’ll need to manually consult them here.

General options (Note that you can combine these with wpa or wep)

Aircrack('wep|wpa', 'file_foo.ivs', a=false, essid=false,
         bssid=false, p=false, E=false, q=false, combine=false,
         l=false, w=false)

WEP options:

Aircrack('wep', 'file_foo.ivs' c=False, t=False, h=False,
          debug=False, m=False, n=False, i=False, f=False,
          k=False, x=False, x1=False, x2=False, X=False,
          y=False, K=False, s=False, M=False, wep_decloack=False,
          ptw_debug=False, oneshot=False)

WPA options:

Aircrack('wpa', 'file_foo.cap', S=False, r=False)

Don’t forget these are context managers, but also can be called manually

foo = Aircrack('wpa', 'file')
foo.start()
time.sleep(1000)
print(foo.result)
foo.stop()
with Aircrack('wpa', 'foo'):
    time.sleep(1000)
    print(_.result)
start()[source]

Start process.

class pyrcrack.cracking.Wesside(interface=False, **kwargs)[source]

Bases: pyrcrack.Air

Wesside-ng is an auto-magic tool to obtain a WEP key with as less interaction from the user as possible.

The only actual required option is the interface, as if no interface specified, it’ll try to crack any.

This is only for WEP networks and does not need anything out of the ordinary

Usage example:

Wesside('mon0', n="192.168.1.3", m="192.168.1.2",
        a="aa:bb:cc:dd:ee:ff", c=False, p=128, v="WLAN_FOO",
        t=10000, f=11)

Don’t forget these are context managers, but also can be called manually

foo = Wesside('mon0', n="192.168.1.3", m="192.168.1.2",
              a="aa:bb:cc:dd:ee:ff", c=False, p=128,
              v="WLAN_FOO", t=10000, f=11)

foo.start()
time.sleep(1000)
print(_.result)
foo.stop()
with Wesside('mon0', n="192.168.1.3", m="192.168.1.2",
              a="aa:bb:cc:dd:ee:ff", c=False, p=128,
              v="WLAN_FOO", t=10000, f=11):
    time.sleep(1000)
    print(_.result)
result

Searches for a key in wesside-ng’s output to stdout.

start()[source]

Start process.

pyrcrack.management module

class pyrcrack.management.Airdecap(attack=False, file_=False, **kwargs)[source]

Bases: pyrcrack.Air

Decrypts a wep / wpa pcap file

Mandatory arguments are attack type (wep|wpa) and pcap file

Attack is actually used only to enforce correct parameters for each attack.

Allowed arguments are:

Common:

Airdecap(‘wep|wpa’, ‘foo.cap’, l=False, b=False, e=False)

Wep:

Airdecap(‘wep’, ‘foo.cap’, w=False)

Wpa:

Airdecap(‘wep’, ‘foo.cap’, p=False, k=False)

As with the rest, this can be used as a context manager

result

Path to the generated decrypted pcap file

start()[source]

Executes airdecap-ng

class pyrcrack.management.Airmon(interface)[source]

Bases: pyrcrack.Air

Airmon-ng manages monitor mode and virtual monitor interfaces As parameter it only accepts the interface, and has three methods (start, stop and check).

As everything else, is a context manager, so you can do:

wifi = Airmon().start('wlan0')
Airmon('smoothie0').stop()
Airmon('wlan0').check()

or:

with Airmon('wlan0') as f:
    print(f.interface)
check()[source]

Executes airmon-ng check <interface>, returns output

interface = None

Wireless interface

start()[source]

Executes

airmon-ng  start <WIFI>

and replaces self.interface with the monitor interface.

stop()[source]

Stops monitor mode on current interface efectively deleting it.

Previously it was necessary to execute iw dev <iface> del but that no longer seems to be the case.

This won’t fail no matter what, so be careful.

pyrcrack.replaying module

Replaying options

class pyrcrack.replaying.Aireplay(attack=False, interface=False, **kwargs)[source]

Bases: pyrcrack.Air

TODO

scan()[source]

Get next result: implement in childrens Both this and previous one must be responsible for duplicates

start(_=False)[source]

Start process. psutil sends an argument (that we don’t actually need...) interface defaults to monitor interface 0 as started by Airmon

watch_process()[source]

Watcher thread. This one relaunches airodump eatch time it dies until we call stop()

pyrcrack.scanning module

Scanning functions

class pyrcrack.scanning.Airodump(interface=False, **kwargs)[source]

Bases: pyrcrack.Air

TODO

This accepts the following parameters from airodump-ng’s help.

  • ivs
  • gpsd
  • beacons
  • manufacturer
  • uptime
  • ignore_negative_one
  • a
  • showack
  • h
  • f
  • update
  • berlin
  • r
  • x
  • encrypt
  • netmask
  • bssid
  • essid
  • output_format
  • write
  • essid_regex
clients

Returns currently reported clients

scan()[source]

Get next result: implement in childrens Both this and previous one must be responsible for duplicates

start(_=False)[source]

Start process. psutil sends an argument (that we don’t actually need...) interface defaults to monitor interface 0 as started by Airmon

stop()[source]

Stop proc.

tree

Returns currently reported aps

update_results()[source]

Updates self.clients and self.aps

watch_process()[source]

Watcher thread. This one relaunches airodump eatch time it dies until we call stop()

Module contents

Aircrack-ng basic attacks This module handles as gracefully as it can be common aircrack-ng commands.

class pyrcrack.Air(**kwargs)[source]

Bases: object

This is the base class for most aircrack-ng classes. Used mainly because its argument handling and writepath.

arguments

Return arguments yields a tuple

curr_csv

Return current execution’s csv location

current_execution

Returns current execution number formatted for usual aircrack output

flags

Returns flags yields a tuple

stop()[source]

Stop proc.

writepath

Where to write things to.

exception pyrcrack.LaunchError[source]

Bases: Exception

Generic process launch error

pyrcrack.PATH = '/home/docs/checkouts/readthedocs.org/user_builds/pyrcrack/envs/0.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

TODO: Make this configurable

exception pyrcrack.WrongArgument[source]

Bases: Exception

Wrong argument has been passed to a call

pyrcrack.format_arg(arg)[source]