コード例 #1
0
def main(workspace='', args=None, parser=None):

    parser.add_argument('-y', '--yes', action="store_true")
    parsed_args = parser.parse_args(args)

    try:
        vulns = models.get_all_vulns(workspace)
    except ResourceDoesNotExist:
        print ("Invalid workspace name: ", workspace)
        return 1, None

    if not parsed_args.yes:
        if not query_yes_no("Are you sure you want to change the status to closed of all the vulns in workspace %s" % workspace, default='no'):
            return 1, None

    count = 0
    for vuln in vulns:
        old_status = vuln.status

        # Valid status
        if vuln.status != "closed":

            vuln.status = "closed"
            count += 1

            if vuln.class_signature == "Vulnerability":
                models.update_vuln(workspace, vuln)

            elif vuln.class_signature == "VulnerabilityWeb":
                models.update_vuln_web(workspace, vuln)

            print (vuln.name, ": Status changed from", old_status,"to closed successfully")

    print ("End of process:", count, "vulnerabilities changed to closed")
    return 0, None
コード例 #2
0
ファイル: delAllVulnsWith.py プロジェクト: yashodhank/faraday
def main(workspace=''):

    regex = (
        r"ssl\-cert|ssl\-date|Traceroute Information|TCP\/IP Timestamps Supported"
        r"|OS Identification|Common Platform Enumeration")

    for vuln in models.get_all_vulns(workspace):
        if re.findall(regex, vuln.name, ) != []:
            print("Delete Vuln: " + vuln.name)
            models.delete_vuln(workspace, vuln.id)
コード例 #3
0
def main(workspace='', args=None, parser=None):
    default_regex = (
        r"ssl\-cert|ssl\-date|Traceroute Information|TCP\/IP Timestamps Supported"
        r"|OS Identification|Common Platform Enumeration")
    parser.add_argument('-y', '--yes', action="store_true")
    parser.add_argument('-r', '--regex', default=default_regex)
    parsed_args = parser.parse_args(args)
    if not parsed_args.yes:
        msg = ("Are you sure you want to delete all vulnerabilities "
               "matching the regex {} in the worspace {}? "
               "This action can't be undone [y/n] ".format(
                   parsed_args.regex, workspace))
        if raw_input(msg) not in ('y', 'yes'):
            return 1, None

    for vuln in models.get_all_vulns(workspace):
        if re.findall(parsed_args.regex, vuln.name, ) != []:
            print("Delete Vuln: " + vuln.name)
            models.delete_vuln(workspace, vuln.id)
    return 0, None
コード例 #4
0
def main(workspace='', args=None, parser=None):

    parser.add_argument('-y', '--yes', action="store_true")
    parsed_args = parser.parse_args(args)

    try:
        vulns = models.get_all_vulns(workspace)
    except ResourceDoesNotExist:
        print("Invalid workspace name: ", workspace)
        return 1, None

    if not parsed_args.yes:
        if not query_yes_no(
                "Are you sure you want to change the status to closed of all the vulns in workspace %s"
                % workspace,
                default='no'):
            return 1, None

    count = 0
    for vuln in vulns:
        old_status = vuln.status

        # Valid status
        if vuln.status != "closed":

            vuln.status = "closed"
            count += 1

            if vuln.class_signature == "Vulnerability":
                models.update_vuln(workspace, vuln)

            elif vuln.class_signature == "VulnerabilityWeb":
                models.update_vuln_web(workspace, vuln)

            print(vuln.name, ": Status changed from", old_status,
                  "to closed successfully")

    print("End of process:", count, "vulnerabilities changed to closed")
    return 0, None
