Skip to content

Commit

Permalink
v0.1.2 fixed pip install errors, Issue #13
Browse files Browse the repository at this point in the history
  • Loading branch information
wraith-wireless committed Jun 11, 2016
1 parent 3b39afd commit b114dde
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 67 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
include LICENSE README.md TODO

# Include subdirectories
# note to self: even including recursive-include here, have to follow up by
# ensuring data (non .py) files are also referenced in setup.py
recursive-include examples
recursive-include examples *.py
recursive-include docs *.pdf
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PyRIC: Python Radio Interface Controller
# PyRIC 0.1.2: Python Radio Interface Controller
## Linux wireless library for the Python Wireless Developer and Pentester
![](docs/logo.png?raw=true)

Expand Down
Binary file modified docs/PyRIC.pdf
Binary file not shown.
27 changes: 20 additions & 7 deletions docs/PyRIC.tex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
\usepackage{caption}
\usepackage{geometry}
\usepackage{color}
\usepackage{graphicx}
\usepackage[titletoc,toc,title]{appendix}
\usepackage[T1]{fontenc}

Expand Down Expand Up @@ -72,7 +73,7 @@
basicstyle=\footnotesize
}

\title{PyRIC v0.1.1: User Manual}
\title{\includegraphics[scale=1]{logo}\\ PyRIC v0.1.2: User Manual}
\author{Dale V. Patterson\\ [email protected]}

\begin{document}
Expand Down Expand Up @@ -840,7 +841,7 @@ \subsection{Functions}
\item rf2ch(f): convert frequency f to channel
\end{enumerate}

\section{API: hardware.py}\label{sec:deviceapi}
\section{API: hardware.py}\label{sec:hardwareapi}
Hardware related: driver, chipset, manufacturer and mac address utility functions
can be found in device.py.

Expand All @@ -852,12 +853,12 @@ \subsection{Constants}

\subsection{Functions}
\begin{enumerate}
\item parseoui(path): reads and stores oui data from optional <path> into a dict
\item oui(mac): returns the oui portion of address <mac>
\item ulm(mac): returns the ulm portion of address <mac>
\item manufacturer(ouis,mac): returns the manufacturer name of <mac> given the
dict of <ouis>
\item randhw(ouis): returns a random mac address given a dict of <ouis>
\item randhw([ouis]): returns a random mac address. If the dict ouis is specified
will select a random oui from the dict otherwise will generate one
\item ifcard(dev): returns the device driver and chipset
\item ifdriver(dev): returns the device driver
\item ifchipset(driver): returns the chipset associated with driver
Expand All @@ -867,13 +868,25 @@ \section{API: ouifetch.py}
The file ouifetch.py retrieves and saves a tab seperated file of oui to
manufacturer name for use by hardware.py functions. From a command line, type: \\

\texttt{python ouifetch.py}\\
\subsection{Constants}
\begin{enumerate}
\item \textbf{OUIURL}: url of IEEE oui file
\item \textbf{OUIPATH}: path to default location PyRIC oui.txt file
\end{enumerate}

Optional arguments path and verbose can also be specified.
\subsection{Functions}
\begin{enumerate}
\item parse([opath]): returns a dict of oui:manufacturer key->value pairs stored
in the text file at opath. If opath is not specified, uses the default
\item fetch([opath]): retrieves oui.txt from the IEEE website, parses the files
and stores the results in a PyRIC friendly format in opath. If opath is not
specified, uses the default. User must have root permissions in order to write
to default opath
\end{enumerate}

\section{API: rfkill.py}\label{sec:rfkillapi}
A port of the command line tool rfkill, rfkill.py writes and reads rfkill\_event
structures to /dev/rfkill using fcntl provding functionality to block and unblock
structures to /dev/rfkill using fcntl providing functionality to block and unblock
devices.

\subsection{Constants}
Expand Down
Binary file modified docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions pyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
changes:
o production release
pyric 0.1.1 t0 0.1.1-1
pyric 0.1.1 t0 0.1.1-*
desc: wireless nic library: wireless radio identification, manipulation, enumeration
includes: /nlhelp /lib /net /utils pyw 0.1.2
changes:
Expand All @@ -133,11 +133,22 @@
o added block/unblock to pyw
o updated pyw to handle the newest version of libnl.py's processing of nested
attributes
pyric 0.1.2
desc: wireless nic library: wireless radio identification, manipulation, enumeration
includes: /nlhelp /lib /net /utils pyw 0.1.4
changes:
o fixed install issues via pip where data files were not being loaded onto
the user's system
o identified and fixed error with ouifetch with invalid path of default oui file
o moved parseoui from hardware to ouifetch renaming to parse
o removed ouifetch execution ability - parse and fetch must be called w/in
python console. Will eventually add this capability as as top-level program
"""

__name__ = 'pyric'
__license__ = 'GPLv3'
__version__ = '0.1.1-2'
__version__ = '0.1.2'
__date__ = 'June 2016'
__author__ = 'Dale Patterson'
__maintainer__ = 'Dale Patterson'
Expand Down
Empty file removed pyric/pyw_unittest.py
Empty file.
5 changes: 3 additions & 2 deletions pyric/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
utils 0.0.1
desc: utilities
includes: hardware 0.0.4 ouifetch 0.0.1 channels 0.0.1 rfkill 0.0.1
includes: hardware 0.0.5 ouifetch 0.0.1 channels 0.0.1 rfkill 0.0.1
changes:
o added mac address related to hardware.py
o randhw does not force an ouis dict, if not present, randomly generates the
oui and the ulm
"""

