# Connect to the server and login (server, session) = nCircleAPI._login(host, user, password) ScanConfigurations = [] for dp in deviceProfilers: params = {} params['query'] = "active = \'true\' AND dp = \'%s\'" % (dp) ScanConfiguration = server.call(session, 'class.ScanConfiguration', 'search', params) if ScanConfiguration: for ScanConfigurationItem in ScanConfiguration: ScanConfigurations.append(ScanConfigurationItem) if ScanConfigurations: timestamp = str(time.time()) for ScanConfigurationItem in ScanConfigurations: scanProfile = server.call(session, ScanConfigurationItem, 'getAttributes', {}) scanProfileDetail = nCircleAPI._getItem(server, session, scanList, scanProfile['scanProfile']) networkDetail = nCircleAPI._getItem(server, session, networkList, scanProfile['network']) print '{"timestamp": "' + timestamp + '", ', nCircleAPI._printJson(scanProfile) print ', "scanProfile" : ', scanProfileDetail['profile'] = json.dumps(xmltodict.parse(scanProfileDetail['profile'])) #scanProfileDetail['profile'] = str(data).replace('\'','"') #data = str(data).replace('"{','{') #data = str(data).replace('}"','}') #scanProfileDetail['profile'] = data #data = nCircleAPI._printJson(scanProfileDetail) scanProfileDetail = str(scanProfileDetail).replace('\'','"') scanProfileDetail = str(scanProfileDetail).replace('"{','{')
print "\thint: use min value if you want to fetch all audit records" print "\thint: use max value if you want to fetch only new audit records" print "" results = server.call(session, 'class.Audit', 'search', {'query':'id>0'}) if results: print 'getAuditDetails.py: IDs in range from ' + results[0].rsplit('.')[1] + ' to ' + results[-1].rsplit('.')[1] print "\tupdate variable called blg in getAuditDetails.py by number in this range" print "\thint: use min value if you want to fetch all audit scan records" print "\thint: use max value if you want to fech only new audit scan records" results = server.call(session, 'class.DP', 'search', {'query':'id>0'}) if results: print 'Device profiler setup' for deviceProfiler in results: deviceProfilerDetail = nCircleAPI._getItem(server, session, dpList, deviceProfiler) for key in ['name', 'IPAddress']: print key + ": " + str(deviceProfilerDetail[key]) toInclude = "n" toInclude = raw_input("Do you want to include this device profiler into the app? y/n: [default: n]: ") if toInclude is "y" : dpDict.append(deviceProfiler) print "" print 'getActiveScans.py, getAuditDetails.py, getDpStats.py: update variable called deviceProfilers by this string' print dpDict print nCircleAPI._logout(server, session) except xmlrpclib.Fault, fault:
# Vulnerabilities for particular hosts are stored under VulnResult IDs vulnResultIDs = server.call(session, 'class.VulnResult', 'search', params) if vulnResultIDs: for vulnResultID in vulnResultIDs: vulnResult = {} vulnDetail = {} hostDetail = {} osDetail = {} vulnResult = server.call(session, vulnResultID, 'getAttributes', {}) # Get additional details that are being referenced in the vulnResult vulnDetail = nCircleAPI._getItem(server, session, vulnList, vulnResult['vuln']) hostDetail = nCircleAPI._getItem(server, session, hostList, vulnResult['host']) osDetail = nCircleAPI._getItem(server, session, osList, hostDetail['os']) print "{", nCircleAPI._printJson(vulnResult) print ', "VulnDetail" : {', nCircleAPI._printJson(vulnDetail) print "},", print '"hostDetail" : {', nCircleAPI._printJson(hostDetail) print "},", print '"osDetail" : {', nCircleAPI._printJson(osDetail)