コード例 #5
0
def main(workspace='', args=None, parser=None):
    default_regex = (
        r"ssl\-cert|ssl\-date|Traceroute Information|TCP\/IP Timestamps Supported"
        r"|OS Identification|Common Platform Enumeration")
    parser.add_argument('-y', '--yes', action="store_true")
    parser.add_argument('-r', '--regex', default=default_regex)
    parsed_args = parser.parse_args(args)
    if not parsed_args.yes:
        msg = ("Are you sure you want to delete all vulnerabilities "
               "matching the regex {} in the worspace {}? "
               "This action can't be undone [y/n] ".format(
                   parsed_args.regex, workspace))
        if raw_input(msg) not in ('y', 'yes'):
            return 1, None

    for vuln in models.get_all_vulns(workspace):
        if re.findall(
                parsed_args.regex,
                vuln.name,
        ) != []:
            print("Delete Vuln: " + vuln.name)
            models.delete_vuln(workspace, vuln.id)
    return 0, None
コード例 #6
0
ファイル: server.py プロジェクト: mr-wrmsr/BlackServerOS
 def get_all_vulns(self, **params):
     return models.get_all_vulns(self.active_workspace, **params)
コード例 #7
0
ファイル: server.py プロジェクト: MrMugiwara/faraday
 def get_all_vulns(self, **params):
     return models.get_all_vulns(self.active_workspace, **params)
