前面说了wp-admin这个目录是静态的。所以任何一个人都能访问到你的后台入口,然后枚举密码(WP最新版本依然很容易枚举,算是个BUG把)

所以,如果你不愿意修改源代码的话,可以尝试后台2次鉴权。也就是在进入后台之前,设置一道密码。如果对方没法过这关,就连才密码的权力都没有。听起来不错把,那么我们就开始吧!

注意,这次我们要新建一个.htaccess文件,将他放在wp-admin目录下面。
输入以下内容


AuthType Basic
AuthName "这里输入你的提示语,用英文或者拼音,中文是无法显示的"
AuthUserFile 写上密码文件的绝对地址
Require valid-user

看到这里,你或许会问,密码文件是什么?

密码文件就是用来存放密码的,不过为了安全考虑,这个文件进行了一点点加密

下面我们就来制作一个加密文件

我们需要apache的htpasswd工具,如果你没有安装Apache的http server,可以从这里下载

先看功能介绍:

c:\Apache\bin>htpasswd** /?
Usage:
htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don't update file; display results on stdout.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.

如果你懒得看这些,可以直接在命令提示符下执行如下指令(由于本地环境不同请勿直接复制)

c:\Apache\bin>htpasswd** -c -s c:\password.txt test123
New password: *******
Re-type new password: *******
Adding password for user test123

这样,我们就在c:\password.txt文件中,存放了一个test123的用户

回到刚才的.htaccess文件
我们进行如下修改

AuthType Basic
AuthName "这里输入你的提示语,用英文或者拼音,中文是无法显示的"
AuthUserFile c:\password.txt
Require valid-user

这个时候,你就可以登陆浏览器测试一下了。是不是感觉很不错呢!

One Comment

  • 艾可优说道:

    😉 呵呵,现在还用不到,就平时写写感想之类的,也不怕有人恶意来搞破坏,以后再说

  • 发表回复