scipag / HardeningKitty

HardeningKitty - Checks and hardens your Windows configuration
MIT License
1.33k stars 166 forks source link

Lazy feature #46

Closed tadghh closed 11 months ago

tadghh commented 11 months ago

A non existant folder isnt created :( perhaps this could be done automatically incase people automate this script. Ex Sys admin wasnt paying attention when running this across a network, uh oh the folder I gave Kitty was the wrong path and now I lost the default settings image

0x6d69636b commented 11 months ago

What parameters did you use to start HardeningKitty? Is it possible to run it without any file parameter? If so, HardeningKitty will create a file in the same directory where it is started from

tadghh commented 11 months ago

What parameters did you use to start HardeningKitty? Is it possible to run it without any file parameter? If so, HardeningKitty will create a file in the same directory where it is started from

Iirc I gave it the logging one but the path to the log file didnt exist (no "tmp" folder on the root of the c drive)

0x6d69636b commented 11 months ago

If you only use -Log without -LogFile, HardeningKitty will generate the file name for you and save the file it in the current folder. I'm uncertain what the default behaviour should be: report that the path does not exist, create a temporary file, create all non-existent folders, or... ;-)

tadghh commented 11 months ago

Considering context of Kitty and accidentally passing an incorrect path and not getting a backup / log could leave a system in an undesirable state. Maybe stop the execution if the passed path doesnt exist or create the path.

0x6d69636b commented 11 months ago

I added checks for log, report, and backup file path, HardeningKitty stops if the path does not exist: https://github.com/0x6d69636b/windows_hardening/commit/f6079cfc6a691eb9de0c3889ea3d7d71ff51a34d

tadghh commented 11 months ago

When are we running this check, I pulled the recent version and havent triggered your fix yet, should'nt we make sure the log file can be created at the path before proceeding?

0x6d69636b commented 11 months ago

I don't like tools or scripts that create folders on my systems, so I prefer to stop HardeningKitty rather than create directories. On the one hand, I understand your use case, but on the other hand, if the log file path has a typo in it or is otherwise wrong, it would be uncool to create the full path

tadghh commented 11 months ago

I don't like tools or scripts that create folders on my systems, so I prefer to stop HardeningKitty rather than create directories. On the one hand, I understand your use case, but on the other hand, if the log file path has a typo in it or is otherwise wrong, it would be uncool to create the full path

Yeah sort of like idempotence. Sorry just wanted to clarify I downloaded the change you made and I still ran into the issue, below is the command im using to test. Shouldnt we make sure that if Kitty is to write something to the disk as requested by the user, we should make sure the path is valid before checking the system with kitty itself.

We would be wasting resources checking the whole system just to tell the user at the end that we cant write to the non existant directory.

  1. If user provides a directory, make sure the path is valid
  2. Now check the system with kitty

And here is the test command im using

Invoke-HardeningKitty -Mode Config -Report -ReportFile C:\tmp\my_hardeningkitty_report.csv
0x6d69636b commented 11 months ago

Agreed. The check takes place during the initialisation phase, and if the path does not exist, execution will be aborted. In your case, you should only receive the message "The path to your report file does not exist.". Can you make sure you're using the latest version from the dev repo?

tadghh commented 11 months ago

Agreed. The check takes place during the initialisation phase, and if the path does not exist, execution will be aborted. In your case, you should only receive the message "The path to your report file does not exist.". Can you make sure you're using the latest version from the dev repo?

Dev repo?

0x6d69636b commented 11 months ago

This is the prod repo, the dev repo is https://github.com/0x6d69636b/windows_hardening

tadghh commented 11 months ago

Yup looking good! My bad haha.

0x6d69636b commented 11 months ago

Thank you for the update 👍