projectdiscovery / nuclei

Fast and customizable vulnerability scanner based on simple YAML based DSL.
https://docs.projectdiscovery.io/tools/nuclei
MIT License
19.94k stars 2.45k forks source link

Prevent accidental data loss by appending to existing results #5049

Open root4loot opened 5 months ago

root4loot commented 5 months ago

I recently reran a Nuclei scan by mistake right after finishing a lengthy two-day scan. Upon realizing this and hitting Control-C, it was already too late. The output files specified with -o and -je were cleared and so the results from my previous scan were lost. Edit: my bad for not using a database

Instead of wiping existing output files on execution, consider appending new scan results to them by default and avoid rescanning templates that have already generated results. This could also benefit users aiming to maintain consistent output across multiple scans. If that is not viable then consider delaying the clearing of output files until the first new result is ready to be written, rather than clearing them immediately. This will give users some time to cancel execution and prevent loss of data.

GeorginaReeder commented 5 months ago

Thanks for your enhancement request @root4loot - we'll take a look into this!

Mzack9999 commented 5 months ago

@root4loot there was a recent similar issue within katana about overwriting existing files. We came up with a solution similar to wget, so if a file exist (ex file.txt), the new one being created is named something like file.1.txt. Do you think this might work?

root4loot commented 5 months ago

@Mzack9999 sounds like a good approach. If it worked well for Katana, then I see no reason why it wouldn't work here. Unlike my suggestion, this would ensure consistency across all output formats as well.

Edit: The only thing I can think of is that some users might rely on automated jobs that expect the output files to match what was set in the flag. They would have to adjust their scripts accordingly, unless you introduce a flag to force overwrite, but in my opinion, I think that's a bit excessive.