Skip to content

Commit 3dedaf4

Browse files
committed
Initial commit
0 parents  commit 3dedaf4

File tree

3 files changed

+197
-0
lines changed

3 files changed

+197
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
![McAfee Remove MacOS](logo.png)
2+
3+
# McAfee Cleaner for Mac
4+
5+
Removes the following McAfee software from macOS and prevents it from being installed again:
6+
7+
* McAfee Threat Prevention for Mac
8+
* McAfee Agent
9+
10+
## Project Goal & Design
11+
12+
Project aims at aiding users in complete removal of enterprise McAfee product from their system.
13+
Enterprise McAfee version has no option of being uninstalled while it continues to corrupt the system,
14+
occupy significant CPU time, and cause wild crashes by misusing macOS's `logd` daemon.
15+
16+
The script also prevents listed McAfee products from being installed again.
17+
18+
**Tested on**: macOS Catalina 10.15.6
19+
20+
## Usage
21+
22+
Download `mcafee-cleaner.sh` script to your machine and run it with sudo rights:
23+
24+
```shell
25+
sudo ./mcafee-cleaner.sh
26+
```
27+
28+
Alternatively, if you trust the source of this script you can run it directly in the terminal:
29+
30+
```shell
31+
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/vduseev/mcafee/master/mcafee-cleaner.sh)"
32+
```
33+
34+
## Internals
35+
36+
It's a simple bash script that performs the following actions:
37+
38+
1. Removing McAfee
39+
1. Stopping McAfee services or daemons via `launchctl`
40+
1. Removing McAfee services using `launchctl`
41+
1. Killing all remaining McAfee processes using `pkill`
42+
1. Removing McAfee user and group from the system using `dscl`
43+
1. Removing directories where McAfee installs itself
44+
1. Removing McAfee files, such as configs, logs, and plists
45+
1. Unloading McAfee kernel extensions using `kextunload`
46+
1. Preventing McAfee from installing itself again
47+
1. Recreate the directories where McAfee installs itself
48+
2. Make them immutable
49+
50+
51+
## Disclaimer
52+
53+
This is a personal project not affiliated with any entity whatsoever with which I have been, am now, or will be affiliated.
54+
Use the script on your own risk. No guarantees provided.
55+

logo.png

256 KB
Loading

mcafee-cleaner.sh

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
#
5+
STEP_REMOVE_INSTALLATION="Removing McAfee"
6+
STEP_STOP_SERVICES="Stopping McAfee services"
7+
STEP_REMOVE_SERVICES="Removing McAfee services"
8+
STEP_KILL_PROCESSES="Killing all remaining McAfee processes"
9+
STEP_REMOVE_USER="Removing McAfee user and group from the system"
10+
STEP_REMOVE_DIRS="Removing McAfee directories"
11+
STEP_REMOVE_FILES="Removing McAfee files"
12+
STEP_UNLOAD_KEXTS="Unloading McAfee kernel extensions"
13+
STEP_PREVENT_INSTALLATION="Preventing McAfee from installing itself again"
14+
STEP_RECREATE_DIRS="Recreate McAfee directory structure and make it immutable"
15+
STEP_COUNTER=1
16+
17+
MCAFEE_DIR_PATHS=(
18+
"/usr/local/McAfee/"
19+
"/Library/Application\ Support/McAfee/"
20+
"/Library/McAfee/"
21+
"/var/McAfee/"
22+
"/etc/ma.d"
23+
"/etc/cma.d/"
24+
"/Library/StartupItems/ma"
25+
"/Library/StartupItems/cma"
26+
)
27+
28+
MCAFEE_FILE_GLOBS=(
29+
"/private/var/db/receipts/com.mcafee*"
30+
"/private/var/log/McAfeeSecurity.log*"
31+
"/Library/LaunchDaemons/com.mcafee*"
32+
"/etc/ma.conf"
33+
)
34+
35+
MCAFEE_SERVICES=(
36+
"com.mcafee.menulet"
37+
"com.mcafee.reporter"
38+
"com.mcafee.virusscan.fmpd"
39+
"com.mcafee.ssm.ScanManager"
40+
"com.mcafee.virusscan.ssm.ScanFactory"
41+
"com.mcafee.ssm.Eupdate"
42+
"com.mcafee.agent.macompat"
43+
"com.mcafee.agent.ma"
44+
"com.mcafee.agent.macmn"
45+
)
46+
47+
MCAFEE_KEXTS=(
48+
"com.McAfee.FMPSysCore"
49+
"com.McAfee.AVKext"
50+
"com.McAfee.FileCore"
51+
)
52+
53+
MCAFEE_USER="mfe"
54+
MCAFEE_GROUP="mfe"
55+
56+
main() {
57+
echo "$STEP_REMOVE_INSTALLATION"
58+
59+
report_step "$STEP_STOP_SERVICES"
60+
launchctl_action_on_services "stop"
61+
62+
report_step "$STEP_REMOVE_SERVICES"
63+
launchctl_action_on_services "remove"
64+
65+
report_step "$STEP_KILL_PROCESSES"
66+
pkill -i -f mcafee
67+
68+
report_step "$STEP_REMOVE_USER"
69+
delete_user "$MCAFEE_USER" "$MCAFEE_GROUP"
70+
71+
report_step "$STEP_REMOVE_DIRS"
72+
remove_dirs
73+
74+
report_step "$STEP_REMOVE_FILES"
75+
remove_files
76+
77+
report_step "$STEP_UNLOAD_KEXTS"
78+
unload_kexts
79+
80+
echo ""
81+
echo "$STEP_PREVENT_INSTALLATION"
82+
report_step "$STEP_RECREATE_DIRS"
83+
create_immutable_dirs
84+
}
85+
86+
report_step() {
87+
local __step="$1"
88+
echo "${STEP_COUNTER}. ${__step} ..."
89+
STEP_COUNTER=$((STEP_COUNTER+1))
90+
}
91+
92+
launchctl_action_on_services() {
93+
local __action="$1"
94+
for i in "${MCAFEE_SERVICES[@]}"; do
95+
launchctl "${__action}" "${i}"
96+
done
97+
}
98+
99+
delete_user() {
100+
local __user="$1"
101+
local __group="$2"
102+
# Ignore errors if user already deleted
103+
dscl . -delete "/Users/${__user}" &> /dev/null
104+
dscl . -delete "/groups/${__group}" &> /dev/null
105+
}
106+
107+
remove_dirs() {
108+
for i in "${MCAFEE_DIR_PATHS[@]}"; do
109+
# Check if the directory is already marked by us as immutable
110+
if [[ ! $(ls -laO "${i}" | grep schg | grep -c uchg) -ge 1 ]]; then
111+
rm -rf "${i}"
112+
fi
113+
done
114+
}
115+
116+
remove_files() {
117+
for i in "${MCAFEE_FILE_GLOBS[@]}"; do
118+
rm -rf "${i}"
119+
done
120+
}
121+
122+
123+
create_immutable_dirs() {
124+
for i in "${MCAFEE_DIR_PATHS[@]}"; do
125+
# Create dir
126+
mkdir -p "${i}"
127+
# Make it immutable by user
128+
chflags -R uchg "${i}"
129+
# Make it immutable to system
130+
chflags -R schg "${i}"
131+
done
132+
}
133+
134+
unload_kexts() {
135+
for i in "${MCAFEE_KEXTS[@]}"; do
136+
kextunload -b "${i}" &> /dev/null
137+
done
138+
}
139+
140+
# Execute
141+
main
142+

0 commit comments

Comments
 (0)