Changeset 5866
- Timestamp:
- 08/31/10 12:36:38 (3 years ago)
- Location:
- packet-manipulator/branches/BTSniffer_ganja
- Files:
-
- 4 added
- 1 modified
- 1 copied
-
BTSniffer/__init__.py (added)
-
BTSniffer/btcompile.py (copied) (copied from packet-manipulator/branches/BTSniffer_ganja/BTSniffer/cppm) (1 diff)
-
BTSniffer/dep_check (added)
-
BTSniffer/dep_check/bluetooth-dev.c (added)
-
BTSniffer/dep_check/python-dev.c (added)
-
setup.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
packet-manipulator/branches/BTSniffer_ganja/BTSniffer/btcompile.py
r5858 r5866 7 7 import shutil 8 8 import re 9 import subprocess 9 10 10 # build and setup commands 11 CMD_BUILD = 'python setup.py build' 11 class btcompile(): 12 12 13 PATH_PM = '../' 14 PATH_BUILD = 'build/' 15 WANTED_FILE_EXTS = ['py','so'] 16 PATH_BT_BACKEND = PATH_PM + 'umit/pm/backend/bt_sniffer/' 17 PATH_BT_PINCRACK = PATH_PM + 'btpincrack-v0.3' 18 PATH_LIB_PREFIX = '%slib.linux' % PATH_BUILD 13 def __init__(self): 14 # build and setup commands 15 self.CMD_BUILD = 'python setup.py build' 19 16 20 def _cpfunc(arg, dirname, flist): 21 if PATH_LIB_PREFIX in dirname: 22 for f in flist: 23 if f[f.rfind('.') + 1:] in WANTED_FILE_EXTS: 24 srcfile = os.path.join(dirname, f) 25 shutil.copy2(srcfile, PATH_BT_BACKEND) 17 self.PATH_PM = '../' 18 self.PATH_BUILD = 'build/' 19 self.WANTED_FILE_EXTS = ['py','so'] 20 self.PATH_BT_BACKEND = self.PATH_PM + 'umit/pm/backend/bt_sniffer/' 21 self.PATH_BT_PINCRACK = self.PATH_PM + 'btpincrack-v0.3' 22 self.PATH_LIB_PREFIX = '%slib.linux' % self.PATH_BUILD 23 self.dependency = 'dep_check' 24 self.python_dev_file = self.dependency + '/' + 'python-dev.c' 25 self.bluetooth_dev_file = self.dependency + '/' + 'bluetooth-dev.c' 26 26 27 # Only runs on Linux 28 if sys.platform == 'linux2': 27 self.blue_deps = [ 'Bluez :- The Linux Bluetooth Stack', 28 'Bluetooth', 29 'Libbluetooth-dev' 30 ] 31 self.python_deps = ['python-dev : Header files and a static library for Python'] 29 32 30 #Compile and copy the C files for BTSniffer to PATH_BT_BACKEND31 os.system(CMD_BUILD) 32 if os.path.exists(PATH_BT_BACKEND):33 shutil.rmtree(PATH_BT_BACKEND)34 os.makedirs(PATH_BT_BACKEND)35 os.path.walk(PATH_BUILD, _cpfunc, None)33 def _cpfunc(self,arg, dirname, flist): 34 if self.PATH_LIB_PREFIX in dirname: 35 for f in flist: 36 if f[f.rfind('.') + 1:] in self.WANTED_FILE_EXTS: 37 srcfile = os.path.join(dirname, f) 38 shutil.copy2(srcfile, self.PATH_BT_BACKEND) 36 39 37 #Delete old btpincrack in PM, copy it again 38 if os.path.exists(PATH_BT_PINCRACK): 39 shutil.rmtree(PATH_BT_PINCRACK) 40 shutil.copytree('btpincrack-v0.3',PATH_BT_PINCRACK) 40 41 def gcc(self):#check if gcc is present 42 return True 41 43 42 43 else: 44 print 'Many apologies. This is not possible at this stage.'\ 45 'Devt of BTSniffer is still limited to Linux. Thank ' \ 46 'you for trying nonetheless.' 44 def python_dev(self): 45 proc = subprocess.Popen('gcc ' + self.python_dev_file, 46 shell=True, 47 stderr=subprocess.PIPE 48 ) 49 # Need to pass -I/usr/include/python2.6 as compile time argument, find better way 50 for dep in self.python_deps: 51 print dep 52 return False 47 53 54 def blue_dev(self): 55 proc = subprocess.Popen('gcc ' + self.bluetooth_dev_file, 56 shell=True, 57 stderr=subprocess.PIPE 58 ) 59 #No errors if strlength is 0 60 if len(proc.communicate()[1])==0: 61 return True 62 63 for dep in self.blue_deps: 64 print dep 65 return False 48 66 67 def make(self): 68 if self.gcc(): 69 blue_check=self.blue_dev() 70 python_check=self.python_dev() 71 72 if blue_check or python_check: 73 return False 49 74 75 #Compile and copy the C files for BTSniffer to PATH_BT_BACKEND 76 os.system(self.CMD_BUILD) 77 if os.path.exists(self.PATH_BT_BACKEND): 78 shutil.rmtree(self.PATH_BT_BACKEND) 79 os.makedirs(self.PATH_BT_BACKEND) 80 os.path.walk(self.PATH_BUILD, self._cpfunc, None) 50 81 82 #Delete old btpincrack in PM, copy it again 83 if os.path.exists(self.PATH_BT_PINCRACK): 84 shutil.rmtree(self.PATH_BT_PINCRACK) 85 shutil.copytree('btpincrack-v0.3',self.PATH_BT_PINCRACK) 51 86 87 else: 88 return False 52 89 90 #btcompile().make() -
packet-manipulator/branches/BTSniffer_ganja/setup.py
r5449 r5866 31 31 from distutils.command.build import build 32 32 from umit.pm.core.const import PM_VERSION, PM_SITE 33 from BTSniffer.btcompile import btcompile as btcompile 33 34 34 35 ROOT_DIR = os.path.abspath(os.path.dirname(__file__)) … … 36 37 'PacketManipulator-%s' % PM_VERSION) 37 38 DOCS_DIR = os.path.join(ROOT_DIR, 'generated-doc', 'html') 39 PACKAGES = ['umit', 40 'umit.pm', 41 'umit.pm.backend', 42 'umit.pm.backend.abstract', 43 'umit.pm.backend.abstract.basecontext', 44 'umit.pm.backend.abstract.context', 45 'umit.pm.backend.scapy', 46 'umit.pm.backend.scapy.context', 47 'umit.pm.backend.umpa', 48 'umit.pm.backend.umpa.context', 49 'umit.pm.manager', 50 'umit.pm.core', 51 'umit.pm.gui', 52 'umit.pm.gui.core', 53 'umit.pm.gui.tabs', 54 'umit.pm.gui.pages', 55 'umit.pm.gui.sessions', 56 'umit.pm.gui.dialogs', 57 'umit.pm.gui.widgets', 58 'umit.pm.gui.plugins', 59 'umit.pm.higwidgets' 60 ] 61 PACKAGE_DATA = {} 62 #conditional append in both of these 38 63 39 64 def getoutput(cmd): … … 176 201 print "#" * 80 177 202 print 203 204 #If linux, default is install btsniffer and pm 205 if sys.platform == 'linux2': 206 os.chdir('BTSniffer') 207 208 if btcompile().make(): 209 210 PACKAGES.append('umit.pm.backend.bt_sniffer') 211 PACKAGE_DATA['umit.pm.backend.bt_sniffer'] = ['*.so'] 212 213 of.chdir('../') 214 215 else: 216 print "\nInstall above listed libraries or run with --no-btsniffer argument\n" 217 print 218 print "#" * 80 219 print "# Installation Halted" 220 print "#" * 80 221 print 222 return False 223 178 224 179 225 install.run(self) … … 288 334 requires = ['gtk'], 289 335 platforms = ['Platform Independent'], 290 packages = ['umit', 291 'umit.pm', 292 'umit.pm.backend', 293 'umit.pm.backend.abstract', 294 'umit.pm.backend.abstract.basecontext', 295 'umit.pm.backend.abstract.context', 296 'umit.pm.backend.scapy', 297 'umit.pm.backend.scapy.context', 298 'umit.pm.backend.umpa', 299 'umit.pm.backend.umpa.context', 300 'umit.pm.manager', 301 'umit.pm.core', 302 'umit.pm.gui', 303 'umit.pm.gui.core', 304 'umit.pm.gui.tabs', 305 'umit.pm.gui.pages', 306 'umit.pm.gui.sessions', 307 'umit.pm.gui.dialogs', 308 'umit.pm.gui.widgets', 309 'umit.pm.gui.plugins', 310 'umit.pm.higwidgets' 311 ], 336 packages = PACKAGES, 337 package_data = PACKAGE_DATA, 312 338 package_dir = {'umit' : os.path.join(ROOT_DIR, 'umit')}, 313 339 data_files = [
