#NEWLINE# def process_options( user_args ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# db_plugin = ServiceLocator . get_component ( 'db_plugin' ) #NEWLINE# valid_groups = db_plugin . GetAllGroups ( ) #NEWLINE# valid_types = ( db_plugin . GetAllTypes ( ) + [ 'all' , 'quiet' ] ) #NEWLINE# arg = parse_options ( user_args , valid_groups , valid_types ) #NEWLINE# #UNINDENT# except KeyboardInterrupt as e : #NEWLINE# #INDENT# usage ( ( 'Invalid OWTF option(s) ' + plugin_types_for_group ) ) #NEWLINE# #UNINDENT# profiles = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# plugin_group = arg . PluginGroup #NEWLINE# if arg . CustomProfile : #NEWLINE# #INDENT# for profile in arg . CustomProfile . split ( ',' ) : #NEWLINE# #INDENT# chunks = profile . split ( ':' ) #NEWLINE# if ( ( len ( chunks ) != 2 ) or ( not os . path . exists ( chunks [ 1 ] ) ) ) : #NEWLINE# #INDENT# usage ( 'Invalid Profile' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# profiles [ chunks [ 0 ] ] = chunks [ 1 ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if arg . OnlyPlugins : #NEWLINE# #INDENT# ( arg . OnlyPlugins , plugin_groups ) = get_plugins_from_arg ( arg . OnlyPlugins ) #NEWLINE# try : #NEWLINE# #INDENT# plugin_group = plugin_groups [ 0 ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# usage ( 'Please use either OWASP/OWTF codes or Plugin names' ) #NEWLINE# #UNINDENT# logging . info ( ( ( "Defaulting Plugin Group to '" + plugin_group ) + "' based on list of plugins supplied" ) ) #NEWLINE# #UNINDENT# if arg . ExceptPlugins : #NEWLINE# #INDENT# ( arg . ExceptPlugins , plugin_groups ) = get_plugins_from_arg ( arg . ExceptPlugins ) #NEWLINE# #UNINDENT# if arg . TOR_mode : #NEWLINE# #INDENT# arg . TOR_mode = arg . TOR_mode . split ( ':' ) #NEWLINE# if ( arg . TOR_mode [ 0 ] == 'help' ) : #NEWLINE# #INDENT# from framework.http.proxy.tor_manager import TOR_manager #NEWLINE# TOR_manager . msg_configure_tor ( ) #NEWLINE# exit ( 0 ) #NEWLINE# #UNINDENT# if ( len ( arg . TOR_mode ) == 1 ) : #NEWLINE# #INDENT# if ( arg . TOR_mode [ 0 ] != 'help' ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for TOR-mode' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( arg . TOR_mode ) != 5 ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for TOR-mode' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( arg . TOR_mode [ 0 ] == '' ) : #NEWLINE# #INDENT# outbound_proxy_ip = '127.0.0.1' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# outbound_proxy_ip = arg . TOR_mode [ 0 ] #NEWLINE# #UNINDENT# if ( arg . TOR_mode [ 1 ] == '' ) : #NEWLINE# #INDENT# outbound_proxy_port = '9050' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# outbound_proxy_port = arg . TOR_mode [ 1 ] #NEWLINE# #UNINDENT# arg . OutboundProxy = ( ( ( 'socks://' + outbound_proxy_ip ) + ':' ) + outbound_proxy_port ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if arg . Botnet_mode : #NEWLINE# #INDENT# arg . Botnet_mode = arg . Botnet_mode . split ( ':' ) #NEWLINE# if ( ( arg . Botnet_mode [ 0 ] == 'miner' ) and ( len ( arg . Botnet_mode ) != 1 ) ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for Botnet mode\n Mode must be miner or list' ) #NEWLINE# #UNINDENT# if ( arg . Botnet_mode [ 0 ] == 'list' ) : #NEWLINE# #INDENT# if ( len ( arg . Botnet_mode ) != 2 ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for Botnet mode\n Mode must be miner or list' ) #NEWLINE# #UNINDENT# if ( not os . path . isfile ( os . path . expanduser ( arg . Botnet_mode [ 1 ] ) ) ) : #NEWLINE# #INDENT# usage ( 'Error Proxy List not found! Please check the path.' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if arg . OutboundProxy : #NEWLINE# #INDENT# arg . OutboundProxy = arg . OutboundProxy . split ( '://' ) #NEWLINE# if ( len ( arg . OutboundProxy ) == 2 ) : #NEWLINE# #INDENT# arg . OutboundProxy = ( arg . OutboundProxy + arg . OutboundProxy . pop ( ) . split ( ':' ) ) #NEWLINE# if ( arg . OutboundProxy [ 0 ] not in [ 'socks' , 'http' ] ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for Outbound Proxy' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# arg . OutboundProxy = arg . OutboundProxy . pop ( ) . split ( ':' ) #NEWLINE# #UNINDENT# if ( len ( arg . OutboundProxy ) not in [ 2 , 3 ] ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for Outbound Proxy' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# int ( arg . OutboundProxy [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# usage ( 'Invalid port provided for Outbound Proxy' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if arg . InboundProxy : #NEWLINE# #INDENT# arg . InboundProxy = arg . InboundProxy . split ( ':' ) #NEWLINE# if ( len ( arg . InboundProxy ) not in [ 1 , 2 ] ) : #NEWLINE# #INDENT# usage ( 'Invalid argument for Inbound Proxy' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# int ( arg . InboundProxy [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# usage ( 'Invalid port for Inbound Proxy' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# plugin_types_for_group = db_plugin . GetTypesForGroup ( plugin_group ) #NEWLINE# if ( arg . PluginType == 'all' ) : #NEWLINE# #INDENT# arg . PluginType = plugin_types_for_group #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( arg . PluginType == 'quiet' ) : #NEWLINE# #INDENT# arg . PluginType = [ 'passive' , 'semi_passive' ] #NEWLINE# #UNINDENT# #UNINDENT# scope = ( arg . Targets or [ ] ) #NEWLINE# num_targets = len ( scope ) #NEWLINE# if ( ( plugin_group != 'auxiliary' ) and ( num_targets == 0 ) and ( not arg . list_plugins ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( num_targets == 1 ) : #NEWLINE# #INDENT# if os . path . isfile ( scope [ 0 ] ) : #NEWLINE# #INDENT# logging . info ( 'Scope file: trying to load targets from it ..' ) #NEWLINE# new_scope = [ ] #NEWLINE# for target in open ( scope [ 0 ] ) . read ( ) . split ( '\n' ) : #NEWLINE# #INDENT# CleanTarget = target . strip ( ) #NEWLINE# if ( not CleanTarget ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# new_scope . append ( CleanTarget ) #NEWLINE# #UNINDENT# if ( len ( new_scope ) == 0 ) : #NEWLINE# #INDENT# usage ( 'Please provide a scope file (1 target x line)' ) #NEWLINE# #UNINDENT# scope = new_scope #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for target in scope : #NEWLINE# #INDENT# if ( target [ 0 ] == '-' ) : #NEWLINE# #INDENT# usage ( ( 'Invalid Target: ' + target ) ) #NEWLINE# #UNINDENT# #UNINDENT# args = '' #NEWLINE# if ( plugin_group == 'auxiliary' ) : #NEWLINE# #INDENT# args = scope #NEWLINE# scope = [ 'auxiliary' ] #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'list_plugins' : arg . list_plugins , #NEWLINE# 'Force_Overwrite' : arg . ForceOverwrite , #NEWLINE# 'Interactive' : ( arg . Interactive == 'yes' ) , #NEWLINE# 'Simulation' : arg . Simulation , #NEWLINE# 'Scope' : scope , #NEWLINE# 'argv' : sys . argv , #NEWLINE# 'PluginType' : arg . PluginType , #NEWLINE# 'OnlyPlugins' : arg . OnlyPlugins , #NEWLINE# 'ExceptPlugins' : arg . ExceptPlugins , #NEWLINE# 'InboundProxy' : arg . InboundProxy , #NEWLINE# 'OutboundProxy' : arg . OutboundProxy , #NEWLINE# 'OutboundProxyAuth' : arg . OutboundProxyAuth , #NEWLINE# 'Profiles' : profiles , #NEWLINE# 'PluginGroup' : plugin_group , #NEWLINE# 'RPort' : arg . RPort , #NEWLINE# 'PortWaves' : arg . PortWaves , #NEWLINE# 'ProxyMode' : arg . ProxyMode , #NEWLINE# 'TOR_mode' : arg . TOR_mode , #NEWLINE# 'Botnet_mode' : arg . Botnet_mode , #NEWLINE# 'nowebui' : arg . nowebui , #NEWLINE# 'Args' : args , #NEWLINE# #UNINDENT# }