Dealing with ad ware on Macs

Joined
May 9, 2007
Messages
116
Reaction score
0
Points
16
Location
UK
Your Mac's Specs
2.16Ghz Mac Book Pro
We're all well aware of the Mac's security when it comes to viruses but what about ad ware, trackers and all those other nasties that come with browsing the net? I use Ad-Aware SE on my PC which searches for things like tracking cookies, ad ware etc. Are Macs vulnerable to these as well. If so can anyone recommend any software for dealing with it? I did a quick scan on my PC last night and found 103 nasty little cookies and trackers - i certainly dont want these on my nice MBP.
 
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
Tracking cookies and the like are an ongoing nuisance that Mac OS X can't protect you from. The only answer that I am aware of is to diligently clean up your cookies on a regular basis.

For myself, being Linux friendly, and thus Terminal.app friendly, I have written a small Terminal script that does this for me. What I did was manually clean up my cookies until there were just the ones there that I wanted to preserve long term (things like my Mac Forums cookie, certain bank site cookies and so on). Then I went into my Firefox directory (I use Firefox pretty exclusively these days) and made a copy of my cookies.txt file (where Firefox keeps the cookies) called cookies.persist.txt. Then I wrote a small Terminal script called "clean" which basically reverses this process - it copies cookies.persist.txt to cookies.txt, thus wiping out the daily accumulation of cookies with just the ones I want to keep permanently.

I take care to run this "clean" script at last once daily, and frequently more often than that. I could automate the running of it via cron, but I am in and out of Terminal so much that this step has never seemed necessary for me.

I have enhanced this "clean" script over time so that it cleans up all sorts of accumulating rubbish - thumbnail caches, recently used file lists, bash history and so on. Keeps everything slim and running quickly.

BTW, this same approach can be used for Safari, except that instead of cookies.txt in a Firefox dir, you make a copy of Cookies.plist in your home folder's Library/Cookies folder.
 
Joined
Mar 22, 2007
Messages
1,463
Reaction score
67
Points
48
Location
UK
Your Mac's Specs
Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
Could you post that script?
 

cwa107


Retired Staff
Joined
Dec 20, 2006
Messages
27,042
Reaction score
812
Points
113
Location
Lake Mary, Florida
Your Mac's Specs
14" MacBook Pro M1 Pro, 16GB RAM, 1TB SSD
I too would be interested in that script, if you wouldn't mind posting it, Mac57.

Also, just wanted to add that to date, there is no executable spyware/grayware/adware for OS X.
 
Joined
Oct 10, 2004
Messages
10,345
Reaction score
597
Points
113
Location
Margaritaville
Your Mac's Specs
3.4 Ghz i7 MacBook Pro (2015), iPad Pro (2014), iPhone Xs Max. Apple TV 4K
I suppose if you are really paranoid about cookies, you could just turn them off in the browser prefs.
 
Joined
Apr 29, 2006
Messages
4,576
Reaction score
378
Points
83
Location
St. Somewhere
Your Mac's Specs
Mac Studio, M1 Max, 32 GB RAM, 2 TB SSD
Hi All, as requested, here is the script:

Code:
# Script to clean up cached data items that tend to accumulate over
# time on the computer. Cleans several things:

# 1. Clean up cached thumbnails

# 2. Clean up the .bash_history file

# 3. Clean up "recently used" accumulators, playlist histories, etc.

# 4. One step clean up of Firefox cookies, histories, etc.

# 5. One step cleanup of Safari cookies, histories, etc. 

# 1. Thumbnails

rm -f /Users/mac57/.thumbnails/large/*
rm -f /Users/mac57/.thumbnails/normal/*

# 2. Bash History

rm -f /Users/mac57/.bash_history

# 3. Various "Recently Used" trackers, playlist histories, etc.

rm -rf /Users/mac57/.recently-used
rm -rf /Users/mac57/.gqview/history
rm -rf /Users/mac57/.gqview/thumbnails
cp -f  /Users/mac57/.gimp-2.2/documents.persist /Users/mac57/.gimp-2.2/documents

cd /Users/mac57/Library/Preferences
cp "Windows Media Player Prefs-default.txt" "Windows Media Player Prefs"
cd

# 4. Firefox cookies, downloads, history - one step cleanup

cd /Users/mac57/Library/Application\ Support/Firefox/Profiles/sy0jbj2k.default
cp cookies.persist.txt  cookies.txt
cp downloads.clear.rdf  downloads.rdf
cp history.clear.dat    history.dat

# 5. Safari cookies, downloads, history, cache - one step cleanup

cd /Users/mac57/Library/Cookies
cp cookies.persist.plist cookies.plist
cd /Users/mac57/Library/Safari
cp Downloads.plist.persist Downloads.plist
cp History.plist.persist History.plist
cd /Users/mac57/Library/Caches
rm -rf Safari
mkdir Safari

# Display the result

echo " "

echo "Caches Cleared - Disk Utilization:"
echo "Filesystem                Size   Used  Avail Capacity  Mounted on"
df -h | grep -i disk

echo " "

Note that you will need to change the references to "mac57" to your userid, and you will also need to change the name of the Firefox sub directory where it keeps all the cookies etc. to match your system.

Also note that I have taken the same approach to Firefox/Safari history and download lists as I have to cookies, saving off a standard minimal one (always named like "something.persist.txt") and then overwriting the existing one with it. In order for this script to work "as is" for you, you will need to do the same.

Also, I have GIMP loaded on my machine, and have included it's documents list in the clean up too. If you don't have GIMP on your machine, just delete that part of the script.


To use this script, copy and paste it into a simple text file, and save that file in your home folder as filename "clean" (or whatever name you like). If you are an advanced user and have your own personal bin folder, place it there. If you are not, your home directory is just fine, and is what is assumed in the below.

Now open a Terminal.app session. Type in "ls" and Enter and you should see your script file there in the list of files. Type the following to make the script executable:

Code:
chmod +x clean

Thats it - all ready to use.

From now on, when you want to clean out your Firefox, Safari, etc. caches, just startup Terminal.app and type:

Code:
./clean

As a useful data point, this script prints out your disk usage at the end. You likely won't see it change as a result of this script running, but when I first put the script together, I thought I might, and I have liked to see the result ever since, so I leave it there.

Enjoy! ...and let me know if you have any questions.
 

cwa107


Retired Staff
Joined
Dec 20, 2006
Messages
27,042
Reaction score
812
Points
113
Location
Lake Mary, Florida
Your Mac's Specs
14" MacBook Pro M1 Pro, 16GB RAM, 1TB SSD
Joined
Mar 22, 2007
Messages
1,463
Reaction score
67
Points
48
Location
UK
Your Mac's Specs
Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
Ugh... virtual rep to you, sir - need to spread it around. Thanks a lot.

Same here. That's a great help, mac57. Does the ~ thing for your home folder work in terminal scripts?
 
Joined
Feb 25, 2007
Messages
116
Reaction score
2
Points
18
Location
Pittsburgh, PA, USA
Your Mac's Specs
PowerBook G4 15" 1GHz 768MB 60GB
Excellent script! And knightlie, ~ should indeed reference your home directory.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top