#NEWLINE# def load_modules( self ) : #NEWLINE# #INDENT# self . main_modules_dirs = [ module for module in os . listdir ( files . modules_directory ) if ( not module . startswith ( '__' ) ) ] #NEWLINE# self . modules = [ ] #NEWLINE# self . modules_with_errors = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( root , dirs , files ) in os . walk ( self . modules_directory ) : #NEWLINE# #INDENT# ( _ , package , root ) = root . rpartition ( 'routersploit' ) #NEWLINE# root = '' . join ( ( package , root ) ) . replace ( os . sep , '.' ) #NEWLINE# modules = map ( ( lambda x : '.' . join ( ( root , os . path . splitext ( x ) [ 0 ] ) ) ) , filter ( ( lambda x : x . endswith ( '.py' ) ) , files ) ) #NEWLINE# for module_path in modules : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# module = importlib . import_module ( module_path ) #NEWLINE# #UNINDENT# except ImportError as error : #NEWLINE# #INDENT# self . modules_with_errors [ module_path ] = error #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# klasses = inspect . getmembers ( module , inspect . isclass ) #NEWLINE# exploits = filter ( ( lambda x : issubclass ( x [ 1 ] , Exploit ) ) , klasses ) #NEWLINE# if exploits : #NEWLINE# #INDENT# self . modules . append ( module_path . split ( '.' , 2 ) . pop ( ) )