Linux 软件免费装
Banner图

DoctorX Hardening

开发者 xaviercode
更新时间 2026年11月15日 19:26
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

security activity log user enumeration two-factor authentication security.txt

下载

0.15.2 0.7.5

详情介绍:

DoctorX Hardening makes your WordPress site harder to break into. It closes a few doors that WordPress leaves open, lets people add a code from their phone when they sign in, and can keep a record of who did what on your site. You do not need to know anything about security to use it. Turn it on and the main protections work right away. Everything is free. Nothing is locked and there is no paid version. What it does as soon as you turn it on Each one has its own on/off switch under Settings → Hardening. Extra protections you can switch on These are all off until you switch them on. Each one says how to undo it. What it does not do So you know where its job ends: Who it is for Any WordPress site owner who wants the common holes closed without learning security. It works with any theme and needs no other plugin. Made by DoctorX.ca.

安装:

  1. In your WordPress dashboard go to Plugins → Add New, search for "DoctorX Hardening", press Install, then Activate.
  2. That is all. The protections in "What it does as soon as you turn it on" are now working. Open Settings → Hardening to see them, and switch off any you do not want.
  3. To add a phone code to your own sign-in, go to Users → Two-step sign-in (or Profile → Two-step sign-in). You need a free authenticator app on your phone, such as Google Authenticator or Microsoft Authenticator. It takes about two minutes. Keep the backup codes it gives you somewhere safe.
  4. Optional: to keep an activity record, tick "Keep an activity record" on Settings → Hardening. You will find it under Tools → Activity.
  5. Optional: for a security.txt file, type a contact email on Settings → Hardening and press Save.

屏幕截图:

  • Setting up two-step sign-in: scan the code with an authenticator app, then type the code it shows.
  • The sign-in page asks for the six-digit code after the password.
  • The activity record (Tools → Activity): who did what on the site, with filters and downloads.
  • History insights: events a day, failed sign-ins and the most active people.

升级注意事项:

0.15.2 New parts, each off until you switch it on: a down page, content policy reports, the visitor's own address behind proxies, and where visitors come from. 0.6.8 First release on WordPress.org.

常见问题:

What are the limits of each protection?

The fine print, so that nobody relies on more than is there:

  • Hidden plugin list: only the list is hidden. A person who already knows or guesses a plugin can still find it in other ways.
  • Two-step sign-in works on normal sign-in pages, including most shop and membership plugins. Apps that sign in with a plain password are refused for an account that has it on. Give each app its own app password instead (at the bottom of your profile). Sign-in through another service, such as "Sign in with Google", does not pass through it.
  • Wrong codes are limited: 5 wrong codes in 15 minutes, or 20 in a day, pause the code step. The person is emailed. While it is paused the real person cannot sign in either, so set a new password if someone else knows yours. A new password ends the pause.
  • Any administrator can switch two-step sign-in off for everybody. When that is done on the settings screen or the Plugins screen, everybody who used it is emailed. If it is switched off in some other way (by editing files or the database), nobody is told.
  • The emergency line DOCTORX_HARDENING_NO_TWO_STEP in wp-config.php turns the phone code off for every account. It is for a locked-out owner, only for as long as needed.
  • Multisite networks do not get two-step sign-in or the hidden sign-in page.
  • The phone app's secret key is stored encrypted with your site's security keys. If your host changes those keys, everybody sets two-step sign-in up again (backup codes still work to get in).
  • security.txt is a notice, not a lock. It makes it easy for an honest person to reach you.
  • The password-guess lockout counts by internet address. Many people can share one address, such as an office, and a lockout holds for all of them. That is why you can list trusted addresses, and why an address an administrator used is only ever paused for an hour. A site behind a proxy or Cloudflare must name it in the settings, or every visitor looks like the same address.
  • The trusted list can hold the name of a home connection whose address changes. The site checks the name every 15 minutes and trusts only the address it points to now.
  • The hidden sign-in page hides the page. It is not a lock. Anyone who learns the address can still try, and the lockout and phone code still apply.
  • The scanner block only sees requests that reach WordPress. Your web server may answer some of them first. The web server lines and Cloudflare rules cover those.
  • A code by email is weaker than the phone app. Whoever has both the password and the email account gets in.
  • Cloudflare's free plan allows five custom rules and one rate limit rule. The DoctorX rules use two or three and the rate limit.
  • The web server lines are text for a person to put in place. The plugin cannot check that they were.

