Skip to content

Commit 47e5d47

Browse files
author
wraith-wireless
committed
0.0.8
1 parent f70f9ea commit 47e5d47

33 files changed

+153
-120
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ software in furtherance of or with intent to commit any fraudulent or other ille
3737
activities, or otherwise in violation of any applicable law, regulation or legal
3838
agreement.
3939

40-
See <http://www.gnu.org/licenses/> for a copy of the GNU General Public License.
40+
See <http://www.gnu.org/licenses/> for a copy of the GNU General Public License.

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Include license, README
1+
# Include license, README, channels, device, pyw and user guide
22
include LICENSE README.md __init__.py channels.py device.py pyw.py PyRIC.pdf
33

44
# Include subdirectories
55
recursive-include lib net examples docs
6-
recursive-include docs *.help *.pdf
6+
recursive-include docs *.help

PyRIC.pdf

1.07 KB
Binary file not shown.

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
## Pythonic iw
33

44
## 1 DESCRIPTION:
5-
BLUF: Stop using subprocess.Popen, regular expressions and str.find. PyRIC
6-
is a python port of a subset of iw and python port of netlink (w.r.t nl80211
7-
functions).
5+
BLUF: Why use subprocess.Popen, regular expressions and str.find to interact
6+
with your Wireless Network Interface Card. PyRIC provides the ability to
7+
manipuate, identify and enumerate your system's cards. It is a pure python port
8+
of a subset the functionality provided by iw, ifconfig and iwconfig. PyRIC is:
9+
* Pythonic: No ctypes, SWIG etc. PyRIC redefines C header files as Python and
10+
uses sockets to communicate with kernel.
11+
* Self-sufficient: No third-party files used, PyRIC is completely self-contained
12+
* Fast: (relatively speaking) PyRIC is faster than using iw through subprocess.Popen
13+
* Parse(less): Get the output you without parsing output from iw. Never worry about
14+
iw updates and rewriting your parsers.
15+
* Easy: If you can use iw, you can use PyRIC
816

917
### a. Background
1018
PyRIC arose out of a need in Wraith (https://github.com/wraith-wireless/wraith)
@@ -76,7 +84,7 @@ the following:
7684
* get supported commands
7785
* get supported modes
7886
* get dev info
79-
* get phy info (does not currently process the bands)
87+
* get phy info
8088
* get/set regulatory domain
8189
* get/set mode
8290
* add/delete interfaces
File renamed without changes.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
1) overall
22
o look at iw dev wlan0 link
3-
o look at iw dev
3+
o make a cli as well
44
2) libnl.py
55
o see (1) in RFI
6-
o define attr_ops and attr_mcast_groups in nla_policy_attr
76
4) pyw
87
o add txget from iw i.e. netlink perspective
98
o find a better way to find the supported standards of a card
109
o for now, using ioctl to set ip addresses
1110
- move everything to netlink
1211
o Can we find the current channel of a radio in monitor mode that is actively
1312
scanning?
14-
o parse NL80211_ATTR_WIPHY_BANDS
13+
o parse NL80211_ATTR_WIPHY_BANDS (have workaround currently in place)

__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# root Distribution directory
1+
# root Distribution directory

examples/device.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python
2+
""" device.py
3+
4+
Example for displaying device details
5+
"""
6+
7+
import argparse as ap
8+
import pyric # pyric error (and ecode EUNDEF)
9+
from pyric import pyw # for iw functionality
10+
from pyric import device # for chipset/driver
11+
from pyric.channels import rf2ch # rf to channel conversion
12+
13+
def execute(dev):
14+
# ensure dev is a wireless interfaces
15+
wifaces = pyw.winterfaces()
16+
if dev not in wifaces:
17+
print "Device {0} is not wireless, use one of {1}".format(dev,wifaces)
18+
19+
dinfo = pyw.devinfo(dev)
20+
card = dinfo['card']
21+
pinfo = pyw.phyinfo(card)
22+
driver = device.ifdriver(card.dev)
23+
chipset = device.ifchipset(driver)
24+
25+
msg = "Device {0}\n".format(dev)
26+
msg += "\tDriver: {0} Chipset: {1}\n".format(driver,chipset)
27+
msg += "\tifindex: {0}\n".format(card.idx)
28+
msg += "\twdev: {0}\n".format(dinfo['wdev'])
29+
msg += "\taddr: {0}\n".format(dinfo['mac'])
30+
msg += "\tmode: {0}\n".format(dinfo['mode'])
31+
msg += "\twiphy: {0}\n".format(card.phy)
32+
if dinfo['mode'] == 'managed':
33+
msg += "\tchannel: {0} (1 MHz), width: {2}, CF: {3}\n".format(rf2ch(dinfo['RF']),
34+
dinfo['RF'],
35+
dinfo['CHW'],
36+
dinfo['CF'])
37+
else:
38+
msg += "\tDevice not associated\n"
39+
print msg
40+
41+
msg = "Wiphy phy{0}\n".format(card.phy)
42+
msg += "\tGeneration: {0}m Coverage Class: {1}\n".format(pinfo['generation'],
43+
pinfo['cov_class'])
44+
msg += "\tMax # scan SSIDs: {0}\n".format(pinfo['scan_ssids'])
45+
msg += "\tRetry Short: {0}, Long: {1}\n".format(pinfo['retry_short'],
46+
pinfo['retry_long'])
47+
msg += "\tThreshold Frag: {0}, RTS: {1}\n".format(pinfo['frag_thresh'],
48+
pinfo['rts_thresh'])
49+
msg += "\tSupported Modes:\n"
50+
for mode in pinfo['modes']:
51+
msg += "\t * {0}\n".format(mode)
52+
msg += "\tSupported Commands:\n"
53+
for cmd in pinfo['commands']:
54+
msg += "\t * {0}\n".format(cmd)
55+
msg += "\tSupported Frequencies:\n"
56+
for freq in pinfo['freqs']:
57+
msg += "\t * {0}\n".format(freq)
58+
59+
print msg
60+
61+
if __name__ == '__main__':
62+
# create arg parser and parse command line args
63+
print "Wireless Device Info Display using PyRIC v{0}".format(pyric.__version__)
64+
argp = ap.ArgumentParser(description="Wireless Device Data")
65+
argp.add_argument('-d','--dev',help="Wireless Device")
66+
args = argp.parse_args()
67+
try:
68+
dev = args.dev
69+
if dev is None:
70+
print "usage: python device.py -d <dev>"
71+
else:
72+
execute(dev)
73+
except pyric.error as e:
74+
print e

examples/pentest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ def execute(dev):
9090
try:
9191
dev = args.dev
9292
if dev is None:
93-
print "usage: python pentest -d <dev> -v <vdev>"
93+
print "usage: python pentest.py -d <dev>"
9494
else:
9595
execute(dev)
9696
except pyric.error as e:
97-
print e
97+
print e

pyric/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@
103103
- added devcmds in pyw
104104
- annotated (in comments) if fcts needed root privileges
105105
- added functions to get/set ip address, netmask and broadcast
106+
- fixed PEP8 errors
107+
- made worked around for pulling supported freqs out NL80211_ATTR_WIPHY_BANDS
106108
"""
107109

108110
__name__ = 'pyric'
109111
__license__ = 'GPLv3'
110-
__version__ = '0.0.7'
112+
__version__ = '0.0.8'
111113
__date__ = 'April 2016'
112114
__author__ = 'Dale Patterson'
113115
__maintainer__ = 'Dale Patterson'

0 commit comments

Comments
 (0)