Exemplo n.º 1
0
def _run():
    """Entry point for all uses of centinel"""
    args = parse_args()

    # register signal handler
    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    # set up logging
    log_formatter = logging.Formatter("%(asctime)s %(filename)s(line %(lineno)d) "
                                      "%(levelname)s: %(message)s")
    root_logger = logging.getLogger()
    root_logger.setLevel(logging.INFO)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    root_logger.addHandler(console_handler)

    # add file handler if specified
    if args.log_file:
        file_handler = logging.FileHandler(args.log_file)
        file_handler.setFormatter(log_formatter)
        root_logger.addHandler(file_handler)

    # check vm_num and vm_index value
    if args.vm_num < 1:
        print "vm_num value cannot be negative!"
        return
    if args.vm_index < 1 or args.vm_index > args.vm_num:
        print "vm_index value cannot be negative or greater than vm_num!"
        return

    if args.create_conf_dir:
        if args.create_HMA:
            hma_dir = return_abs_path(args.create_conf_dir, 'vpns')
            hma.create_config_files(hma_dir)
        elif args.create_IPVANISH:
            ipvanish_dir = return_abs_path(args.create_conf_dir, 'vpns')
            ipvanish.create_config_files(ipvanish_dir)
        elif args.create_PUREVPN:
            purevpn_dir = return_abs_path(args.create_conf_dir, 'vpns')
            purevpn.create_config_files(purevpn_dir)
        elif args.create_VPNGATE:
            vpngate_dir = return_abs_path(args.create_conf_dir, 'vpns')
            vpngate.create_config_files(vpngate_dir)
        # create the config files for the openvpn config files
        create_config_files(args.create_conf_dir)
    else:
        # sanity check tls_auth and key_direction
        if (args.tls_auth is not None and args.key_direction is None) or \
                (args.tls_auth is None and args.key_direction is not None):
            logging.error("tls_auth and key_direction must be specified "
                          "together!")
            return

        scan_vpns(directory=args.directory, auth_file=args.auth_file,
                  crt_file=args.crt_file, tls_auth=args.tls_auth,
                  key_direction=args.key_direction, exclude_list=args.exclude_list,
                  shuffle_lists=args.shuffle_lists, vm_num=args.vm_num,
                  vm_index=args.vm_index, reduce_vp=args.reduce_vp)
Exemplo n.º 2
0
def run():
    """Entry point for all uses of centinel"""

    args = parse_args()
    logging.basicConfig(filename=args.log_file,
                        format="%(levelname)s %(asctime)s: %(message)s",
                        level=logging.INFO)
    if args.create_conf_dir:
        if args.create_HMA:
            hmaDir = return_abs_path(args.create_conf_dir, "vpns")
            hma.create_config_files(hmaDir)
        # create the config files for the openvpn config files
        create_config_files(args.create_conf_dir)
    else:
        scan_vpns(args.directory, args.auth_file, args.crt_file,
                  args.exclude_list, args.shuffle_lists)
Exemplo n.º 3
0
        os.mkdir(data_dir)
        configuration.params['dirs']['data_dir'] = data_dir
        res_dir = os.path.join(home_dir, "results")
        os.mkdir(res_dir)
        configuration.params['dirs']['results_dir'] = res_dir

        log_file = os.path.join(home_dir, "centinel.log")
        configuration.params['log']['log_file'] = log_file
        login_file = os.path.join(home_dir, "login")
        configuration.params['server']['login_file'] = login_file
        configuration.params['user']['is_vpn'] = True

        conf_file = os.path.join(conf_dir, filename)
        configuration.write_out_config(conf_file)


if __name__ == "__main__":
    args = parse_args()
    logging.basicConfig(filename=args.log_file,
                        format="%(levelname)s %(asctime)s: %(message)s",
                        level=logging.INFO)
    if args.create_conf_dir:
        if args.create_HMA:
            hmaDir = return_abs_path(args.create_conf_dir, "vpns")
            hma.create_config_files(hmaDir)
        # create the config files for the openvpn config files
        create_config_files(args.create_conf_dir)
    else:
        scan_vpns(args.directory, args.auth_file, args.exclude_list,
                  args.shuffle_lists)
