Exemple #1
0
 def __init__(self, host='192.168.74.128', port='8834'):
     self.host = host
     self.port = port
     self.headers = {"Content-type":"application/x-www-form-urlencoded",\
                     "Accept":"text/plain",\
                     "Referer": "https://10.0.0.7:8834/NessusClient.swf"}
     conn = connector()
     self.scan = Scan(conn)
     self.report = Report(conn)
Exemple #2
0
class Nessus:
    """define common scan methods"""
    def __init__(self, host='192.168.74.128', port='8834'):
        self.host = host
        self.port = port
        self.headers = {"Content-type":"application/x-www-form-urlencoded",\
                        "Accept":"text/plain",\
                        "Referer": "https://10.0.0.7:8834/NessusClient.swf"}
        conn = connector()
        self.scan = Scan(conn)
        self.report = Report(conn)

    def run(self, scan_name='pynessus test scan', target='10.0.0.9'):
        retvalue = self.scan.new(target, '-4', scan_name)
        self.monitor(retvalue['uuid'])
        self.download_report(retvalue['uuid'], 'pdf')
        print("\nfinished.")

    def monitor(self, uuid):
        """this method will only monitor the new scan with uuid"""        
        while True:
            time.sleep(2)
            host = self.report.hosts(uuid)
            if not host:
                continue;
            progress = int(host[0]["scanProgressCurrent"])*100/int(host[0]["scanProgressTotal"])
            print("progress:" + str(progress) + "%")
            if progress == 100:
                break

    def download_report(self, uuid, format):
        """this method will download report of scan with specified uuid"""
        chaptersList = self.report.chapter_list()        
        chapters = ';'.join(chaptersList['chapters'])        
        file = self.report.chapter(uuid, chapters, format)        
        self.report.fileXsltDownload(file)