Will the block editor or the mobile app still work?

The block editor, yes. People who work on the site, and apps that sign in as them with an application password, still get the full list of what the site can do. A signed-in customer or subscriber gets the answer without the list, like a visitor. The list of user accounts stays readable to anybody who is signed in, as WordPress has it. Only visitors lose it. One thing changes for apps. An app that signs in with the ordinary password of an account that has two-step sign-in on is refused: give it an application password instead (see "What about apps and services that sign in with my password?" below).

My theme shows author names under each post. Do they disappear?

No. The author's display name still shows. Only the link behind it now points to the home page instead of an author page.

I use an SEO plugin that makes its own author sitemap.

This plugin only removes authors from WordPress's built-in sitemap. Turn off author sitemaps in your SEO plugin too.

Something on my site stopped finding its way after I updated.

A few outside apps, and scripts in some themes, read the list at /wp-json/ without signing in, to find out what the site offers. Untick "Hide the list of what your site can do from visitors" and it is as before. A developer can instead keep one part of the list open with the doctorx_hardening_open_rest_namespaces filter.

Which authenticator app do I need?

Any app that makes six-digit sign-in codes that change every 30 seconds. Your phone's app shop has several free ones, and most password managers do it too. Nothing has to be bought and no account has to be opened anywhere.

I lost my phone. How do I get in?

Type one of your backup codes where the sign-in page asks for the six-digit code. Each works once. Then switch two-step sign-in off under Users (or Profile) → Two-step sign-in, with another backup code, and set it up again on the new phone.

I lost my phone and my backup codes.

Somebody who may edit your account (on most sites, another administrator) can switch two-step sign-in off for you: Users, your name, "Switch it off for this account". An email about it goes to your address. If you are the only administrator, add this line to wp-config.php, above the line that says "That's all, stop editing" (your web host can do this for you): define( 'DOCTORX_HARDENING_NO_TWO_STEP', true ); Nobody is asked for a code while the line is there, on any account: every account opens with its password alone. So do it only when nobody else can know your password or the password of any other account that can change the site (if in doubt, have new passwords set first), and for as short a time as you can. Somebody who signs in while the line is there stays signed in after it is taken out, until they sign out or their password is changed. Sign in, open Users → Two-step sign-in, and press "Switch two-step sign-in off": while the line is there, that button asks for no code. Set it up again with your new phone, and take the line out.

It says "too many wrong sign-in codes", and it was not me.

Then somebody typed your password correctly and guessed at the code. The lock stopped the guessing. Use "Lost your password?" on the sign-in page to set a new password: that shuts them out and opens the lock, and you sign in with your new password and a code as usual. If the email with the link does not arrive, another administrator can set a new password for you on your profile (Users, your name), which opens the lock too. If you are the only administrator, ask your web host to set a new password for your account: hosts can do that without signing in to the site. The stranger is then out, and you sign in with the new password and a code (if the lock is still on, it opens at the time the page shows). Do not add the wp-config.php line from the answer above while somebody else knows your password. That line switches the second step off for every account, so the stranger would be signed in with the password alone. Change the password first. Use the line only for a lost phone. If your site's "Lost your password?" page belongs to a shop or membership plugin, and your WordPress is a release from before November 2024, a password set there may not open the lock. It then opens at the time shown, or when the password is changed on the profile screen.

Nobody's codes work any more.

The codes depend on the time. If everybody's codes fail at once, the clock of the website's server is probably wrong by more than half a minute: ask your web host to check it. If only yours fail, check that your phone sets its clock automatically.

