r/Wordpress • • 7d ago

Rogue admin detection

A compromised or attacker-added administrator account is one of the most common ways a cleaned site gets re-infected: the attacker logs back in and uploads the malware again. I developed a tool for Plesk webmasters that tries to find them...
My scanner looks for these accounts in two ways: it watches for changes in admin rights (the strong signal), and it marks accounts that look unusual (hints, for sorting).

Please tell me if there other ways so i can implemented in my free scanner for plesk on
https://github.com/dzaal/StingyScan-for-Plesk/

What makes an account suspected

An account is marked to review (red) only for a strong signal. Grey badges are hints: many real admins have them, so on their own they don't make an account suspected.

Strong signals (red): something changed, or the address is known to attackers

SignalWhat it means
New admin accountAn account with admin rights appeared that was not there at the scan before. Attackers add one right after they get in.
Existing account got admin rightsAn older account (a subscriber, customer, editor…) was promoted. Shows the previous role and when the account was created: an account from years ago can get admin rights today.
Admin rights without the administrator roleThe account can take over the site through capabilities such as manage_options, promote_users, create_users, edit_users or install_plugins, given directly to the account or to a custom role. A role name alone does not show this, which is why attackers use it.
A role got admin rightsA role other than administrator (for example editor or a plugin's role) gained one of those capabilities. Everyone with that role now counts as an admin.
New Multisite super adminA new super admin of a WordPress network.
Admin e-mail address changedThe address of an existing admin changed: the usual first step of an account takeover (the password reset mail then goes to the attacker). The admin list stays the same, so only a comparison catches it.
New application passwordA new application password for an admin: a login for the REST API and XML-RPC that skips the normal login screen and two-factor login.
Found in N breachesThe address is in a known data breach (see Pwned Admins): if the password was reused, an attacker can simply log in.
Created N days ago (yellow)The account is less than 30 days old.

Hints (grey): worth a look, not suspicious on their own

HintWhy it is only a hint
Generic or bot-added username (admin2, support, wpuser, a random string…)Bots use these names, but so do some site builders.
Free e-mail provider (Gmail, Hotmail…)Many site owners use one.
E-mail from an unrelated domainNormal for a web agency or maintainer.
Admin on N sites of other customersThe same address has admin rights on sites of different customers. Normal for an agency; otherwise one attacker may have added the same account to several sites.
1 Upvotes

6 comments sorted by

1

u/thomas-at-caseproof 7d ago

A few signals that have caught things your list doesn't seem to cover yet:

  • Hidden admins. Some malware drops an mu-plugin that filters pre_user_query or views_users, so the account exists but never shows up on the Users screen or in WP_User_Query results. Comparing a raw SQL count of users whose capabilities meta contains administrator against what the API returns catches that, and a mismatch is about as strong a signal as you'll get.
  • Prefix leftovers. The capabilities meta key is {prefix}capabilities, so a site whose table prefix changed (or a multisite) can carry keys from an old prefix. Capability keys that don't match the current prefix are worth flagging.
  • user_registered is just a column. Anyone inserting rows directly can set it to whatever they like, so I wouldn't let an old registration date lower suspicion on an account that's new to your scan.
  • Session tokens. The session_tokens user meta records the IP and user agent of each active login, so an old, quiet admin account with a fresh session from an address nobody recognizes deserves the red badge even though the account itself hasn't changed.

One caveat on the breach check: if it sends addresses to a third-party API, say so plainly in the README, because people running Plesk for clients will want to know where those emails go.

1

u/NeelbyteWeb 7d ago

Nice list — the one I'd add from cleaning hacked client sites is checking what the account actually did, not just that it exists. A rogue admin usually leaves a trail in the activity log: a plugin installed, a file edited, or a cron job added in the hours after the account appeared.

I also check capabilities in the database directly, because a user can hold manage_options without the administrator role name, and I compare the admin list against a known-good backup. Do you track last login time and IP as well, or just the account changes?

1

u/ansari_m369 7d ago

Also flag changed user_email, new files in wp-content/uploads or mu-plugins, and logins from new IPs or odd hours. Compare core file checksums with wp core verify-checksums.