Esempio n. 1
0
def test_deduplicate_hosts():
    login = os.getenv("NESSUS_USER")
    password = os.getenv("NESSUS_PASSWORD")
    url = "https://%s:%s" % (os.getenv("NESSUS_SERVER"),
                             os.getenv("NESSUS_PORT", "8834"))

    scan = nessrest.Scanner(url=url, login=login, password=password)

    hosts = [{'hostname': 'host1', 'host_id': '1'},
             {'hostname': 'host1', 'host_id': '1'},
             {'hostname': 'host2', 'host_id': '2'}]
    unique_hosts = scan._deduplicate_hosts(hosts=hosts)
    assert unique_hosts  == \
        [{'hostname': 'host2', 'host_id': '2'},
         {'hostname': 'host1', 'host_id': '1'}]

    assert scan._deduplicate_hosts(hosts=[]) == []
Esempio n. 2
0
    def __init__(self,
                 name,
                 scanner=None,
                 url="",
                 login="",
                 password="",
                 insecure="",
                 template=""):
        if scanner:
            self.scanner = scanner
        else:
            self.scanner = nessrest.Scanner(url=url,
                                            login=login,
                                            password=password,
                                            insecure=insecure)
        self.name = name
        self.scan_id = ""
        self.scanner_id = "1"
        self.folder_id = ""
        self.uuid = ""
        self.category = ""
        self.settings = {
            "launch": "ONETIME",
            "enabled": False,
            "launch_now": True,
            "text_targets": "",
            "file_targets": ""
        }
        self.audits = {}
        self.creds = {}
        self.uploads = []
        self.categories = {}

        self._cache = {}

        if template:
            self.set_scan_template(template)

        if self.scanner.scan_exists(name):
            self.get_scan_settings(self.scanner.scan_id)
Esempio n. 3
0
login = "******"
password = "******"

# Handle arguments
parser = argparse.ArgumentParser()
parser.add_argument('--target', required=True)
parser.add_argument('--policy', required=True)
parser.add_argument('--name', required=True)
parser.add_argument('--insecure', action="store_true")
parser.add_argument('--ca_bundle')
args = parser.parse_args()

# Log in
scan = ness6rest.Scanner(url=nessus_url,
                         login=login,
                         password=password,
                         insecure=args.insecure,
                         ca_bundle=args.ca_bundle)

# Set policy that should be used
scan.policy_set(name=args.policy)

# Set target and scan name
scan.scan_add(targets=args.target, name=args.name)

# Run scan

print "Starting scan now, UUID will follow:"
scan.scan_run_red()
##prints uuid to file so exporter can read it
with open('scanTest.txt', 'w') as file_:
#!/usr/bin/env python3

import ness6rest
import argparse

nessus_url = "https://localhost:8834"

parser = argparse.ArgumentParser()
parser.add_argument('--login', required=True)
parser.add_argument('--password', required=True)
args = parser.parse_args()

scan = ness6rest.Scanner(url=nessus_url,
                         login=args.login,
                         password=args.password,
                         insecure=True)

print(scan.scan_list())

scans = scan.scan_list()['scans']
for detail_scan in scans:
    print(scan.scan_details(detail_scan['name']))
Esempio n. 5
0
except KeyboardInterrupt:
    print("You pressed Ctrl+C")
    sys.exit()

print("-" * 70)
nlogin = input("Please enter your Nessus Username: "******"Please enter your password: "******"-" * 70)
print('\n')

# YOU dont have to hard code your policy i do
npolicy = "Your policy"

#Login to Nessus
nscan = ness6rest.Scanner(url=nessus_url,
                          login=nlogin,
                          password=npass,
                          insecure=True)

#Set policy for scan
nscan.policy_set(name=npolicy)

#Set Target for scan
nscan.scan_add(targets=remoteServer, name=nname)

#Run the Scan
nscan.scan_run()
print("-" * 70)
#Get the results of scan
nscan.scan_results()
results_one = nscan.scan_results()
evaldoc.write(results_one)