我写了这个脚本与nessus互动并告诉我在nessus列表中有哪些报告:
#!/usr/bin/python
from NessusXMLRPC import Scanner
import sys
x = Scanner("localhost", "8834", login="root", password="password123")
report = str(x.reportList())
print report
x.logout
我现在想要输出:
root@bt:~/NessusXMLRPC-0.21# ./reportfornessus.py
[{'status': 'running', 'readableName': 'SecondScan', 'name': '76c25e9b-8280-5310-23e8-f9873255c5a6288ff86b03b2cdb6', 'timestamp': '1328641639'}, {'status': 'running', 'readableName': 'Third Scan', 'name': '01b2a026-44d3-574c-08e3-e6c97e3f8e21c7c00ec9cb71a7cd', 'timestamp': '1328641704'}]
并解析它,寻找我特别传递的'readableName',然后返回该扫描的'status'。
答案 0 :(得分:4)
scn = Scanner("localhost", "8834", login="root", password="password123")
reports = scn.reportList()
for r in reports:
if r["readableName"] == SOME_NAME:
print r["status"]