diff --git a/MANIFEST.in b/MANIFEST.in index 1d8b652..89eec76 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/README.md b/README.md index fbde213..cf38435 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/docs/PyRIC.pdf b/docs/PyRIC.pdf index cce769c..8d8da94 100644 Binary files a/docs/PyRIC.pdf and b/docs/PyRIC.pdf differ diff --git a/docs/PyRIC.tex b/docs/PyRIC.tex index 6efdead..f8ec2ed 100644 --- a/docs/PyRIC.tex +++ b/docs/PyRIC.tex @@ -35,6 +35,7 @@ \usepackage{caption} \usepackage{geometry} \usepackage{color} +\usepackage{graphicx} \usepackage[titletoc,toc,title]{appendix} \usepackage[T1]{fontenc} @@ -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\\ wraith.wireless@yandex.com} \begin{document} @@ -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. @@ -852,12 +853,12 @@ \subsection{Constants} \subsection{Functions} \begin{enumerate} -\item parseoui(path): reads and stores oui data from optional into a dict \item oui(mac): returns the oui portion of address \item ulm(mac): returns the ulm portion of address \item manufacturer(ouis,mac): returns the manufacturer name of given the dict of -\item randhw(ouis): returns a random mac address given a dict of +\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 @@ -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} diff --git a/docs/logo.png b/docs/logo.png index 4a0a20c..015b9f0 100644 Binary files a/docs/logo.png and b/docs/logo.png differ diff --git a/pyric/__init__.py b/pyric/__init__.py index 4fd607d..cd1948b 100644 --- a/pyric/__init__.py +++ b/pyric/__init__.py @@ -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: @@ -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' diff --git a/pyric/pyw_unittest.py b/pyric/pyw_unittest.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyric/utils/__init__.py b/pyric/utils/__init__.py index 5632f02..12fcaf3 100644 --- a/pyric/utils/__init__.py +++ b/pyric/utils/__init__.py @@ -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' diff --git a/pyric/utils/hardware.py b/pyric/utils/hardware.py index ead73b7..8c1dca5 100644 --- a/pyric/utils/hardware.py +++ b/pyric/utils/hardware.py @@ -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' @@ -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 @@ -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 diff --git a/pyric/utils/ouifetch.py b/pyric/utils/ouifetch.py index 2610571..23defd3 100644 --- a/pyric/utils/ouifetch.py +++ b/pyric/utils/ouifetch.py @@ -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 @@ -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') @@ -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) diff --git a/setup.py b/setup.py index f923f24..ae73e57 100644 --- a/setup.py +++ b/setup.py @@ -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']} )