惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
L
LINUX DO - 最新话题
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
博客园 - Franky
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
V
Visual Studio Blog
博客园 - 【当耐特】
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
IT之家
IT之家
H
Hacker News: Front Page
O
OpenAI News
V2EX - 技术
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
K
Kaspersky official blog
罗磊的独立博客
博客园 - 聂微东
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Threatpost
N
News and Events Feed by Topic
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
Help Net Security
Help Net Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
H
Help Net Security
S
Secure Thoughts
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Cloudbric
Cloudbric
NISL@THU
NISL@THU
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Latest news
Latest news
T
Troy Hunt's Blog

OSU Open Source Lab

Data Center Migration Update and Fundraising Campaign | OSU Open Source Lab OSL Infrastructure Migration: A Move to Oregon's State Data Center | OSU Open Source Lab Featured: Strong support stabilizes funding for the Open Source Lab | OSU Open Source Lab We're Hiring: Join the OSU Open Source Lab as a Student Systems Engineer! | OSU Open Source Lab Forging Our Future: OSL's Path to Sustainability – A Call for Smart Solutions and Enduring Support | OSU Open Source Lab Future of OSL in Jeopardy | OSU Open Source Lab Now Providing Access to POWER10 for Open Source Projects | OSU Open Source Lab FTP Server Rebuild - March 2024 | OSU Open Source Lab On Leaving the Open Source Lab, Jonathan Frederick | OSU Open Source Lab Reflections on My Time at the Open Source Lab, Travis Whitehead | OSU Open Source Lab OSL Alumnus Matthew Johnson on working at Tesla | OSU Open Source Lab Hiring two DevOps student positions | OSU Open Source Lab TDS Telecom Support of OSU Open Source Lab Tops $5 Million | OSU Open Source Lab Goodbye Letter from Graduating Senior, Cody Holliday | OSU Open Source Lab Mohamed Eldebri on OSL's participation in the Corvallis Maker Fair | OSU Open Source Lab Cody Holliday on the Department of Energy Cyber Defense Competition 2018 | OSU Open Source Lab OSL's Cody Holliday Wins Regional DOE Cyber Defense Competition | OSU Open Source Lab OSL Alumnus Alex Plovi sells CoreOS to RedHat | OSU Open Source Lab Changing the World, One Line of Code at a Time | OSU Open Source Lab Jonathan Frederick on Packer Templates project at the OSL | OSU Open Source Lab Ganeti Production Rebuild - Dec 11-15 & 18-19, 2017 | OSU Open Source Lab Thank You for Supporting our Crowdfunding Campaign! | OSU Open Source Lab A Message from the Director | OSU Open Source Lab New Project: polr | OSU Open Source Lab Donate to Our Crowdfunding Campaign! | OSU Open Source Lab Cody Holliday on Why we should stop using C | OSU Open Source Lab Amanda Kelner on Graduating | OSU Open Source Lab Beaver BarCamp 17: New Horizons | OSU Open Source Lab New Project: libpng Now Mirrored on ftp.osuosl.org | OSU Open Source Lab Network Outage 2016-12-17 Post-mortem | OSU Open Source Lab OSL Summer 2016 Internship | OSU Open Source Lab The OSL at PyCon | OSU Open Source Lab Congratulations 2016 Graduates! | OSU Open Source Lab RTEMS | OSU Open Source Lab CASS and the AllSeen Alliance | OSU Open Source Lab DevOps DayCamp 2015 | OSU Open Source Lab OSL GSOC 2015 - Oregon's Catch | OSU Open Source Lab OSL GSOC 2015 - Protein Geometry Database | OSU Open Source Lab Mysql1-vip Outage Post-Mortem | OSU Open Source Lab Write the Docs '15 | OSU Open Source Lab Coming Soon: Beaver BarCamp 15 | OSU Open Source Lab SCALE x13 | OSU Open Source Lab A Successful DevOps DayCamp | OSU Open Source Lab Using Variables in a Custom Drupal Theme | OSU Open Source Lab DevOps DayCamp | OSU Open Source Lab Make Bash, Not War | OSU Open Source Lab A Recap of OSCON 2014 | OSU Open Source Lab Google Migration Post-mortem | OSU Open Source Lab OpenStack on OpenPOWER | OSU Open Source Lab Protein Geometry - What the Heck is That? | OSU Open Source Lab Openstack's Horizon | OSU Open Source Lab DevOps Bootcamp Extends OSL Reach | OSU Open Source Lab 10 Projects Making a Difference | OSU Open Source Lab Connecting at Beaver BarCamp 12 | OSU Open Source Lab Top 10 Projects Impacting the Open Source Community | OSU Open Source Lab Top 10 Milestones | OSU Open Source Lab A Look Back at Beaver BarCamp 1 | OSU Open Source Lab OSL Announces 10 year Celebration; Attends OSCON | OSU Open Source Lab Open Source Bridge Promotes Community | OSU Open Source Lab OSL to Mentor Four in Google Summer of Code | OSU Open Source Lab OSL Staff Participate at DrupalCon 2013 | OSU Open Source Lab OSL's April 2013 Newsletter | OSU Open Source Lab Students & Community Members Learn Together at Beaver BarCamp 11 | OSU Open Source Lab OSL to Participate in Google Summer of Code 2013 | OSU Open Source Lab OSL Staff Mentors International Students Through Google Summer of Code | OSU Open Source Lab Students, Community and Professionals Collaborate at Beaver BarCamp 10 | OSU Open Source Lab From Support to Success | OSU Open Source Lab OSL in the Spotlight at Summer Conferences | OSU Open Source Lab OSL Advances With New Staff Members; Renewed Focus | OSU Open Source Lab Building a Bright Future With DevOps | OSU Open Source Lab Connect With the OSL at OSCON 2012 | OSU Open Source Lab Open Source, Open Future | OSU Open Source Lab Setting the Bar High | OSU Open Source Lab OSL 'Unconference' Approaches | OSU Open Source Lab Highlights From Beaver Barcamp 8 | OSU Open Source Lab Lots of Love from LinuxCon | OSU Open Source Lab All Aboard for Vancouver! | OSU Open Source Lab New Study to Investigate Use of Open Source Software for Securing the Energy Industry | OSU Open Source Lab A Little Love for the LUG | OSU Open Source Lab Highlights from OSCON 2011 | OSU Open Source Lab OSL Talks OSWALD and Ganeti at Open Source Bridge | OSU Open Source Lab OSUOSL Alum Eric Searcy Joins the Linux Foundation as IT Infrastructure Manager | OSU Open Source Lab Out and About with the OSL in June | OSU Open Source Lab Emily on Essentials: Robotics, Open Source and Life as New Student at the OSL | OSU Open Source Lab Special Student Attendee Packages for LinuxCon North America 2011 | OSU Open Source Lab OSL Newsletter - April 2011 | OSU Open Source Lab Visiting Prineville: OSL Tours Facebook's Open Compute Data Center | OSU Open Source Lab OSL Newsletter: A Look Back at 2010 | OSU Open Source Lab CrisisCommons is pleased to announce partnership with OSU's Open Source Lab | OSU Open Source Lab OSU Open Source Lab to assist young students in “Google Code-in” contest | OSU Open Source Lab TeachEngineering Project Receives Award from NSF's National Science Digital Library | OSU Open Source Lab Google Surpasses $1M in Donations to OSUOSL | OSU Open Source Lab OSCON 2009 | OSU Open Source Lab Catch us at Open Source Bridge | OSU Open Source Lab Hackathon at Open Source Bridge | OSU Open Source Lab Hardware Donation Expands OSUOSL Infrastructure | OSU Open Source Lab Flourish! Open Source Conference | OSU Open Source Lab OSUOSL Visit to Japan | OSU Open Source Lab Linux.com finds new home at OSUOSL | OSU Open Source Lab OSU Open Source Lab announces OSL Alliance Corporate Sponsorship Program | OSU Open Source Lab
Vim Trick FTW! | OSU Open Source Lab
2014-06-11 · via OSU Open Source Lab

