Patchwork/Django anti-spam cleanup script
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sat Feb 18 13:10:25 EST 2012
In case you ever want to clean a Patchwork instance of spam
registrations and assuming that nothing on your site besides Patchwork
uses Django, try the following script which should kill a majority of
spam accounts.
Disclaimer: This script is an absolutely gross 5-minute hack, and it
should remove all inactive accounts with all associated data. If you
deactivated real users, they will vanish as well. I wrote this killer
script after I noticed that 99% of the spam accounts in coreboot
patchwork were inactive.
License of this script is WTFPL 2.0
# use w3m to log in to patchwork
for ((i=0; i<1980; i++)); do w3m -cookie http://patchwork.yoursite.org/admin/auth/user/$i -dump|grep "Active\|Date\|Time" >$i.txt; echo -n .; done
fgrep -l "[ ]Active" *txt|cut -f 1 -d.|while read a; do grep "Date:\|Time:" $a.txt|sort -u|wc -l|grep -q "^2$" && echo $a; done|while read b; do w3m -cookie http://patchwork.yoursite.org/admin/auth/user/$b/delete/ -dump -cols 200 >$b.del; done
# inspect *.del and check if any .del file mentions data you want to keep
# extract the cookie value from your w3m cookie cache
ls *.del|cut -f 1 -d.|while read a; do curl --data post=yes --cookie sessionid=123456789abcdef http://patchwork.yoursite.org/admin/auth/user/$a/delete/ ; done
Regards,
Carl-Daniel
--
http://www.hailfinger.org/
More information about the Patchwork
mailing list