Does two-step sign-in apply to everybody? Can I make it compulsory?

Each person switches it on for their own account. Settings → Hardening shows how many of the site's administrators have it on. To make it compulsory for some roles, from a date, use "Two-step sign-in required" on Settings → Hardening → Sign-in and server.

What about apps and services that sign in with my password?

An account with two-step sign-in can no longer be used with just its password by a program (XML-RPC, a script, a sign-in box that works without loading a page): there would be nowhere to ask for the code. Give each app its own application password, at the bottom of your profile (if there is no "Application Passwords" section there, another plugin or your web host has switched them off). That is safer anyway: you can take one app's key away without changing your password.

Our host changed the site's "security keys" (salts), and now nobody's codes work.

The key each app shares with the site is kept encrypted with your site's security keys. When those keys change (after a break-in, or because a host or plugin does it on a schedule), the codes can no longer be checked. The plugin notices at the next visit to the sign-in page and writes to everybody with two-step sign-in, and the page that asks for the code says what happened. Settings → Hardening says for thirty days what was done and whether everybody could be reached. (If the site's address or its folder changed at the same time, as on a copy of the site, nobody is written to. The plugin keeps a mark of the place for this, not the address, so that a copy made by replacing the address throughout the database is still told from the site itself.) Sign in with a backup code, then set it up again or switch it off with another backup code: either takes two minutes. Backup codes are not affected by the change. If a host or a plugin changes the keys on a schedule, this happens every time. Ask them to stop, or two-step sign-in is not practical on that site.

Where is the security.txt file, and why can I not see it?

At /.well-known/security.txt on your domain, which is where the standard puts it. It is served only when the site is on HTTPS and lives at the top of its domain, when a contact is set, and while its date is good. Some web servers refuse every address with "/." in it before WordPress is asked. The "Check that visitors can read it" button on the settings screen tells you, and your host can let that one address through. If a file of that name already lies on the server, it wins: the button tells you that too.

Why does the security.txt file run out?

The standard requires a date, so that nobody reports a problem to an address that stopped being read years ago. A contact you give or change is good for 360 days. You get an email and a notice on Settings → Hardening 30 days before the end. Pressing Save on the settings screen then confirms the contact for another 360 days. If you do nothing, the file is taken down on that date and comes back the moment you press Save.

I am paused by the password-guess lockout on my own site.

Wait until the time the sign-in page shows, or sign in from another network (a phone without Wi-Fi): only the address is paused, not your account. Or have your web host (or anyone with access to the server) do one of these:

  • run wp doctorx-hardening unlock --all (or unlock YOUR_ADDRESS), or wp doctorx-hardening guard off
  • add define( 'DOCTORX_HARDENING_NO_LOCKOUT', true ); to wp-config.php, above "That's all, stop editing". Nobody is paused or counted while it is there, and Settings → Hardening reminds you to take it out.
Add your office and home addresses to the trusted list so this cannot happen there.

My own address was banned by the probe ban.

Sign in from another network (a phone without Wi-Fi) and lift the ban on Settings → Hardening → Sign-in and server, or run wp doctorx-hardening unban --all (or wp doctorx-hardening unlock ADDRESS, which lifts a sign-in pause and a ban of that address) on the server, or add define( 'DOCTORX_HARDENING_NO_PROBE_BAN', true ); to wp-config.php: nobody is banned or counted while it is there.

I lost the address of the hidden sign-in door.

It was emailed to the site's administration address when it was set. Otherwise run wp doctorx-hardening door on the server to see it, wp doctorx-hardening door off to switch the door off, or add define( 'DOCTORX_HARDENING_NO_DOOR', true ); to wp-config.php: wp-login.php answers again at once.

Will any of this hurt my search ranking or AI assistants?

No part of it changes what visitors, search engines or AI assistants read on your pages. The probe ban does not count a crawler. The Cloudflare rules leave every crawler Cloudflare verifies alone. The server lines do not name a crawler to turn away. "Hide the WordPress version" changes a few characters in the addresses of WordPress's own script files, nothing that is read.