Exemplo n.º 4
0
def _run():
    """Entry point for all uses of centinel"""
    args = parse_args()

    # register signal handler
    signal.signal(signal.SIGTERM, signal_handler)
    signal.signal(signal.SIGINT, signal_handler)

    # set up logging
    log_formatter = logging.Formatter(
        "%(asctime)s %(filename)s(line %(lineno)d) "
        "%(levelname)s: %(message)s")
    root_logger = logging.getLogger()
    root_logger.setLevel(logging.INFO)
    console_handler = logging.StreamHandler()
    console_handler.setFormatter(log_formatter)
    root_logger.addHandler(console_handler)

    # add file handler if specified
    if args.log_file:
        file_handler = logging.FileHandler(args.log_file)
        file_handler.setFormatter(log_formatter)
        root_logger.addHandler(file_handler)

    # check vm_num and vm_index value
    if args.vm_num < 1:
        print "vm_num value cannot be negative!"
        return
    if args.vm_index < 1 or args.vm_index > args.vm_num:
        print "vm_index value cannot be negative or greater than vm_num!"
        return

    if args.create_conf_dir:
        if args.create_HMA:
            hma_dir = return_abs_path(args.create_conf_dir, 'vpns')
            hma.create_config_files(hma_dir)
        elif args.create_IPVANISH:
            ipvanish_dir = return_abs_path(args.create_conf_dir, 'vpns')
            ipvanish.create_config_files(ipvanish_dir)
        elif args.create_NORDVPN:
            nordvpn_dir = return_abs_path(args.create_conf_dir, 'vpns')
            nordvpn.create_config_files(nordvpn_dir)
        elif args.create_PUREVPN:
            purevpn_dir = return_abs_path(args.create_conf_dir, 'vpns')
            purevpn.create_config_files(purevpn_dir)
        elif args.create_VPNGATE:
            vpngate_dir = return_abs_path(args.create_conf_dir, 'vpns')
            vpngate.create_config_files(vpngate_dir)
        # create the config files for the openvpn config files
        create_config_files(args.create_conf_dir)
    else:
        # sanity check tls_auth and key_direction
        if (args.tls_auth is not None and args.key_direction is None) or \
                (args.tls_auth is None and args.key_direction is not None):
            logging.error("tls_auth and key_direction must be specified "
                          "together!")
            return

        scan_vpns(directory=args.directory,
                  auth_file=args.auth_file,
                  crt_file=args.crt_file,
                  tls_auth=args.tls_auth,
                  key_direction=args.key_direction,
                  exclude_list=args.exclude_list,
                  shuffle_lists=args.shuffle_lists,
                  vm_num=args.vm_num,
                  vm_index=args.vm_index,
                  reduce_vp=args.reduce_vp)
Exemplo n.º 5
0
        os.mkdir(data_dir)
        configuration.params['dirs']['data_dir'] = data_dir
        res_dir = os.path.join(home_dir, "results")
        os.mkdir(res_dir)
        configuration.params['dirs']['results_dir'] = res_dir

        log_file = os.path.join(home_dir, "centinel.log")
        configuration.params['log']['log_file'] = log_file
        login_file = os.path.join(home_dir, "login")
        configuration.params['server']['login_file'] = login_file
        configuration.params['user']['is_vpn'] = True

        conf_file = os.path.join(conf_dir, filename)
        configuration.write_out_config(conf_file)


if __name__ == "__main__":
    args = parse_args()

    logging.basicConfig(filename=args.log_file,
                        format="%(levelname)s %(asctime)s: %(message)s",
                        level=logging.INFO)
    if args.create_conf_dir:
        if args.create_HMA:
            hmaDir = return_abs_path(args.create_conf_dir, "vpns")
            hma.create_config_files(hmaDir)
        # create the config files for the openvpn config files
        create_config_files(args.create_conf_dir)
    else:
        scan_vpns(args.directory, args.auth_file)