Skip to content

Commit

Permalink
0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
wraith-wireless committed May 15, 2016
1 parent 9d42d6e commit 5aece7a
Show file tree
Hide file tree
Showing 8 changed files with 362 additions and 203 deletions.
Binary file modified PyRIC.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Extending PyRIC is fun and easy too, see the user guide PyRIC.pdf.

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

* pyric root Distribution directory
* PyRIC root Distribution directory
- \_\_init\_\_.py initialize distrubution PyRIC module
- examples example folder
+ pentest.py create wireless pentest environment example
Expand All @@ -324,7 +324,7 @@ Extending PyRIC is fun and easy too, see the user guide PyRIC.pdf.
- MANIFEST.in used by setup.py
- README.md this file
- LICENSE GPLv3 License
* PyRIC.pdf User Guide
- PyRIC.pdf User Guide
- pyric package directory
+ \_\_init\_\_.py initialize pyric module
+ pyw.py wireless nic functionality
Expand Down
7 changes: 2 additions & 5 deletions pyric/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@
o see (1) in RFI
o define attr_ops and attr_mcast_groups in nla_policy_attr
4) pyw
o add txget from iw perspective
o figure out why txset doesn't work
o devstds sucks, find a better way to find the supported standards of a card
5) User Guide
o finish it
o add txget from iw i.e. netlink perspective
o devstds sucks, find a better way to find the supported standards of a card
515 changes: 338 additions & 177 deletions pyric/docs/res/PyRIC.tex

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions pyric/lib/libnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def nla_parse(msg,l,mtype,stream,idx):

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

def nla_parse_nested(nested):
Expand Down Expand Up @@ -531,20 +531,6 @@ def nla_parse_nested(nested):
idx = nlh.NLMSG_ALIGN(idx + alen)
return ns

def _nla_strip(v):
"""
strips padding from v
:param v: value to strip
:returns: v w/o padding
**NOTE: Do not use on numeric attributes
"""
try:
for i,e in reversed(list(enumerate(v))):
if e != '\x00': return v[:i+1]
return v
except IndexError:
return v

def nla_put(msg,v,a,d):
"""
append attribute to msg's attribute list
Expand Down Expand Up @@ -617,6 +603,21 @@ def nla_get(msg,i,value=True):

#### FILE PRIVATE ####

def _nla_strip_(v):
"""
strips padding from v
:param v: value to strip
:returns: v w/o padding
**NOTE: Do not use on numeric attributes
"""
try:
for i,e in reversed(list(enumerate(v))):
if e != '\x00': return v[:i+1]
return v
except IndexError:
return v


def _attrpack_(a,v,d):
"""
:param a: attribute type
Expand Down
1 change: 1 addition & 0 deletions pyric/net/netlink_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def nlmsgerr(error,mlen,nltype,flags,seq,pid):
"""

# Attribute Datatypes
NLA_DATATYPES = ['unspec','u8','u16','u32','u64','string','flag','msecs','nested']
NLA_ERROR = -1 # my own -> failed to unpack attribute, treat as unspec
NLA_UNSPEC = 0 # Unspecified type, binary data chunk
NLA_U8 = 1 # 8 bit integer
Expand Down
3 changes: 1 addition & 2 deletions pyric/pyw.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,7 @@ def modeset(card,mode,flags=None,*argv):
'Can only set flags in monitor mode')
for flag in flags:
if flag not in MNTRFLAGS:
raise pyric.error(errno.EINVAL, 'Invalid flag: {0}',
format(flag))
raise pyric.error(errno.EINVAL, 'Invalid flag: {0}',format(flag))
else: flags = []

try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

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

0 comments on commit 5aece7a

Please sign in to comment.