Загрузка пользовательского отчета о сканировании Nessus с помощью Nessus APIPython

Программы на Python
Ответить
Anonymous
 Загрузка пользовательского отчета о сканировании Nessus с помощью Nessus API

Сообщение Anonymous »

У меня есть код Python, который успешно загружает отчет о сканировании Nessus в формате csv, но мне нужно добавить в загруженный отчет несколько дополнительных полей. Я включаю параметры в полезные данные запроса, чтобы включить некоторые поля, но загружаемое сканирование не включает эти поля.
Я пробовал изменить значение параметров reportContents на фактические логические типы с помощью ключевого слова True.
Кроме того, я изменил формат на pdf, и он экспортирует файл PDF, который представляет собой просто титульную страницу и страницу с пустым оглавлением.
Загруженный файл CSV имеет данные в нем, но включает только заголовки по умолчанию (т. е.):
Plugin ID,CVE,CVSS v2.0 Base Score,Risk,Host,Protocol,Port,Name,Synopsis,Description,Solution,See Also,Plugin Output

Необработанный вывод запроса POST выглядит так:
POST https://localhost:8834/scans//export
X-ApiKeys: accessKey=accessKey;secretKey=secretKey
Content-Type: application/x-www-form-urlencoded
Content-Length: 122

format=csv&reportContents.vulnerabilitySections.exploitable_with=true&reportContents.vulnerabilitySections.references=true

def download_scan(scan_num):

# Post an export request
headers = {
'X-ApiKeys': 'accessKey=accessKey;secretKey=secretKey',
'Content-Type': 'application/x-www-form-urlencoded'
}

data = {
'format': 'csv',
'reportContents.vulnerabilitySections.exploitable_with': 'true',
'reportContents.vulnerabilitySections.references': 'true'
}

res = requests.post(url + '/scans/{id_num}/export'.format(id_num = scan_num), data=data, verify=False, headers=headers)

if res.status_code == 200:
export = json.loads(res.text)
file_id = export.get('file')

# Continually check the scan status until the status is ready
while True:
# Check file status
res = requests.get(url + '/scans/{id_num}/export/{file_num}/status'.format(id_num = scan_num, file_num = file_id), verify=False, headers=headers)

if res.status_code == 200:
status = json.loads(res.text)['status']
if status == 'ready':
break

# Download the scan
res = requests.get(url + '/scans/{scan_num}/export/{file_num}/download'.format(scan_num = scan_num, file_num = file_id), verify=False, headers=headers)

# If the scan is successfully downloaded, get the attachment file
if res.status_code == 200:
attachment = res.content
print("Scan downloaded!!!")
else:
raise Exception("Download request failed with status code: " + str(res))

return attachment

def main():

# Download the scan based on the scan_id. I have a helper function that returns the id that I am omitting here
try:
scan = download_scan(scan_id)
except Exception as e:
print(e)
quit()

with open("scan.csv", "wb") as f:
f.write(scan)
f.close()

if __name__ == "__main__":
main()


Подробнее здесь: https://stackoverflow.com/questions/689 ... nessus-api
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»