Is there any api by which I can download all the info of report schedule? for example distribution list, target IPs/asset groups etc?
Yep, Busby is correct, check out "List scan schedules" /api/2.0/fo/schedule/scan/?action=list. I also created a postman collection of this use case for you to reference (Use API to Download all Scheduled Report Info (Community Example) -- Postman Example ). If you are not familiar with Postman, please check out the tutorial on our community.
I do not know any scripts for this, but there is a possibility if you are not aware of. You can download the schedules/Asset groups as follows.
VM > Reports > Schedules > select one scheduled report > click New > Download
For Asset groups/DL's:
VM > Assets > Asset groups > Select one asset group > click New > Download.
Hope this helps.
However, I am also interested to know if there is any API that do all this stuff automatically.
In a word yes. if you refer to the documentation here: Documentation | Qualys, Inc.
You need to refer to the Scheduled Reports List roughly on page 425 depending on version; need the qualys-api-vmpc guide. If you need help let me know.
The issue with this api: " /api/2.0/fo/schedule/scan/?action=list" is I only get only information like report title, active/inactive, report template etc. Along with I need the information like target IP/ asset groups and report distribution list etc.
I noticed this as well. May not be what you want to hear but if you want to get to the actual targets; which I may need to do at some point; is determine what the target set of the scan is; i.e. is it an Asset Group or set of TAGS.
Asset Groups are easy to enumerate the Asset Groups involved in the scan and then pull the ranges/ips in each of the groups referenced in the scan schedule; probably de-duplicate them depends if you want all the IPs or if you want them in the groups.
Tags are not much different in that you would need to enumerate the TAGS; however that is where the similarity ends. Depends on your case. I have some TAGS defined as a Network Range; Those are relatively easy to get the range. But if you have something like a rule where the TAG is Groovy or Asset Search then you would need to get the set of IPs that TAG is applying too at the time your script runs. This poses a consistency issue as the tags are dynamically evaluated.
My suggestion would be to pull the scans that ran after the schedule and you should be able to pull the TARGET IP from the scans. Now you would have a schedule list of something like; scan A occurs every Monday. Then you have the list of scans and their respective targets from the previous Monday or whatever the schedule is.
The main thing is that while the schedule to scan is rather constant it is unlikely for many cases for the targets of the scan to remain very constant depending on your individual setup this can be quite dynamic.
Retrieving data ...