from framework.dependency_management.dependency_resolver import ServiceLocator


DESCRIPTION = "Launches all Exploits for a category(ies) -i.e. for IDS testing-"
CATEGORIES = ['LINUX', 'WINDOWS', 'OSX']
SUBCATEGORIES = ['DCERPC', 'FTP', 'HTTP', 'IIS', 'IMAP', 'ISAPI', 'LDAP', 'LPD', 'MDNS', 'MISC', 'MMSP', 'MSSQL',
                 'MYSQL', 'NOVELL', 'NFS', 'NNTP', 'NTP', 'ORACLE', 'PHP', 'POP3', 'POSTGRES', 'PPTP', 'PROXY',
                 'REALSERVER', 'RPC', 'RTSP', 'SAMBA', 'SCADA', 'SIP', 'SMB', 'SMTP', 'SOFTCART', 'SSH', 'SSL',
                 'SUNRPC', 'SVN', 'TACACS', 'TELNET', 'TFTP', 'UNICENTER', 'VNC', 'VPN', 'WEBAPP', 'WINS', 'WYSE']


def run(PluginInfo):
    Content = []
    plugin_params = ServiceLocator.get_component("plugin_params")
    config = ServiceLocator.get_component("config")
    args = {
        'Description': DESCRIPTION,
        'Mandatory': {
            'RHOST': config.FrameworkConfigGet('RHOST_DESCRIP'),
            'RPORT': config.FrameworkConfigGet('RPORT_DESCRIP'),
            'CATEGORY': 'Category to use (i.e. ' + ', '.join(sorted(CATEGORIES)) + ')',
            'SUBCATEGORY': 'Subcategory to use (i.e. ' + ', '.join(sorted(SUBCATEGORIES)) + ')'
        },
        'Optional': {'REPEAT_DELIM': config.FrameworkConfigGet('REPEAT_DELIM_DESCRIP')}
    }
    for Args in plugin_params.GetArgs(args, PluginInfo):
        plugin_params.SetConfig(Args)
        resource = config.GetResources('LaunchExploit_' + Args['CATEGORY'] + "_" + Args['SUBCATEGORY'])
        Content += ServiceLocator.get_component("plugin_helper").CommandDump('Test Command', 'Output',
                                                                             resource, PluginInfo, "")
    return Content
