r/Wordpress • u/zirk020 • 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
| Signal | What it means |
|---|---|
| New admin account | An 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 rights | An 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 role | The 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 rights | A 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 admin | A new super admin of a WordPress network. |
| Admin e-mail address changed | The 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 password | A 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 breaches | The 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
| Hint | Why 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 domain | Normal for a web agency or maintainer. |
| Admin on N sites of other customers | The 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
u/thomas-at-caseproof 7d ago
A few signals that have caught things your list doesn't seem to cover yet:
pre_user_queryorviews_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 containsadministratoragainst what the API returns catches that, and a mismatch is about as strong a signal as you'll get.{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_registeredis 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_tokensuser 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.