Skip to content

Instantly share code, notes, and snippets.

@terminalfool
Last active July 23, 2017 03:50
Show Gist options
  • Save terminalfool/770a05ef8d76bdb3ca3c to your computer and use it in GitHub Desktop.
Save terminalfool/770a05ef8d76bdb3ca3c to your computer and use it in GitHub Desktop.
a daemon to remove tracking keys between browser sessions
#!/usr/bin/perl
#otter.pl v0.11 7/1/16
#scan and delete urchin cookies from mozilla cookie db
use strict;
use warnings;
use File::Monitor;
use File::Path qw(remove_tree);
use DBI;
my $cookies = '/users/admin/library/application support/firefox/profiles/admin.default/cookies.sqlite';
my $diskcache = '/users/admin/library/caches/firefox/profiles/admin.default/cache2';
my $appcache = '/users/admin/library/caches/firefox/profiles/admin.default/offlinecache';
my @baseDomain = ("google.com","twitter.com","abmr.net","actionx.com","actnx.com","adelixir.com","agkn.com","analyticsmarket.com","adyapper.com","advertising.com","advertising.net","thebrighttag.com","mediaplex.com","effectivemeasure.com","yieldmanager.com","optimizely.com","doubleclick.net","acxiom.com","demdex.net","analyticsmarket.com","newrelic.com","agilone.com","cash-duck.com","granify.com","choicestream.com","citygridmedia.com","collective-media.com","completecarrd.com","convertro.com","cxsense.com","tealiumiq.com","demdex.net","dmtracker.com","dmtry.com","csdata1.com","dsply.com","dynamicyield.com","esomniture.com","simplereach.com","eloqua.com","omtrdc.net","ensighten.com","estara.com","postclickmarketing.com","exelator.com","aweber.com","gcimetrics.com","gigya.com","glassdoor.com","wbsadsdel.com","infusionsoft.com","hostingprod.com","cnzz.com","inspectlet.com","inttrax.com","ioam.de","kau.li","krxd.net","mercent.com","linkbucksmedia.com","livefyre.com","lytics.io","marinsm.com","ml314.com","mxptint.net","naytev.com","netmn.comg","nolo.com","nrelate.com","openstat.net","owneriq.net","liadm.com","p.univide.com","pagefair.com","pardot.com","parsely.com","go2jump.org","affiliaxe.com","pointclicktrack.com","richrelevance.com","rkdms.com","scorecardresearch.com","securedvisit.com","sessionm.com","simpli.fi","simplereach.com","skimresources.com","statcounter.com","swishu.com","tinypass.com","tellapart.com","themarketiq.com","taboola.com","triggit.com","tynt.com","visualdna.com","vizu.com","ahalogy.com","weiku.com","xignite.com","yyv.co","zemanta.com","digitalpoint.com","pixlee.com","listrakbi.com","marketo.com","bizible.com","brandads.net","audienceiq.com","2o7.net","33across.com","sophus3.com","acuityplatform.com","acxiom-online.com","amgdgt.com","amxdt.com","analytics.fairfax.com.au","atwola.com","atdmt.com","bestadbid.com","bidswitch.net","bizographics.com","brilig.com","btrll.com","burstnet.com","ypcdn.com","chango.com","channelintelligence.com","cleverbridge.com","clkrev.com","inq.com","collective-media.net","netmng.com","connexity.net","contextweb.com","conversionruler.com","coolsocial.net","criteo.com","crsspxl.com","cxense.com","daniweb.com","decdna.net","did-it.com","directrev.com","djs-consulting.com","dlqm.net","elicitapp.com","etracker.de","flashtalking.com","freshplum.com","gameagent.com","gumgum.com","histats.com","hlserve.com","hubbiz.com","mookie1.com","ic-live.com","igodigital.com","imrworldwide.com","getclicky.com","insightexpressai.com","intentiq.com","interclick.com","invitemedia.com","iponweb.com","j.co.uk","jumptap.com","kontera.com","legolas-media.com","lexity.com","lijit.com","liverail.com","luminate.com","media.net","media6degrees.com","morevisibility.com","mybuys.com","myvisualiq.net","myvisualiq.com","nanigans.com","neodatagroup.com","netseer.com","netshelter.net","bazaarvoice.com","newsinc.com","nexac.com","ning.com","nyti.ms","nytimes.com","ojrq.net","openx.net","openx.com","outbrain.com","servedbyopenx.com","p-td.com","p.d41.co","pointroll.com","admedo.com","provenpixel.com","pswec.com","pulsemgr.com","steelhousemedia.com","r7ls.net","wunderloop.net","revsci.net","rfihub.com","rlcdn.com","radiumone.com","gwallet.com","rtbidder.net","ru4.com","rubiconproject.com","sojern.com","specificclick.net","webtrendslive.com","liveclicker.net","brand-server.com","crsspxl.com","thinkupfront.com","touchcommerce.com","adform.net","callmeasurement.com","tradelab.fr","udmserve.net","vanguard15.org","viglink.com","vindicosuite.com","visiblemeasures.com","vindico.com","voice5.com","w55c.net","wsod.com","wtp101.com","wtvertnet.com","wurfl.io","xg4ken.com","impact-ad.jp","yadro.ru","namhuy.net","1worldonline.com","17track.net","104.197.10.88","adk2x.com","digitaltrends.com","104.198.198.188","voluumtrk.com");
my @name = ("^_*utm.*","^_*ga.*","^__cfduid",".*track.*",);
my $monitor = File::Monitor->new();
$monitor->watch( $cookies,
sub {
my ( $name, $event, $change ) = @_;
}
);
while(1) {
foreach my $delta ($monitor->scan) {
my $dbh = DBI->connect('dbi:SQLite:dbname=' . $delta->name, '', '',{AutoCommit=>1,RaiseError=>1,PrintError=>0});
foreach (@baseDomain) {
my $sth = $dbh->prepare('delete from "moz_cookies" where baseDomain REGEXP ".*'.$_.'.*"');
$sth->execute();
}
foreach (@name) {
my $sth = $dbh->prepare('delete from "moz_cookies" where name REGEXP "'.$_.'"');
$sth->execute();
}
$dbh->disconnect;
remove_tree($diskcache, $appcache);
}
sleep(1);
}
1;
=head1 NAME
otter.pl
=head1 SYNOPSIS
perl otter.pl
=head1 DESCRIPTION
Daemon Script for scanning and deleting urchins from mozilla cookie db. Also deletes a growing list of other tracking cookies and clears any remaining tracking keys by deleting the disk and application caches.
=head1 AUTHOR
David Watson <[email protected]>
=head1 COPYRIGHT
This library is free software. You can redistribute it and/or modify it under the
same terms as Perl itself.
=cut
install as daemon on osx using launchctl: launchctl load -w /library/launchdaemons/us.dustbin.otter.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>us.dustbin.otter</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/otter.pl</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment