nexxai / CryptoBlocker

A script to deploy File Server Resource Manager and associated scripts to block infected users
GNU General Public License v2.0
200 stars 73 forks source link

Return of notification creation to script #1

Closed cbaumhart closed 7 years ago

cbaumhart commented 7 years ago

Rather than message you on a forum, I've added changes myself along with global options to set one time at the start of the file, with the script updating itself through a scheduled task.

nexxai commented 7 years ago

When the script updates itself, where is it updating from? GitHub? Won't the fact that the email address placeholder is "admin@domain.com" right in the script be overwritten each time? Would it not be better to have a settings file that the script checks for, and if missing, prompts the user for the necessary info and writes it to, before continuing on?

I'm not great at PowerShell so I don't even know if this is possible, but I think it is?

cbaumhart commented 7 years ago

When the script updates itself, where is it updating from? GitHub?

[ Line 158], it downloads the "raw" script from your github (https://raw.githubusercontent.com/nexxai/CryptoBlocker/master/DeployCryptoBlocker.ps1) as a string, then writes that to a file (eventually).

Though it is a valid point. I should adjust it to make updating of the script optional, and instead just break out enough to refresh the template definitions from fsrm.experiant.ca. Updating the script itself is probably not a good idea because it'd be a potential security risk... Maybe instead do a comparison with the script installed and email the "email recipient" if an updated script is found -- can compare the scripts and evaluate that.

Won't the fact that the email address placeholder is "admin@domain.com" right in the script be overwritten eah time?

line 35 The first time through, the script will create a txt file with the email notification settings. Subsequent times, it will look for the txt file and use whatever values are in there instead of the defaults.

Would it not be better to have a settings file that the script checks for, and if missing, prompts the user for the necessary info and writes it to, before continuing on?

Yes.

I'm not great at PowerShell so I don't even know if this is possible, but I think it is?

It is. I'm making the mistake of writing this for myself, rather than for another person -- five months from now, would I be able to read and understand it. Prompting the user for email addresses and other things (SMTP server, etc) would be better form than just assuming everyone will understand that they need to modify the script before running it.

Let me run through this again tonight and see if I can write a little more smoothly on a few things 1) Prompt for notification settings 2) Check for SMTP setup 3) Create mini-script that will just update the template definitions 4) Create notification for script update -- add check onto 3 5) Improve layout of my additions