Vim Trick FTW!

Recently, I learned a useful Vim trick. One of our hosted clients has a Dokuwiki instance that we help manage, and they were having problems with a lot of spam user accounts being created. We added a CAPCHA to the wiki to make it less convenient for new spammers to join, but there were a lot of bad accounts already existing. By “a lot,” I mean there were 112,808 accounts listed in users.auth.php, and only about a dozen real project personnel using the wiki on a regular basis.

To clean it out, we decided the best course of action would be deleting every account except those with admin privileges, because most of the real humans were in the admin group and those who weren’t could get the project leader to re-add their accounts. The benefit of clearing out a hundred thousand spammers would, in this case, outweigh the inconvenience of manually recreating a couple of real accounts.

It turns out that DokuWiki’s interface isn’t set up to bulk delete users based on group membership – one really shouldn’t get that many spammers in to begin with, so this is an unusual case. However, I’m not forced to use only the graphical interface. DokuWiki’s configurations are stored in .php files in /var/www/wikiname/conf. Each line in users.auth.php represents one user account, and is of the form user:MD5password:Real Name:email:groups,comma,separated.

I was familiar with the Vim command :d/pattern/g to delete all lines containing a pattern, but this time I needed to delete all lines that didn’t have ‘admin’ in them. A little research revealed the command :v/pattern/d, which deletes all lines except those which match the pattern. Since many of the spammers (73 out of our 112,808, but still too many to hand-delete each) were using admin@ email addresses, simply deleting all the lines without ‘admin’ in them wasn’t good enough. Instead, since I know all the users in the admin group have their group permissions in the form “admin,user,” the command that removed everyone except the admin users was :v/admin,user/d.

If you’re newer to the Bash shell, you may be wondering how I got the specific numbers of spammers. I made a backup of the users.auth.php file before deleting users, just in case the client changed their mind. Since DokuWiki had automatically created a users.auth.php.bak, I created my own backup of the users.auth with cp users.auth.php users.auth.php.bak2. Now I can look back at the user list full of spammers and say wc -l users.auth.php.bak2 to count the lines in it (since there’s one account per line) and grep admin@ users.auth.php.bak2 | wc -l to count how many of the former users had admin@ email addresses.