Skip to content

Commit 5aece7a

Browse files
author
wraith-wireless
committed
0.0.7
1 parent 9d42d6e commit 5aece7a

File tree

8 files changed

+362
-203
lines changed

8 files changed

+362
-203
lines changed

PyRIC.pdf

84.5 KB
Binary file not shown.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ Extending PyRIC is fun and easy too, see the user guide PyRIC.pdf.
315315

316316
## 5. ARCHITECTURE/HEIRARCHY: Brief Overview of the project file structure
317317

318-
* pyric root Distribution directory
318+
* PyRIC root Distribution directory
319319
- \_\_init\_\_.py initialize distrubution PyRIC module
320320
- examples example folder
321321
+ pentest.py create wireless pentest environment example
@@ -324,7 +324,7 @@ Extending PyRIC is fun and easy too, see the user guide PyRIC.pdf.
324324
- MANIFEST.in used by setup.py
325325
- README.md this file
326326
- LICENSE GPLv3 License
327-
* PyRIC.pdf User Guide
327+
- PyRIC.pdf User Guide
328328
- pyric package directory
329329
+ \_\_init\_\_.py initialize pyric module
330330
+ pyw.py wireless nic functionality

pyric/TODO

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@
1111
o see (1) in RFI
1212
o define attr_ops and attr_mcast_groups in nla_policy_attr
1313
4) pyw
14-
o add txget from iw perspective
15-
o figure out why txset doesn't work
16-
o devstds sucks, find a better way to find the supported standards of a card
17-
5) User Guide
18-
o finish it
14+
o add txget from iw i.e. netlink perspective
15+
o devstds sucks, find a better way to find the supported standards of a card

pyric/docs/res/PyRIC.tex

Lines changed: 338 additions & 177 deletions
Large diffs are not rendered by default.

pyric/lib/libnl.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def nla_parse(msg,l,mtype,stream,idx):
474474

475475
# Note: we use unpack_from which will ignore the null bytes in numeric
476476
# datatypes & for strings & unspec we just strip trailing null bytes
477-
if dt == nlh.NLA_STRING or dt == nlh.NLA_UNSPEC: a = _nla_strip(a)
477+
if dt == nlh.NLA_STRING or dt == nlh.NLA_UNSPEC: a = _nla_strip_(a)
478478
if dt == nlh.NLA_NESTED: a = nla_parse_nested(a)
479479
elif dt == nlh.NLA_U8: a = struct.unpack_from("B",a,0)[0]
480480
elif dt == nlh.NLA_U16: a = struct.unpack_from("H",a,0)[0]
@@ -485,7 +485,7 @@ def nla_parse(msg,l,mtype,stream,idx):
485485
nla_put(msg,a,atype,dt)
486486
except struct.error:
487487
# append as Error, stripping null bytes
488-
nla_put(msg,_nla_strip(a),atype,nlh.NLA_ERROR)
488+
nla_put(msg,_nla_strip_(a),atype,nlh.NLA_ERROR)
489489
idx = nlh.NLMSG_ALIGN(idx + alen) # move index to next attr
490490

491491
def nla_parse_nested(nested):
@@ -531,20 +531,6 @@ def nla_parse_nested(nested):
531531
idx = nlh.NLMSG_ALIGN(idx + alen)
532532
return ns
533533

534-
def _nla_strip(v):
535-
"""
536-
strips padding from v
537-
:param v: value to strip
538-
:returns: v w/o padding
539-
**NOTE: Do not use on numeric attributes
540-
"""
541-
try:
542-
for i,e in reversed(list(enumerate(v))):
543-
if e != '\x00': return v[:i+1]
544-
return v
545-
except IndexError:
546-
return v
547-
548534
def nla_put(msg,v,a,d):
549535
"""
550536
append attribute to msg's attribute list
@@ -617,6 +603,21 @@ def nla_get(msg,i,value=True):
617603

618604
#### FILE PRIVATE ####
619605

606+
def _nla_strip_(v):
607+
"""
608+
strips padding from v
609+
:param v: value to strip
610+
:returns: v w/o padding
611+
**NOTE: Do not use on numeric attributes
612+
"""
613+
try:
614+
for i,e in reversed(list(enumerate(v))):
615+
if e != '\x00': return v[:i+1]
616+
return v
617+
except IndexError:
618+
return v
619+
620+
620621
def _attrpack_(a,v,d):
621622
"""
622623
:param a: attribute type

pyric/net/netlink_h.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def nlmsgerr(error,mlen,nltype,flags,seq,pid):
268268
"""
269269

270270
# Attribute Datatypes
271+
NLA_DATATYPES = ['unspec','u8','u16','u32','u64','string','flag','msecs','nested']
271272
NLA_ERROR = -1 # my own -> failed to unpack attribute, treat as unspec
272273
NLA_UNSPEC = 0 # Unspecified type, binary data chunk
273274
NLA_U8 = 1 # 8 bit integer

pyric/pyw.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,7 @@ def modeset(card,mode,flags=None,*argv):
690690
'Can only set flags in monitor mode')
691691
for flag in flags:
692692
if flag not in MNTRFLAGS:
693-
raise pyric.error(errno.EINVAL, 'Invalid flag: {0}',
694-
format(flag))
693+
raise pyric.error(errno.EINVAL, 'Invalid flag: {0}',format(flag))
695694
else: flags = []
696695

697696
try:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
setup(name='PyRIC',
4848
version=pyric.__version__,
49-
description="PyRIC: python port of a subset of iw",
49+
description="Pythonic iw",
5050
long_description=long_desc,
5151
url='http://wraith-wireless.github.io/pyric',
5252
download_url="https://github.com/wraith-wireless/pyric/archive/"+pyric.__version__+".tar.gz",

0 commit comments

Comments
 (0)