コード例 #8
0
ファイル: searcher.py プロジェクト: perplext/faraday
def main():
    signal.signal(signal.SIGINT, signal_handler)

    parser = argparse.ArgumentParser(description='Search duplicated objects on Faraday')
    parser.add_argument('-w', '--workspace', help='Search duplicated objects into this workspace', required=True)
    parser.add_argument('-s', '--server', help='Faraday server', required=False, default="http://127.0.0.1:5985/")
    parser.add_argument('-u', '--user', help='Faraday user', required=False, default="")
    parser.add_argument('-p', '--password', help='Faraday password', required=False, default="")
    parser.add_argument('-o', '--output', help='Choose a custom output directory', required=False)
    parser.add_argument('-l', '--log', help='Choose a custom log level', required=False)
    args = parser.parse_args()

    lockf = ".lock.pod"
    if not lock_file(lockf):
        print ("You can run only one instance of searcher (%s)" % lockf)
        exit(0)

    workspace = ''
    if args.workspace:
        workspace = args.workspace
    else:
        print("You must enter a workspace in command line, please use --help to read more")
        os.remove(lockf)
        exit(0)

    _server = 'http://127.0.0.1:5985/'
    if args.server:
        _server = args.server

    _user = '******'
    if args.user:
        _user = args.user

    _password = '******'
    if args.password:
        _password = args.password

    output = 'output/'
    if args.output:
        output = args.output

    loglevel = 'debug'
    if args.log:
        loglevel = args.log

    for d in [output, 'log/']:
        if not os.path.isdir(d):
            os.makedirs(d)

    numeric_level = getattr(logging, loglevel.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError('Invalid log level: %s' % loglevel)

    if not logger.handlers:
        logger.propagate = 0
        logger.setLevel(numeric_level)
        fh = logging.FileHandler('log/searcher.log')
        fh.setLevel(numeric_level)
        # create console handler with a higher log level
        ch = logging.StreamHandler()
        ch.setLevel(numeric_level)
        # create formatter and add it to the handlers
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')

        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        logger.addHandler(fh)
        logger.addHandler(ch)

    try:
        session_cookie = login_user(_server, _user, _password)
        if not session_cookie:
            raise UserWarning('Invalid credentials!')
        else:
            CONF.setDBUser(_user)
            CONF.setDBSessionCookies(session_cookie)

        server.AUTH_USER = _user
        server.AUTH_PASS = _password
        server.SERVER_URL = _server
        server.FARADAY_UP = False

        logger.info('Started')
        logger.info('Searching objects into workspace %s ' % workspace)

        logger.debug("Getting hosts ...")
        hosts = models.get_hosts(workspace)

        logger.debug("Getting services ...")
        services = models.get_services(workspace)

        logger.debug("Getting vulnerabilities ...")
        vulns = models.get_all_vulns(workspace)

        if validate_rules():
            process_vulnerabilities(workspace, vulns, _server)
            process_services(workspace, services, _server)
            process_hosts(workspace, hosts, _server)

        # Remove lockfile
        os.remove(lockf)

        logger.info('Finished')

    except ResourceDoesNotExist:
        logger.error("Resource not found")
        os.remove(lockf)
        exit(0)

    except Exception as errorMsg:
        logger.error(errorMsg)
        os.remove(lockf)
        exit(0)
コード例 #9
0
def main():
    signal.signal(signal.SIGINT, signal_handler)

    parser = argparse.ArgumentParser(
        description='Search duplicated objects on Faraday')
    parser.add_argument('-w',
                        '--workspace',
                        help='Search duplicated objects into this workspace',
                        required=True)
    parser.add_argument('-s',
                        '--server',
                        help='Faraday server',
                        required=False,
                        default="http://127.0.0.1:5985/")
    parser.add_argument('-u',
                        '--user',
                        help='Faraday user',
                        required=False,
                        default="")
    parser.add_argument('-p',
                        '--password',
                        help='Faraday password',
                        required=False,
                        default="")
    parser.add_argument('-o',
                        '--output',
                        help='Choose a custom output directory',
                        required=False)
    parser.add_argument('-l',
                        '--log',
                        help='Choose a custom log level',
                        required=False)
    args = parser.parse_args()

    lockf = ".lock.pod"
    if not lock_file(lockf):
        print("You can run only one instance of searcher (%s)" % lockf)
        exit(0)

    workspace = ''
    if args.workspace:
        workspace = args.workspace
    else:
        print(
            "You must enter a workspace in command line, please use --help to read more"
        )
        os.remove(lockf)
        exit(0)

    _server = 'http://127.0.0.1:5985/'
    if args.server:
        _server = args.server

    _user = '******'
    if args.user:
        _user = args.user

    _password = '******'
    if args.password:
        _password = args.password

    output = 'output/'
    if args.output:
        output = args.output

    loglevel = 'debug'
    if args.log:
        loglevel = args.log

    for d in [output, 'log/']:
        if not os.path.isdir(d):
            os.makedirs(d)

    numeric_level = getattr(logging, loglevel.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError('Invalid log level: %s' % loglevel)

    if not logger.handlers:
        logger.propagate = 0
        logger.setLevel(numeric_level)
        fh = logging.FileHandler('log/searcher.log')
        fh.setLevel(numeric_level)
        # create console handler with a higher log level
        ch = logging.StreamHandler()
        ch.setLevel(numeric_level)
        # create formatter and add it to the handlers
        formatter = logging.Formatter(
            '%(asctime)s - %(name)s - %(levelname)s: %(message)s',
            datefmt='%m/%d/%Y %I:%M:%S %p')

        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        logger.addHandler(fh)
        logger.addHandler(ch)

    try:
        session_cookie = login_user(_server, _user, _password)
        if not session_cookie:
            raise UserWarning('Invalid credentials!')
        else:
            CONF.setDBUser(_user)
            CONF.setDBSessionCookies(session_cookie)

        server.AUTH_USER = _user
        server.AUTH_PASS = _password
        server.SERVER_URL = _server
        server.FARADAY_UP = False

        logger.info('Started')
        logger.info('Searching objects into workspace %s ' % workspace)

        logger.debug("Getting hosts ...")
        hosts = models.get_hosts(workspace)

        logger.debug("Getting services ...")
        services = models.get_services(workspace)

        logger.debug("Getting vulnerabilities ...")
        vulns = models.get_all_vulns(workspace)

        if validate_rules():
            process_vulnerabilities(workspace, vulns, _server)
            process_services(workspace, services, _server)
            process_hosts(workspace, hosts, _server)

        # Remove lockfile
        os.remove(lockf)

        logger.info('Finished')

    except ResourceDoesNotExist:
        logger.error("Resource not found")
        os.remove(lockf)
        exit(0)

    except Exception as errorMsg:
        logger.error(errorMsg)
        os.remove(lockf)
        exit(0)