From 6286e901a00a771f34ed2b75071b90e63c7e763f Mon Sep 17 00:00:00 2001 From: Zack T Date: Tue, 29 Aug 2017 11:02:28 -0700 Subject: [PATCH] v1.0 = First Production Version + Script is configured to disable SMBv1 --- Jamf Pro/config_SMBProtocol.sh | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Jamf Pro/config_SMBProtocol.sh diff --git a/Jamf Pro/config_SMBProtocol.sh b/Jamf Pro/config_SMBProtocol.sh new file mode 100644 index 0000000..e06daaf --- /dev/null +++ b/Jamf Pro/config_SMBProtocol.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +################################################################################################### +# Script Name: config_SMBProtocol.sh +# By: Zack Thompson / Created: 7/3/2017 +# Version: 1.0 / Updated: 7/3/2017 / By: ZT +# +# Description: This script configures the SMB Protocol on a Mac. Configured to disable SMBv1. +# +################################################################################################### + +echo "Configuring the SMB Protocols allowed on this Mac..." + +# Check if file exists. +if [[ -e /etc/nsmb.conf ]]; then + + # If it exists, check if the SMB Protocol is already set. + nsmbSMBProtocol=$(cat /etc/nsmb.conf | /usr/bin/grep "sprotocol_vers_map") + + # Check if Protocol is currently configured. + if [[ -n $nsmbSMBProtocol ]]; then + # If it is currently configured... + + # Backup file. + mv /etc/nsmb.conf /etc/nsmb.conf.orig + # Remove configuration from original file and redirect the output to proper file. + awk '!/sprotocol_vers_map/' /etc/nsmb.conf.orig > /etc/nsmb.conf + fi + + # If/once the Protocol is not configured.... + + # Check if default section is defined. + nsmbContents=$(cat /etc/nsmb.conf | /usr/bin/grep "default") + + # Does default section exist? + if [[ $nsmbContents == "[default]" ]]; then + # If it is empty... + + # Backup file. + mv /etc/nsmb.conf /etc/nsmb.conf.bak + # Insert configuration into contents of backup file and redirect the output to proper file. + awk '/default/ {print; print "sprotocol_vers_map=6";next}1' /etc/nsmb.conf.bak > /etc/nsmb.conf + + else + # If the defaults section does not exist... + + # Insert the defaults section and the configuration. + echo '[default]' >> /etc/nsmb.conf + echo 'sprotocol_vers_map=6' >> /etc/nsmb.conf + fi +else + # If the file does not exist... + + # Create the file. + touch /etc/nsmb.conf + + # Insert the defaults section and the configuration. + echo '[default]' >> /etc/nsmb.conf + echo 'sprotocol_vers_map=6' >> /etc/nsmb.conf +fi + +echo "Configuration Complete!" + +exit 0 \ No newline at end of file