Main menu

Automatically update targets in Nessus Security Center scan with AWS instances.

install python security center module
pip install pysecuritycenter

install aws boto3 python module
pip install boto3

import csv 
import boto3 
import securitycenter 
 
# Connect to EC2 
ec2 = boto3.resource('ec2','us-gov-west-1') 
 
# Get information for all running instances 
running_instances = ec2.instances.filter(Filters=[{ 
    'Name': 'instance-state-name', 
    'Values': ['running']}]) 
iplist=[] 
for instance in running_instances: 
    iplist.append(instance.private_ip_address) 
 
# Create iplist in string format 
iplist  = ','.join(map(str, iplist))  
 
if __name__ == '__main__': 
    # Get the needed login info from the user... 
    host = "nessus.yourdomain.com" 
    username = "your_user_name" 
    password = "Your_password" 
     
    # Log into the SecurityCenter environment and get the parsed data back... 
    sc = securitycenter.SecurityCenter5(host) 
    sc.login(username, password) 
 
  
# asset/12345 is the asset ID of the asset list you're trying to update 
#ip_list is the string you put the list of IPs you're wanting to place in the asset list 
resp = sc.patch('asset/42', json={'definedIPs': iplist})
FacebookTwitterGoogle+RSS