├── Casper Asset Tag
├── CasperAssetTag.sh
└── LICENSE
├── Create Missing Hidden Home Folder
└── Admin_Home_Folder_Creator.py
├── Critical Update Checker
├── LICENSE
├── Update_Status.sh
└── Update_enabler.sh
├── Display Serial Identifier
└── display_serial.py
├── IPv6 Checker
├── LICENSE
└── ipv6_Checker.py
├── JSS Users Cleanup
├── jss_user_Cleanup.py
└── setup.py
├── LICENSE
├── Local Admin account
├── LICENSE
└── localadmin.sh
├── Mac Model
└── mac_model_identifier.sh
├── NTP Vulnerability Check
├── LICENSE
└── NTPcheck.py
├── README.md
├── SSH Checker
├── LICENSE
├── ssh_enabler.sh
└── ssh_status.sh
├── ScreenSaver Settings
├── LICENSE
├── Screensaver_lock.sh
└── screensaver_status.sh
├── Software Update Prompt
├── LICENSE
└── softwareupdatehelper.sh
├── Sophos Removal
├── LICENSE
└── sophos_removal.py
└── Virtual Machine Identifier
└── vm_os_checker.py
/Casper Asset Tag/CasperAssetTag.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Written by Quam Sodji
3 | #Copyright 2014 Quam Sodji
4 |
5 | # Script will capture the assigned ARDComputerField (Field 4) in DS and set it as Asset Tag in Casper
6 |
7 | asset=$(defaults read /Library/Preferences/com.apple.RemoteDesktop Text4)
8 |
9 | sudo jamf recon -assetTag $asset
10 |
11 | exit 0
12 |
--------------------------------------------------------------------------------
/Casper Asset Tag/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Create Missing Hidden Home Folder/Admin_Home_Folder_Creator.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #Script to fix Local Admin account missing a Home folder
3 | #Quam Sodji 2015
4 |
5 | import os
6 |
7 | if not os.path.exists("/var/administrator"):
8 | os.makedirs("/var/administrator")
9 | os.system("mkdir /var/administrator/{Desktop,Documents,Downloads,Library,Music,Pictures,Public,Movies}")
10 | os.system("chown -R administrator:staff /var/administrator")
11 | print "Home folder created"
12 | else:
13 | print "Home folder exists"
14 |
15 |
--------------------------------------------------------------------------------
/Critical Update Checker/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Critical Update Checker/Update_Status.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #Script to verify the status of Auto Updates
3 | #to ensure Critical and Security updates are applied
4 | #By Quam Sodji Copyright 2015
5 |
6 | ### Check for schedule, critical and config settings
7 | schedule_status=$(softwareupdate --schedule)
8 | critical_status=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate CriticalUpdateInstall 2>/dev/null)
9 | config_status=$(defaults read /Library/Preferences/com.apple.SoftwareUpdate ConfigDataInstall 2>/dev/null)
10 | run_config=$(softwareupdate --background-critical)
11 |
12 | ### The expected settings for schedule, critical and config
13 | schedule_on="Automatic check is on"
14 | critical_on="1"
15 | config_on="1"
16 |
17 |
18 | if [ "$schedule_status" == "$schedule_on" ] && [ "$critical_status" == "$critical_on" ] && [ "$config_status" == "$config_on" ]; then
19 |
20 | result="Enabled"
21 | else
22 | result="Disabled"
23 | fi
24 |
25 | echo "$result"
26 |
27 |
--------------------------------------------------------------------------------
/Critical Update Checker/Update_enabler.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #Enable updates
3 | #Enable critical updates
4 | #Quam Sodji Copyright 2015
5 |
6 | defaults write /Library/Preferences/com.apple.SoftwareUpdate CriticalUpdateInstall -bool yes
7 | defaults write /Library/Preferences/com.apple.SoftwareUpdate ConfigDataInstall -bool yes
8 | schedule=$(softwareupdate --schedule on)
9 | run_config=$(softwareupdate --background-critical)
10 |
11 | exit 0
12 |
--------------------------------------------------------------------------------
/Display Serial Identifier/display_serial.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # Quam Sodji Copyright 2015
3 | # Extension Attribute to retrive attached Display serial numbers if any
4 | # Only applicable to monitors connected via HDMI, Thunderbolt or DVI
5 |
6 | import subprocess
7 |
8 | display_profile = subprocess.check_output(["system_profiler SPDisplaysDataType | awk '/Serial/ {print $4}'"],shell=True)
9 | display_serial = display_profile.strip()
10 | serials = display_serial.split("\n")
11 | serials = filter(None,serials)
12 | size = len(serials)
13 | results = []
14 |
15 | if not serials:
16 | print "N/A"
17 |
18 | else:
19 | t = 1
20 | while t != size + 1:
21 | for i in serials:
22 | form = "%i:%s"%(t,i)
23 | results.append(form)
24 | t += 1
25 |
26 | recon_res = ('\n').join(results)
27 | print "%s"%recon_res
28 |
29 |
--------------------------------------------------------------------------------
/IPv6 Checker/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/IPv6 Checker/ipv6_Checker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 |
3 | #Copyright 2014 Quam Sodji
4 |
5 | import subprocess
6 |
7 | def getinfo(hardware): #Return network info on select interface
8 | info = subprocess.check_output(["networksetup", "-getinfo", hardware])
9 | return info
10 |
11 | wireless = ["Airport", "Wi-Fi"] #The two type of interfaces that refers to wireless
12 |
13 | list_network = subprocess.check_output(["networksetup", "-listallnetworkservices"])
14 | list_network = list_network.split('\n')
15 |
16 | for device in wireless:
17 | if device in list_network:
18 | response = getinfo(device)
19 | response_check = response.split("\n")
20 | if "IPv6: Off" not in response_check:
21 | check = subprocess.check_output(["networksetup", "-setv6off", device])
22 | Status = "Off"
23 | else:
24 | for setting in response_check:
25 | if setting.startswith("IPv6:"):
26 | if setting != "IPv6: Off":
27 | Status = setting
28 | else:
29 | Status = "Off"
30 | else:
31 | Status = "No wireless interfaces configured"
32 | continue
33 |
34 |
35 | print "%s"%Status
36 |
--------------------------------------------------------------------------------
/JSS Users Cleanup/jss_user_Cleanup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #Quam Sodji 2015
3 | #Script for cleaning up JSS of empty users (users not associated with a computer)
4 | #Script is using python-jss to access the JSS via the REST API and Kn/Slack
5 | #https://pypi.python.org/pypi/python-jss/0.5.9
6 | #https://github.com/kn/slack
7 | #Load script onto JSS and setup with a once a week cron job
8 |
9 | import jss
10 | import sys
11 | import smtplib
12 | import slack
13 | import slack.chat
14 |
15 | ######### EMAIL SETTINGS #######
16 |
17 | sender = 'from email goes here'
18 | receivers = ['send to emails go here'] #You can have multiple emails
19 | smtp_server = smtplib.SMTP('smtp server url','smtp port') #smtp server & port
20 |
21 | ######### SLACK SETTINGS #######
22 | slack.api_token = 'slack-token'
23 | slack_channel = ['slack channel'] #Supports multiple channels
24 |
25 | ####################################
26 | ## JSS URL, USERNAME & PASSWORD ##
27 |
28 | gree_jss = jss.JSS(
29 | url='https://your_jss_url:8443',
30 | user='jss_username',
31 | password='jss_password') #JSS account should be read Only on Computers,
32 | #Mobile Device and Read 7 Delete on Users
33 |
34 | #######################################
35 |
36 | def email_me(): #Send email
37 | try:
38 | smtp_server.sendmail(sender, receivers, message)
39 | print "Email was sent successfully"
40 | except smtplib.SMTPException:
41 | print "Error: unable to send email"
42 |
43 | def slack_me(): #use Slack
44 | for channel in slack_channel:
45 | slack.chat.post_message(channel, message, username='casper')
46 |
47 | #############################################
48 |
49 | qualifier = []
50 | id_to_remove = []
51 | jss_names = []
52 | removed_names = []
53 |
54 | #Pull a list of all the users in the JSS
55 | registered_users = str(gree_jss.User())
56 | found_users = registered_users.split('\n')
57 | for assigned_users in found_users:
58 | if "name" in assigned_users:
59 | qualifier.append(assigned_users)
60 | for username in qualifier:
61 | username = username[7:]
62 | jss_names.append(username)
63 |
64 | #Find the users who do not have a computer assigned to them
65 | for ind in jss_names:
66 | struct = gree_jss.User(ind)
67 | try:
68 | a = struct.find('links/computers/computer/name').text
69 | pass
70 | except AttributeError:
71 | id_to_remove.append(ind)
72 | full_name = ind.replace("."," ")
73 | removed_names.append(full_name)
74 |
75 | #Remove found users from the JSS
76 | if id_to_remove == []:
77 | print "No user found!"
78 | sys.exit(0)
79 | else:
80 | user_count = len(id_to_remove)
81 | print "Found %i users without computers."%user_count
82 | for user_to_remove in id_to_remove:
83 | remove_user = gree_jss.User(user_to_remove)
84 | remove_user.delete()
85 | print "Users deleted: %i"%user_count
86 | #Send email with removed users list
87 | removed_names = '\n'.join(removed_names)
88 | message = "Removed Users:\n %s"%removed_names
89 |
90 | #email_me() #Uncomment for email
91 | #slack_me() #Uncomment for slack
92 |
93 | #You can uncomment both if you want both
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/JSS Users Cleanup/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #Quam Sodji 2015
3 | #Setup script to install the needed python modules
4 | #Installs kn/Slack and python-jss modules
5 | #We assume you have Git installed.......
6 | import subprocess
7 | import os
8 | import sys
9 | import shutil
10 |
11 | clone_jss = subprocess.check_output(['git','clone','git://github.com/sheagcraig/python-jss.git'])
12 | clone_slack = subprocess.check_output(['git','clone','git://github.com/kn/slack.git'])
13 | path = os.path.dirname(os.path.realpath(__file__))
14 |
15 | #Installing Slack
16 | print "Installing Slack"
17 | slack_folder = os.chdir(path + '/slack')
18 | install_slack = subprocess.check_output(['python','setup.py','install'])
19 | print "slack module installed"
20 | #Installing Python JSS
21 | print "Installing Python JSS"
22 | jss_folder = os.chdir(path + '/python-jss')
23 | install_jss = subprocess.check_output(['python','setup.py','install'])
24 | print "python-jss module installed"
25 | #Cleaning up
26 | print "Cleaning up"
27 | change_location = os.chdir(path)
28 | remove_slack_clone = shutil.rmtree(path + '/slack')
29 | remove_jss_clone = shutil.rmtree(path + '/python-jss')
30 | print "Done."
31 | sys.exit(0)
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Local Admin account/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Local Admin account/localadmin.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/bash
2 | #Create a localadmin via script
3 | #Copyright by Quam Sodji 2014
4 | dscl . create /Users/administrator
5 | dscl . create /Users/administrator UserShell /bin/bash
6 | dscl . create /Users/administrator RealName "administrator"
7 | dscl . create /Users/administrator UniqueID 503
8 | dscl . create /Users/administrator PrimaryGroupID 1000
9 | dscl . create /Users/administrator NFSHomeDirectory /Local/Users/administrator
10 | dscl . passwd /Users/administrator PASSWORD
11 | dscl . append /Groups/admin GroupMembership administrator
12 |
--------------------------------------------------------------------------------
/Mac Model/mac_model_identifier.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #Quam Sodji 2014
3 | # This script will return the correct Mac model
4 |
5 | Last4Ser=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}' | tail -c 5)
6 | Last3Ser=$(ioreg -rd1 -c IOPlatformExpertDevice | awk -F'"' '/IOPlatformSerialNumber/{print $4}' | tail -c 4)
7 |
8 | FullModelName=$(curl -s -o - "http://support-sp.apple.com/sp/product?cc=${Last4Ser}&lang=en_US" xpath //root/configCode[1] 2>&1 | awk -F'|' '{print $2}' | sed '/^$/d')
9 |
10 | if [[ "$FullModelName" == "" ]]; then
11 | FullModelName=$(curl -s -o - "http://support-sp.apple.com/sp/product?cc=${Last3Ser}&lang=en_US" xpath //root/configCode[1] 2>&1 | awk -F'|' '{print $2}' | sed '/^$/d')
12 | fi
13 |
14 | echo "$FullModelName"
--------------------------------------------------------------------------------
/NTP Vulnerability Check/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NTP Vulnerability Check/NTPcheck.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #Script written by Quam Sodji
3 | #Copyright 2014 Quam Sodji
4 | #Script checks for NTP vulnerability patch via casper
5 |
6 | import subprocess
7 | import platform
8 |
9 | applied_patch = ["ntp-77.1.1","ntp-88.1.1","ntp-92.5.1"]
10 |
11 | def check_ntp():
12 | check = subprocess.check_output(["what", "/usr/sbin/ntpd"])
13 | o = check.strip()
14 | p = o.split()
15 | t = p[2]
16 | c = t.split(":")
17 | result = c[1]
18 | return result
19 |
20 | #Check the version and also handles new sub versions of Yosemite
21 | def check_version():
22 | osvers = platform.mac_ver()[0]
23 | sub_ver = osvers[3:]
24 | sub_ver = float(sub_ver)
25 |
26 | if sub_ver == 8.5:
27 | return "Mountain Lion 10.8.5"
28 | elif sub_ver == 9.5:
29 | return "Mavericks 10.9.5"
30 | elif sub_ver >= 10.1:
31 | return "Yosemite"
32 | else:
33 | return osvers
34 |
35 | #The NTP fix is only available for the following OSX versions
36 | Needed_vers = ["Mountain Lion 10.8.5", "Mavericks 10.9.5", "Yosemite"]
37 |
38 | def check_sub_version():
39 | for item in applied_patch:
40 | sub_patch =item[:6]
41 | expected_patch = check_ntp()
42 | if expected_patch.startswith(sub_patch):
43 | #print item
44 | sub_pass = float(item[7:])
45 | #print sub_pass
46 | if expected_patch[7:] >= sub_pass:
47 | return True
48 | else:
49 | continue
50 |
51 | #print check_sub_version()
52 |
53 | running_version = check_version()
54 | if not running_version in Needed_vers:
55 | Status = "No:OS is %s"%running_version
56 | else:
57 | result = check_ntp()
58 |
59 | if check_sub_version:
60 | Status = "Yes"
61 | else:
62 | apply_update = subprocess.check_output(["softwareupdate", "--install", "OS X NTP Security Update-1.0"])
63 | value_one = check_ntp()
64 | if value_one in applied_patch:
65 | Status = "Yes"
66 | else:
67 | Status = apply_update
68 |
69 |
70 | print "%s" %Status
71 |
72 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OSXScripts
2 | ==========
3 |
4 | Scripts for managing macs
5 |
--------------------------------------------------------------------------------
/SSH Checker/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/SSH Checker/ssh_enabler.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #Script to reset and enable ssh
4 | #2015 Quam Sodji
5 |
6 | #The script remove the sshd_config then recreates it
7 | #Add the enabled default settings
8 | #Turns remotelogin on
9 |
10 | sshd_fixer() {
11 | touch /etc/sshd_config
12 | echo "SyslogFacility AUTHPRIV" > /etc/sshd_config
13 | echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/sshd_config
14 | echo "AcceptEnv LANG LC_*" >> /etc/sshd_config
15 | echo "Subsystem sftp /usr/libexec/sftp-server" >> /etc/sshd_config
16 |
17 | if [[ `systemsetup -getremotelogin` == *On ]];then
18 | echo "Remote login is already On.... Skipping"
19 | exit 0
20 | else
21 | systemsetup -setremotelogin on
22 | fi
23 | }
24 |
25 | if [[ -f "/etc/sshd_config" ]];then
26 | echo "Found it.. Deleting...."
27 | rm -r /etc/sshd_config
28 | sshd_fixer
29 | else
30 | echo "sshd_config doesn't exists...Creating and Fixing ssh"
31 | sshd_fixer
32 | fi
33 |
34 | exit 0
--------------------------------------------------------------------------------
/SSH Checker/ssh_status.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #Reports back the status of SSH Remote Login via Attribute
4 | #Quam Sodji 2015
5 |
6 | ssh_chk=`systemsetup -getremotelogin`
7 | ssh_conf="/etc/sshd_config"
8 |
9 | if [[ "$ssh_chk" == *On ]] && [[ -f "$ssh_conf" ]]; then
10 |
11 | result="Enabled"
12 | else
13 | result="Disabled"
14 | fi
15 |
16 | echo "$result"
17 |
--------------------------------------------------------------------------------
/ScreenSaver Settings/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ScreenSaver Settings/Screensaver_lock.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sh
2 | #Script will set values for the screensaver settings to ensure a password prompt
3 | #immediatly after the screensaver kicks in
4 | #Quam Sodji
5 |
6 | user=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`
7 |
8 | defaults write /Users/"$user"/Library/Preferences/com.apple.screensaver askForPassword -int 1
9 | defaults write /Users/"$user"/Library/Preferences/com.apple.screensaver askForPasswordDelay -int 0
10 | chown $user /Users/"$user"/Library/Preferences/com.apple.screensaver.plist
11 |
--------------------------------------------------------------------------------
/ScreenSaver Settings/screensaver_status.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #This script checks the settings assigned to the user screensaver.plist by QUAM SODJI
4 |
5 | user=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`
6 |
7 | user_settings_one=$(defaults read /Users/$user/Library/Preferences/com.apple.screensaver askForPassword)
8 |
9 | user_settings_two=$(defaults read /Users/$user/Library/Preferences/com.apple.screensaver askForPasswordDelay)
10 |
11 | user_settings_three=$(defaults read /Users/$user/Library/Preferences/com.apple.screensaver)
12 |
13 | #These are the two values we want for our screensaver settings
14 | ask_password=1
15 | ask_Delay=0
16 |
17 | #Evaluate the user settings against the desired settings and reports back
18 |
19 | if [[ "$user_settings_one" == "$ask_password" && "$user_settings_two" == "$ask_Delay" ]]; then
20 | echo "Secure"
21 | else
22 | echo "Insecure"
23 | fi
24 |
--------------------------------------------------------------------------------
/Software Update Prompt/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Software Update Prompt/softwareupdatehelper.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ####################################################################################################
4 | #
5 | # Copyright (c) 2015, Quam Sodji.
6 | # Script will prompt the user after Casper has installed the OS X updates to restart
7 | # If the user chooses later, he will be prompted again in 4 hours at which time
8 | # the user will only have the option to restart now
9 | ####################################################################################################
10 |
11 | ## Get the logged in user's name
12 | userName=$(/usr/bin/stat -f%Su /dev/console)
13 |
14 | ## CUSTOMIZABLE SETTINGS ####################
15 |
16 | TIME=4 #in Hours
17 |
18 | ##############################################
19 | if [ "$TIME" == 1 ];then
20 | TIMESTAMP="hour"
21 | else
22 | TIMESTAMP="hours"
23 | fi
24 | ##############################################
25 |
26 | SCHEDULE="$TIME $TIMESTAMP"
27 | JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
28 | LOGO="/private/tmp/COMPANY.icns"
29 | TITLE="COMPANY IT Client Management"
30 | PROMPT_HEADING="Updates have been installed on your Mac"
31 | PROMPT_MESSAGE="Please save your work and restart to complete the process.
32 | You can restart now or your Mac will be restarted automatically in "$SCHEDULE"."
33 | PROMPT_MESSAGE_TWO="Please save your work and restart now to complete the update process!"
34 |
35 | ################# END #######################
36 |
37 | ######## Check if there are still updates available ######
38 |
39 | UPDATES=$((softwareupdate -l) 2>&1 > /dev/null)
40 |
41 | if [[ -n "$UPDATES" ]];then
42 | echo "We are all good"
43 | echo $UPDATES
44 | jamf recon
45 | exit 0
46 | else
47 | echo "Found updates to install...."
48 | softwareupdate -l
49 | INSTALL=$(softwareupdate -i -a)
50 | jamf recon
51 | WAIT=$(($TIME * 3600)) #Based on the time entered, the counter will be set in seconds
52 | # Display a COMPANY branded prompt.
53 | reply=$("$JAMFHELPER" -windowType utility -lockHUD -icon "$LOGO" -title "$TITLE" -heading "$PROMPT_HEADING"\
54 | -description "$PROMPT_MESSAGE" -alignDescription natural -button1 "Now" -defaultButton 1 -button2 "Later")
55 |
56 | if [ "$reply" == 0 ];then
57 | echo "Rebooting......"
58 | shutdown -r now
59 |
60 | else
61 | echo "$userName chose to reboot later"
62 | sleep $WAIT
63 |
64 | reply1=$("$JAMFHELPER" -windowType utility -lockHUD -icon "$LOGO" -title "$TITLE"\
65 | -description "$PROMPT_MESSAGE_TWO" -button1 "Now" -defaultButton 1)
66 |
67 | if [ "$reply1" == 0 ];then
68 | echo "Rebooting......"
69 | shutdown -r now
70 | fi
71 | fi
72 | fi
--------------------------------------------------------------------------------
/Sophos Removal/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Quam Sodji
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Sophos Removal/sophos_removal.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | # Quam Sodji Copyright 2015
3 | # Remove Sophos silently from Mac running any version from 9.0 to 9.2+
4 |
5 | import subprocess
6 | import os
7 |
8 | version_9_0 = "9.0"
9 | version_9_1 = "9.1"
10 | version_9_2 = "9.2"
11 | try:
12 | sophos_version = subprocess.check_output("mdls -name kMDItemVersion /Applications/Sophos\ Anti-Virus.app", shell=True)
13 | sophos_version = sophos_version.strip()
14 | sophos_version = sophos_version[17:]
15 | sophos_version = sophos_version[1:]
16 | sophos_version = sophos_version[:-3]
17 | if sophos_version == version_9_0:
18 | os.chdir("/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/")
19 | remove_9_0 = subprocess.check_output(["./InstallationDeployer","--remove"])
20 |
21 | elif sophos_version == version_9_1:
22 | os.chdir("/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/")
23 | remove_9_1 = subprocess.check_output(["./InstallationDeployer","--remove"])
24 |
25 | elif sophos_version == version_9_2:
26 | os.chdir("/Library/Application Support/Sophos/opm/Installer.app/Contents/MacOS/tools/")
27 | remove_9_2 = subprocess.check_output(["./InstallationDeployer","--remove"])
28 | else:
29 | print "Found some other version of Sophos labeled : %s" %sophos_version
30 | except:
31 | print "Sophos not installed"
--------------------------------------------------------------------------------
/Virtual Machine Identifier/vm_os_checker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | #Quam Sodji 2015
3 |
4 | import subprocess
5 | #Search for VMs
6 | vmware_files = subprocess.check_output(["find","/Users","-name","*.vmx"])
7 | vbox_files = subprocess.check_output(["find","/Users","-name","*.vbox"])
8 | parallels_files = subprocess.check_output(["find","/Users","-name","VmInfo.pvi"])
9 |
10 | #Create list with the found VMs
11 | vmware_files = vmware_files.split("\n")
12 | vmware_files = filter(None, vmware_files)
13 | vbox_files = vbox_files.split("\n")
14 | vbox_files = filter(None, vbox_files)
15 | parallels_files = parallels_files.split("\n")
16 | parallels_files = filter(None, parallels_files)
17 | #print vmware_files
18 | #print vbox_files
19 | #print parallels_files
20 | results = []
21 |
22 | def what_vm(): #Check which VMs are present
23 | if vmware_files == [] and vbox_files == [] and parallels_files == []:
24 | return "No VM Found"
25 | elif vmware_files == [] and vbox_files == [] and parallels_files != []:
26 | return "Parallels Found"
27 | elif vmware_files == [] and vbox_files != [] and parallels_files == []:
28 | return "Vbox Found"
29 | elif vmware_files == [] and vbox_files != [] and parallels_files != []:
30 | return "Vbox and Parallels Found"
31 | elif vmware_files != [] and vbox_files == [] and parallels_files == []:
32 | return "VMware found"
33 | elif vmware_files != [] and vbox_files == [] and parallels_files != []:
34 | return "VMware and Parallels Found"
35 | elif vmware_files != [] and vbox_files != [] and parallels_files == []:
36 | return "VMware and Vbox Found"
37 | elif vmware_files != [] and vbox_files != [] and parallels_files != []:
38 | return "VMware,Vbox and Parallels Found"
39 | else:
40 | return "Error..."
41 |
42 | def found_vmware(): #Returns found Vms OS
43 | vm_found = []
44 | vmware_config =[]
45 | for i in vmware_files:
46 | if i.endswith(".vmx"):
47 | vmware_config.append(i)
48 | for t in vmware_config:
49 | tre = open(t)
50 | for line in tre:
51 | if line.startswith("guest"):
52 | vm_os = line.strip()[11:-1]
53 | vm_os = vm_os.lower()
54 | vm_found.append(vm_os)
55 |
56 | vm_found = ('\n').join(vm_found)
57 | return "%s"%vm_found
58 |
59 | def found_vbox(): #Returns found Vms OS
60 | vbox_mod = []
61 | vbox_os = []
62 | for i in vbox_files:
63 | read_vbox = open(i)
64 | for line in read_vbox:
65 | if "OSType=" in line:
66 | vbox_mod.append(line)
67 |
68 | for some in vbox_mod:
69 | some = some.strip()
70 | vbox_cut = some.split()
71 | for b in vbox_cut:
72 | if "OSType=" in b:
73 | vbox_os.append(b[8:-1])
74 | vbox_os = ('\n').join(vbox_os)
75 | return "%s"%vbox_os
76 |
77 | def found_para(): #Returns found Vms OS
78 | para_res = []
79 | cleanup =[]
80 | para_mod = []
81 | for a in parallels_files:
82 | read_pars = open(a)
83 | for bib in read_pars:
84 | if "RealOsType" in bib:
85 | para_mod.append(bib.strip())
86 | for g in para_mod:
87 | gt = g.split()
88 | gt = gt[1:2:]
89 | cleanup.append(gt)
90 | for m in cleanup:
91 | t = m[0].translate(None,",")
92 | para_res.append(t)
93 | para_res = ('\n').join(para_res)
94 | return "%s" %para_res
95 |
96 | #Output logic based on found Vms --> Info is then displayed in Casper
97 | if what_vm() == "No VM Found":
98 | results = "No VM Found"
99 | print "%s"%results
100 |
101 | elif what_vm() == "Parallels Found":
102 | results.append("Parallels")
103 | results.append(found_para())
104 | results = ('\n').join(results)
105 | print "%s"%results
106 |
107 | elif what_vm() == "Vbox Found":
108 | results.append("VirtualBox")
109 | results.append(found_vbox())
110 | results = ('\n').join(results)
111 | print "%s"%results
112 |
113 | elif what_vm() == "Vbox and Parallels Found":
114 | results.append("Parallels")
115 | results.append(found_para())
116 | results.append("\nVirtualBox")
117 | results.append(found_vbox())
118 | results = ('\n').join(results)
119 | print "%s"%results
120 |
121 | elif what_vm() == "VMware found":
122 | results.append("VMware Fusion")
123 | results.append(found_vmware())
124 | results = ('\n').join(results)
125 | print "%s"%results
126 |
127 | elif what_vm() == "VMware and Parallels Found":
128 | results.append("Parallels")
129 | results.append(found_para())
130 | results.append("\nVMware Fusion")
131 | results.append(found_vmware())
132 | results = ('\n').join(results)
133 | print "%s"%results
134 |
135 | elif what_vm() == "VMware and Vbox Found":
136 | results.append("VirtualBox")
137 | results.append(found_vbox())
138 | results.append("\nVMware Fusion")
139 | results.append(found_vmware())
140 | results = ('\n').join(results)
141 | print "%s"%results
142 |
143 | elif what_vm() == "VMware,Vbox and Parallels Found":
144 | results.append("Parallels")
145 | results.append(found_para())
146 | results.append("\nVirtualBox")
147 | results.append(found_vbox())
148 | results.append("\nVMware Fusion")
149 | results.append(found_vmware())
150 | results = ('\n').join(results)
151 | print "%s"%results
152 |
153 | else:
154 | results = what_vm()
155 | print "%s"%results
156 |
157 |
158 |
--------------------------------------------------------------------------------