__name__ = 'utils'
Expand Down
38 changes: 7 additions & 31 deletions pyric/utils/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

__name__ = 'hardware'
__license__ = 'GPLv3'
__version__ = '0.0.4'
__version__ = '0.0.5'
__date__ = 'June 2016'
__author__ = 'Dale Patterson'
__maintainer__ = 'Dale Patterson'
Expand All @@ -35,37 +35,10 @@

import os
import random
import pyric

dpath = '/proc/net/dev' # system device details
drvpath = '/sys/class/net/{0}/device/driver/module/drivers' # format w/ device name

def parseoui(path=None):
"""
parse oui.txt file
:param path: path of oui text file
:returns: oui dict {oui:manuf} for each oui in path or empty dict
"""
fin = None
ouis = {}

if not path:
path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'data/oui.txt')

try:
fin = open(path)
for line in fin.readlines()[1:]:
o,m = line.strip().split('\t')
ouis[o.lower()] = m[0:100]
fin.close()
except IndexError:
pass
except IOError as e:
raise pyric.error(e.errno,e.strerror)
finally:
if fin and not fin.closed: fin.close()
return ouis

def oui(mac):
"""
:param mac: 48-bit mac address
Expand All @@ -92,13 +65,16 @@ def manufacturer(ouis,mac):
except KeyError:
return "unknown"

def randhw(ouis):
def randhw(ouis=None):
"""
generate a random hw address
:param ouis: oui dict to use
:param ouis: oui dict to use (if any)
:returns: random hw address
"""
o = random.choice(ouis.keys())
if ouis is None or ouis == []:
o = ":".join(['{0:02x}'.format(random.randint(0,255)) for _ in xrange(3)])
else:
o = random.choice(ouis.keys())
u = ":".join(['{0:02x}'.format(random.randint(0,255)) for _ in xrange(3)])
return o + ':' + u

Expand Down
68 changes: 47 additions & 21 deletions pyric/utils/ouifetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,48 @@
__status__ = 'Production'

import urllib2,os,sys,datetime,time
import argparse as ap
#import argparse as ap
import pyric

OUIURL = 'http://standards-oui.ieee.org/oui.txt'
OUIPATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),
os.path.abspath('data/oui.txt'))
OUIPATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),'data/oui.txt')

def fetch(path=None,verbose=False):
def parse(opath=None):
"""
parse oui.txt file
:param opath: path of oui text file
:returns: oui dict {oui:manuf} for each oui in path or empty dict
"""
fin = None
ouis = {}

if not opath: opath = OUIPATH

try:
fin = open(opath)
for line in fin.readlines()[1:]:
o,m = line.strip().split('\t')
ouis[o.lower()] = m[0:100]
fin.close()
except IndexError:
pass
except IOError as e:
raise pyric.error(e.errno,e.strerror)
finally:
if fin and not fin.closed: fin.close()
return ouis


def fetch(opath=None,verbose=False):
"""
retrieves oui.txt from IEEE and writes to data file
:param path: fullpath of oui.txt
:param opath: fullpath of oui.txt
:param verbose: write updates to stdout
"""
# determine if data path is legit
if path is None: path = OUIPATH
if not os.path.isdir(os.path.dirname(path)):
print "Path to data is incorrect {0}".format(path)
if opath is None: opath = OUIPATH
if not os.path.isdir(os.path.dirname(opath)):
print "Path to data is incorrect {0}".format(opath)
sys.exit(1)

# fetch oui file from ieee
Expand All @@ -64,8 +90,8 @@ def fetch(path=None,verbose=False):
res = urllib2.urlopen(req)
if verbose: print "Parsing OUI file"

if verbose: print "Opening data file {0} for writing".format(path)
fout = open(path,'w')
if verbose: print "Opening data file {0} for writing".format(opath)
fout = open(opath,'w')
gen = datetime.datetime.utcnow().isoformat() # use current time as the first line
fout.write(gen+'\n')

Expand Down Expand Up @@ -95,16 +121,16 @@ def fetch(path=None,verbose=False):
finally:
if fout: fout.close()

if __name__ == '__main__':
# create arg parser and parse command line args
print "OUI Fetch {0}".format(__version__)
argp = ap.ArgumentParser(description="IEEE OUI fetch and parse")
argp.add_argument('-p','--path',help="Path to write parsed file")
argp.add_argument('-v','--verbose',action='store_true',help="Display operations to stdout")
argp.add_argument('--version',action='version',version="OUI Fetch {0}".format(__version__))
args = argp.parse_args()
verbose = args.verbose
path = args.path
#if __name__ == '__main__':
# # create arg parser and parse command line args
# print "OUI Fetch {0}".format(__version__)
# argp = ap.ArgumentParser(description="IEEE OUI fetch and parse")
# argp.add_argument('-p','--path',help="Path to write parsed file")
# argp.add_argument('-v','--verbose',action='store_true',help="Display operations to stdout")
# argp.add_argument('--version',action='version',version="OUI Fetch {0}".format(__version__))
# args = argp.parse_args()
# verbose = args.verbose
# path = args.path

# execute
fetch(path,verbose)
# fetch(path,verbose)
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@
'Topic :: Utilities',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7'
],
'Programming Language :: Python :: 2.7'],
keywords='Linux nl80211 iw wireless pentest',
packages=find_packages(),
package_data={'pyric':['docs/*.help']}
package_data={'pyric':['nlhelp/*.help','utils/data/*.txt']}
)

0 comments on commit b114dde

Please sign in to comment.