@@ -0,0 +1,2155 @@
+# Parse map XML for live but not scannable IPs.%0A%0Aimport argparse%0Aimport datetime%0Afrom collections import defaultdict%0Aimport logging%0Aimport os%0Aimport qualysapi%0Afrom lxml import objectify%0A%0A#%0A#  Begin%0A#%0A# Declare the command line flags/options we want to allow.%0Aparser = argparse.ArgumentParser(description = 'Parse QualysGuard VM map XML for live but not scannable IPs.')%0Aparser.add_argument('-v', '--debug', action = 'store_true',%0A                    help = 'Outputs additional information to log.')%0Aparser.add_argument('--config',%0A                    help = 'Configuration for Qualys connector.')%0A# Parse arguments.%0Aargs = parser.parse_args()# Create log directory.%0A# Validate input.%0Aif not (args.map or %5C%0A        args.subscribe_from_csv):%0A    parser.print_help()%0A    exit()%0A# Create log directory.%0APATH_LOG = 'log'%0Aif not os.path.exists(PATH_LOG):%0A    os.makedirs(PATH_LOG)%0A# Set log options.%0ALOG_FILENAME = '%25s/%25s-%25s.log' %25 (PATH_LOG,%0A                                __file__,%0A                                datetime.datetime.now().strftime('%25Y-%25m-%25d.%25H-%25M-%25S'))%0A# Make a global logging object.%0Alogger = logging.getLogger()%0Alogger.setLevel(logging.DEBUG)%0A# This handler writes everything to a file.%0Alogger_file = logging.FileHandler(LOG_FILENAME)%0Alogger_file.setFormatter(logging.Formatter(%22%25(asctime)s %25(name)-12s %25(levelname)s %25(funcName)s %25(lineno)d %25(message)s%22))%0Alogger_file.setLevel(logging.INFO)%0Aif c_args.verbose:%0A    logger_file.setLevel(logging.DEBUG)%0Alogger.addHandler(logger_file)%0A# This handler prints to screen.%0Alogger_console = logging.StreamHandler(sys.stdout)%0Alogger_console.setLevel(logging.ERROR)%0Alogger.addHandler(logger_console)%0A#%0A# Read in XML map.%0Awith open(args.map) as xml_file:%0A    xml_output = xml_file.read()%0Atree = objectify.fromstring(xml_output)%0A# Find live, not scannable IPs.%0Acount = 0%0Asubscribe_me = set()%0Aif c_args.config:%0A    qgc = qualysapi.connect(c_args.config)%0Aelse:%0A    qgc = qualysapi.connect()%0A# Combine IPs to comma-delimited string.%0Aformatted_ips_to_subscribe = ','.join(subscribe_me)%0A# Subscribe IPs.%0Aqgc = qualysapi.connect('asset_ip.php',%7B'action': 'add', 'host_ips': formatted_ips_to_subscribe%7D)%0Aexit()%0A

Create qualysguard_add_assets.py