Malicious anti-brush of Terry tribe

Throw in a peach and return it with a courtesy. For those who maliciously brush my interface, I will come to prevent malicious brushing, it is not too much!

First upload a picture to see what this kind of people are doing. There are many such people. They usually do things in the middle of the night. They are all very stupid. They have brains but not many of them!

insert image description here
insert image description here
insert image description here
insert image description here

If you make trouble, I will add you to the blacklist. It is fair. Take a screenshot to see the effect

insert image description here

Users who have been listed in the blacklist visit the website again, and the interface looks like this, not fancy, simple and rude

insert image description here

implement logic

I allow you to deliberately visit the wrong address three times. The first path is error, I set it to jump to 404, the second and third times it jumps to fuck, and the fourth time it is directly printed by the filter and added to the blacklist

  1. Create an interceptor
public class GlobalInterceptor implements HandlerInterceptor

insert image description here

The interception time can be set according to your own wishes, or it can be set to be permanent, or create a blacklist table and add them to the database, I am lazy here

  1. Create intercept configuration
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    
    

    @Autowired
    private GlobalInterceptor globalInterceptor;

    // 对除静态资源外所有路径进行拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    
    
        registry
            .addInterceptor(globalInterceptor)
            .excludePathPatterns(
                "/css/**",
                "/js/**",
                "/image/**",
                "/font/**",
                "/icon/**",
                "/layui/**",
                "/font-awesome/**",
                "/editormd/**"
            );
    }
}
  1. Cooperate with filter to achieve interception effect

insert image description here

final effect

  • first malicious visit
    insert image description here
  • The second and third times were maliciously accessed

insert image description here

  • Finally, directly prompt to join the blacklist

insert image description here

Guess you like

Origin blog.csdn.net/u011277745/article/details/130758604