What do content policy reports keep, and can they break my pages?

They keep the day, the kind of thing that would have been blocked (the directive, such as script-src), the website it came from (only its origin, such as https://example.com), the path of the page without anything after a question mark, the browser family (such as Chrome or Firefox) and a count. They do not keep a visitor's address or full browser details, and each row goes after 30 days. The header is the report-only kind, so browsers load and run everything on the page as before. The report address takes only the shapes browsers send, small bodies and a limited number of reports a minute from one address. On a site with HTTPS, browsers send reports in small batches, about a minute after the page was seen. Switch it off on Settings → Hardening, Content policy reports, and pages made from then on carry no header. Pages kept by WP Super Cache, W3 Total Cache or LiteSpeed Cache are cleared at the same time. Clear any other page cache yourself.

Wordfence's scan runs out of memory on my site. Can this help?

When uploads holds a very large tree of picture folders (a feed's listing photos, say), Wordfence's scan walks every one of those folders and keeps what it walked in memory. On a big tree it can run out of memory and stop without finishing. With Wordfence active, this plugin looks once a day (and on its own screens) for top-level folders of uploads with 20,000 folders or more below them. The look stops counting at that number and stops after about one second in all, so it does not walk a big tree itself. The media library's year folders are not offered (nor, on a multisite network, the folders of its other sites). Other plugins can name their own picture folders with the filter doctorx_hardening_static_media_folders. The screen then says what happens, what skipping gives up and why that is safe only when PHP cannot run in uploads. What you give up: nothing in those folders is looked at by the scan any more, so a .php or .htaccess file put there, or a page made to trick people, would not be flagged. Before the button "Skip these folders in Wordfence's scan" shows, press "Check again". It puts small test files in each folder (a plain .txt, and a .php, a .phtml and a .phar), fetches them as a visitor and deletes them at once. The .txt must come back first, which proves the fetch reached that folder on this server. Then each test file must be refused (or shown as text, not run). The files are fetched from this site's own server. When uploads is served from another address (a CDN, or "Full URL path to files"), the test uses the site's own address instead, and uploads kept outside the WordPress folder cannot be tested. A password in front of the site, a firewall page or another server answering can not tell, and the button stays hidden. A firewall in front of the server that refuses .php (a Cloudflare rule, say) can make the test say "refused" while the server behind it would run PHP: the server's own rule is what matters. On Apache that reads .htaccess files, an .htaccess put into a skipped folder could switch PHP back on there, and the scan would no longer see it. Put the rule in the server's own settings where you can. Each press tests up to five folders for at most 25 seconds. Press again for the rest. This test runs only when you press the button, not by itself. Otherwise the screen asks you to put the "No PHP in uploads" rule in place first (Server rules, on the Sign-in and server tab). Once folders are skipped, the screen warns when their test is more than 7 days old, with "Check again". On a multisite network only network administrators see this and can press the buttons, because Wordfence's list holds for the whole network. The button adds two lines per folder to Wordfence's own "Exclude files from scan" list, through Wordfence itself: wp-content/uploads/<folder> (Wordfence then does not list the folder at all) and wp-content/uploads/<folder>/* (anything below it). The rest of your list stays exactly as it was, and Undo puts the list back. Nothing in Wordfence changes without the button, and without Wordfence none of this runs. Deleting this plugin leaves the lines in Wordfence's list. Remove them there if you want. This plugin's own daily self-check does not walk such a folder either. When a look runs out of time, the folders it did not reach go first next time and the folder it was counting goes last, counted again from the start. A folder cut short twice in a row with a quarter of the 20,000 folders already counted is taken as a large tree. So on a slow disk that has not been read for a while it may take a few looks (days) to see a large folder.

What happens when I delete the plugin?

Its settings are removed (on a multisite network, on every site). So are the sign-in guard's settings, the paused and banned addresses and the sealed Cloudflare token. The rules already at Cloudflare stay there: remove them with Undo first if you want them gone. Everything kept for two-step sign-in on every account is removed too, and so is the activity record with its events. (Simple History's own tables, if you still have them, are left alone.) The down page files, the db-error.php this plugin wrote, the content policy reports, the visitor counts and the city file are removed too. Signing in then takes only the password again. Deactivating without deleting keeps everything for when you switch it back on. While it is deactivated nobody is asked for a code, and when it is deactivated on the Plugins screen everybody who had two-step sign-in is told by email.

What does the activity record keep, and for how long?

Each event says what happened, when, who did it (a signed-in person, an anonymous visitor, WordPress itself, or WP-CLI), the address the request came from, the browser's name, and the details of what changed (a post's title before and after, a plugin's version before and after). Addresses are kept without their last part unless you choose to keep them whole. Events are removed after the number of days you choose (60 unless you change it), once a day, and the removal is itself recorded. Administrators read everything. Editors read the events about what they can change themselves. Addresses are shown to administrators only.

I used Simple History. Do I lose its log?

No. Switch the activity record on, then press "Bring in Simple History's events" on Settings → Hardening (or run "wp doctorx-hardening activity import"). Every event comes over with its date, address, details and who did it. Pressing it again brings in only what is new. Simple History's own tables are not changed, so switching back is reactivating it. Code written for Simple History ("do_action( 'simple_history_log', ... )") keeps being recorded once Simple History is gone.

Can it tell me when something happens?

Yes. On the activity record's "More settings" screen, add a destination: an email address, a Slack, Discord or Microsoft Teams webhook, a Telegram bot, or any webhook. Then add a rule. It can be a ready one (security, content, updates, failed sign-ins, plugins installed, somebody made an administrator) or your own (kinds of events, the lowest level, who did it, words). "Alert me about events like these" on the record makes a rule from what you searched. Each rule sends at most the number of alerts an hour you set, and a run of failed sign-ins alerts at the 1st, 10th, 100th attempt. Nothing is sent until you switch alerts on.

Can it send the record to our log service?

Yes: syslog (this server's, or another over UDP, TCP or TLS), Datadog, Splunk or any webhook. Keys, tokens and passwords are kept sealed and are not shown again. Events are sent once the page has answered, at most 50 a request. What a request cannot send (more events, a destination that is down) waits, and is sent in order by a scheduled job that exists only while forwarding is on and something waits. At most 5,000 events wait for each destination. Past that the oldest are dropped, and the screen, wp doctorx-hardening activity forward list and the activity record say how many. Events made by backfill are not forwarded. Events dated in the past by hand also wait their turn (at most 500 a destination). Delivery is "at least once": after a failure half-way an event can arrive twice. So every event carries a delivery id that a receiver can use to drop repeats. It is the "uid": your site, the event's number and its count. Webhooks also get it in the X-DRX-Event-Id header. Destinations on this server itself or on link-local addresses (such as a cloud metadata service) are refused. A destination's name is looked up once and the connection goes to the address that was checked. A name that cannot be found is not sent to. TLS certificates are checked, for syslog over TLS and for the database with TLS, against the certificates WordPress trusts. Code can name your own CA file with the filter doctorx_hardening_activity_ca_file. A website set up not to send (the line define( 'DOCTORX_HARDENING_MAY_CONNECT', false ); in wp-config.php) sends no alert, forwards nothing and looks nothing up.

Does it look up where an address is?

Only if you choose how. It can use a database file on your server (MaxMind GeoLite2, DB-IP Lite or IPinfo's .mmdb), and then nothing leaves the server. Or it can use ipinfo.io with your own token, and then only when an administrator opens an address (not on a website set up not to send). Out of the box nothing is looked up.

Does the activity record slow the site down?

Not for visitors: nothing of it runs on a page view. A failed sign-in costs one database write. A run of them from one address is counted on one line.

What happens to its data when a site of a network is deleted?

The activity record of that site and the notes kept on accounts for that site go with the site, as when the plugin is deleted. Two-step sign-in belongs to each account on the whole network, so it stays for the other sites. WordPress removes the site's settings and uploaded files itself.

What does "Where visitors come from" keep?

Only the city and the country of each visitor, counted per day, for 31 days. No address, no visitor record and nothing that names a person is kept. The visitor's address is looked up in the city file on your server and then forgotten. To count each visitor once a day, the browser keeps a small cookie that holds only the date, the same for everybody. Search engines and other known crawlers, scripts, the site's own requests, sign-in pages, feeds and missing pages are not counted. Each page asks your site once a day to count the visitor (one small request to the site's own address), so pages served from a page cache are counted too. A visitor whose browser runs no scripts is not counted, and one whose browser refuses cookies is counted at each page. At most 30 visitors in 5 minutes are counted from one address. For that limit the site keeps a scrambled form of the address for 5 minutes, never the address itself. The look-up is made after that small answer is sent where the server allows it. The city file (about 120 MB) is kept in your uploads folder, in a folder closed to the web under a random name. On a network each site has its own switch, file and counts. "Delete the city database and the counts" removes all of it. While counting is on, a paragraph about it is added to the suggested text of your privacy policy (Settings → Privacy).

Privacy: what does it keep about people, and where does it go?

  • For each account with two-step sign-in the plugin keeps, in your own database:
  • the key shared with the authenticator app (encrypted)
  • hashes of the backup codes
  • the day it was switched on, and which code was used last
  • the times of recent wrong codes (those older than a day are removed the next time a code is typed for the account)
  • when the account was last warned by email.
While somebody sets it up, the new key is kept (encrypted) until they finish or cancel. New backup codes are kept (encrypted) for up to ten minutes, until the screen has shown them once. A sign-in that is waiting for its code can be used for ten minutes, and keeps the address the person was on their way to. WordPress clears the stored note away later, with its other short-lived notes. After a change of the site's security keys, the names of up to twenty people who could not be told by email are kept for the settings screen, which shows them for thirty days. They are removed at the first visit to the sign-in page after those thirty days. * It emails the account's own address when two-step sign-in is switched on or off for the account, when a backup code is used, when a wrong code is typed after the right password (once a day at most), when wrong codes lock the second step, when the site's security keys were changed, and when two-step sign-in stops for the whole site. * The contact you give for security.txt is published in that file for anybody to read. Use an address meant for that. * The activity record (when you switch it on) keeps, in your own database, what is described under "What does the activity record keep" above, for the number of days you choose. It adds a paragraph about itself to the suggested text of your privacy policy (Settings → Privacy). It takes part in WordPress's "Export Personal Data" and "Erase Personal Data" tools: erasing takes the person's name, address and browser out of their events. Notes a person wrote on events, and notes or entries added by hand that name their email address, are in their export. Erasing takes them off as the notes' writer and takes the address out of those words, and leaves other people's events their own details. The weekly email (if you switch it on) goes to the addresses you give. The feed (if you switch it on) is readable by whoever has its secret. Alerts and forwarding (if you switch them on and set a destination up) send events, with the person's name and address, to the services you choose. The suggested privacy text then names them. Looking up where an address is sends it to ipinfo.io only if you choose that and only when an administrator opens it. * Content policy reports (when you switch them on) keep the day, what would have been blocked, the website it came from, the page's path, the browser family and a count, for 30 days. No visitor address is kept. * "Where visitors come from" (when you switch it on) counts only cities and countries: no address, no visitor record, nothing that names a person. Its cookie holds only the date. * Nothing is sent to DoctorX.ca or to anybody else. "Check that visitors can read it" makes your site fetch its own file.

更新日志:

0.15.2 0.15.1 0.15.0 0.13.2 0.13.1 0.13.0 0.12.1 0.11.1 0.11.0 0.9.9 0.9.1 0.9.0 0.8.0 0.7.5 0.7.1 0.6.9 0.6.8