def init(args): config = args.config print(Back.BLACK + Fore.GREEN + """ starting program loaded for B1 battle droid """ + Back.BLACK + Fore.BLUE + Style.BRIGHT + """ ||/__'`. |//()'-.: |-.|| |o(o) |||\\\ .==._ |||(o)==::' `|T "" () |\\ ||\\ ()() ||// |// .'=`=. """) # parse config attack_range_config = Path(config) if attack_range_config.is_file(): print(Back.BLACK + Fore.GREEN + "attack_range is using config at path " + Style.BRIGHT + "{0}".format( attack_range_config)) configpath = str(attack_range_config) else: print("ERROR: attack_range failed to find a config file") sys.exit(1) # Parse config parser = CustomConfigParser() config = parser.load_conf(configpath) log = logger.setup_logging(config['log_path'], config['log_level']) log.info("INIT - attack_range v" + str(VERSION)) if config['cloud_provider'] == 'azure': os.environ["AZURE_SUBSCRIPTION_ID"] = config['azure_subscription_id'] if config['attack_range_password'] == 'Pl3ase-k1Ll-me:p': log.error('ERROR: please change attack_range_password in attack_range.conf') sys.exit(1) if config['cloud_provider'] == 'azure' and config['zeek_sensor'] == '1': log.error('ERROR: zeek sensor only available for aws in the moment. Plase change zeek_sensor to 0 and try again.') sys.exit(1) if config['cloud_provider'] == 'aws' and config['windows_client'] == '1': log.error('ERROR: windows client is only support for Azure.') sys.exit(1) return TerraformController(config, log), config, log
def init(args): config = args.config print(""" starting program loaded for B1 battle droid .-~~~-. .- ~ ~-( )_ _ / ~ -. | Cloud Attack Range \ \ .' ~- . _____________ . -~ ||/__'`. |//()'-.: |-.|| |o(o) |||\\\ .==._ |||(o)==::' `|T "" () |\\ ||\\ ()() ||// |// .'=`=. """) # parse config attack_range_config = Path(config) if attack_range_config.is_file(): print("attack_range is using config at path {0}".format( attack_range_config)) configpath = str(attack_range_config) else: print("ERROR: attack_range failed to find a config file") sys.exit(1) # Parse config parser = CustomConfigParser() config = parser.load_conf(configpath) log = logger.setup_logging(config['log_path'], config['log_level']) log.info("INIT - attack_range v" + str(VERSION)) # if ARG_VERSION: # log.info("version: {0}".format(VERSION)) # sys.exit(0) return TerraformController(config, log), config, log
if action == "" and not list_machines: log.error('ERROR: flag --action is needed.') sys.exit(1) # lets give CLI priority over config file for pre-configured techniques if simulation_techniques: pass else: simulation_techniques = config['art_run_techniques'] if not simulation_atomics: simulation_atomics = 'no' # default to terraform controller = TerraformController(config, log) if list_machines: controller.list_machines() sys.exit(0) if action == 'build': controller.build() if action == 'destroy': controller.destroy() if action == 'stop': controller.stop() if action == 'resume':
log.error( 'ERROR: cloud_attack_range needs a value in cloudtrail_bucket, a s3_bucket in the same region of your attack_range to store the cloudtrail logs.' ) sys.exit(1) # lets give CLI priority over config file for pre-configured techniques if simulation_techniques: pass else: simulation_techniques = config['art_run_techniques'] if not simulation_atomics: simulation_atomics = 'no' if mode == 'terraform': controller = TerraformController(config, log, packer_amis) elif mode == 'vagrant': controller = VagrantController(config, log) elif mode == 'packer': controller = PackerController(config, log) if action == 'build_amis': controller.build_amis() elif action == 'destroy_amis': controller.destroy_amis() if list_machines: controller.list_machines() sys.exit(0) if action == 'build': controller.build()
sys.exit(1) if mode == 'packer' and action != 'build_amis' and action != 'destroy_amis': log.error( 'ERROR: packer can only be used with action build_amis and destroy_amis. To build attack range use mode terraform or vagrant.' ) sys.exit(1) # lets give CLI priority over config file for pre-configured techniques if simulation_techniques: pass else: simulation_techniques = config['art_run_techniques'] if mode == 'terraform': controller = TerraformController(config, log, packer_amis) elif mode == 'vagrant': controller = VagrantController(config, log) elif mode == 'packer': controller = PackerController(config, log) if action == 'build_amis': controller.build_amis() elif action == 'destroy_amis': controller.destroy_amis() if list_machines: controller.list_machines() sys.exit(0) if list_searches: controller.list_searches()
if action == "" and not list_machines: log.error('ERROR: flag --action is needed.') sys.exit(1) if config['attack_range_password'] == 'I-l1ke-Attack-Range!': log.error( 'ERROR: please change attack_range_password in attack_range.conf') sys.exit(1) if len(config['key_name']) > 20: log.error( 'ERROR: your key_name is too long. Please create a shorter key_name. Maximum number of characters are 20.' ) sys.exit(1) controller = TerraformController(config, log) if list_machines: controller.list_machines() sys.exit(0) if action == 'build': controller.build() if action == 'destroy': controller.destroy() if action == 'stop': controller.stop() if action == 'resume':