Home Web Front-end JS Tutorial How to deal with http hijacked floating ads

How to deal with http hijacked floating ads

Apr 19, 2018 am 11:04 AM
http hijack float

This time I will bring you how to deal with http being hijackedfloatingadvertisements, what are the precautionsfor dealing with http being hijacked floating ads, the following is a practical case, one Get up and take a look.

Recently, I discovered that a floating advertisement often pops up in the lower right corner of the website. At first, I thought it was just a browser advertisement.

Later, more and more colleagues reported that advertisements would appear in different browsers at home. Then I checked in depth and found that the website had been hijacked.

Then Baidu searched a lot of information, such as http hijacking, dns hijacking, operator hijacking, etc., and I was sure that I had been tricked.

It’s really an understatement, the advertising code has been inserted. What an unscrupulous businessman, he can do anything.

However, what is the most important solution? Then the problem was thrown to the operation and maintenance colleagues.

The end result is that there is no solution. Yes, it's such a cheat. Unless https is used. Making phone calls and sending complaints online seems to be of no use. Maybe the operation and maintenance is too bad. Anyway, the result is nothing.

Then, there was nothing we could do. We can only find a way to block it on our own as a big front end. Then started the journey of researching hijacking codes,

...the process omits the 800-word search process.

Finally, it was discovered that the hijacked advertisement would define a js global variable _pushshowjs_, which stores some information about the hijacked advertisement, and then create a p with the ID of _embed_v3_dc to put the advertisement. And it will be the same every time, there will be no changes.

According to the delivery principle of hijacked advertisements, the js method of blocking hijacked advertisements was finally used.

The specific code is as follows:

;(function($,window,undefined){
 var needClear=false,
  timeout;
 if(window._pushshowjs_){
  console.log("adHttp");
  needClear=true;
 }
 window._pushshowjs_={};
 Object.freeze(window._pushshowjs_);//让对象只读, 防止属性被直接修改
 Object.defineProperty(window, '_pushshowjs_', {
  configurable: false,//防止属性被重新定义
  writable: false//防止属性被重新赋值
 });
 if(needClear){
  timeout=setInterval(function(){
   if($("#_embed_v3_dc").length>0){
    $("#_embed_v3_dc").remove();
    console.log("http清除");
    needClear=false;
    clearInterval(timeout);
   }
  },500);
  $(window).load(function(){
   if(needClear){
    setTimeout(function(){
     clearInterval(timeout);
     console.log("清除");
    },2000);
   }
  });
 }
}(jQuery,window));
Copy after login

There is not much code, so I won’t analyze it in detail (if you think there is something wrong with the code, please correct me). To put it simply, set the global js variable _pushshowjs_ necessary to hijack advertisements to be unmodifiable and read-only. If you find ads, clear them.

I released the code and finally said 88 to the hijacked advertisement.

Why do you say it's a stupid way?

Because this is just self-deception. In fact, hijacking still exists, and the loading order of hijacked js may change and cause errors. The ideal solution is to rely on operation and maintenance and operators to solve it or use https.

The advertising logic of each hijack should be similar, but the advertising code will be different. So this may not be applicable to other hijacking ads. This is just an idea, a solution among all solutions.

If anyone has a better solution, please give me some advice.

The above method of using js to block floating ads hijacked by http is all the content shared by the editor. I hope it can give you a reference, and I hope you will support Yiju Tutorial Network.

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Detailed explanation of the use of Vue scope slots

JS implementation of data validation and check box form submission

JS to easily implement carousel images


The above is the detailed content of How to deal with http hijacked floating ads. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does http status code 520 mean? What does http status code 520 mean? Oct 13, 2023 pm 03:11 PM

HTTP status code 520 means that the server encountered an unknown error while processing the request and cannot provide more specific information. Used to indicate that an unknown error occurred when the server was processing the request, which may be caused by server configuration problems, network problems, or other unknown reasons. This is usually caused by server configuration issues, network issues, server overload, or coding errors. If you encounter a status code 520 error, it is best to contact the website administrator or technical support team for more information and assistance.

What is http status code 403? What is http status code 403? Oct 07, 2023 pm 02:04 PM

HTTP status code 403 means that the server rejected the client's request. The solution to http status code 403 is: 1. Check the authentication credentials. If the server requires authentication, ensure that the correct credentials are provided; 2. Check the IP address restrictions. If the server has restricted the IP address, ensure that the client's IP address is restricted. Whitelisted or not blacklisted; 3. Check the file permission settings. If the 403 status code is related to the permission settings of the file or directory, ensure that the client has sufficient permissions to access these files or directories, etc.

Understand common application scenarios of web page redirection and understand the HTTP 301 status code Understand common application scenarios of web page redirection and understand the HTTP 301 status code Feb 18, 2024 pm 08:41 PM

Understand the meaning of HTTP 301 status code: common application scenarios of web page redirection. With the rapid development of the Internet, people's requirements for web page interaction are becoming higher and higher. In the field of web design, web page redirection is a common and important technology, implemented through the HTTP 301 status code. This article will explore the meaning of HTTP 301 status code and common application scenarios in web page redirection. HTTP301 status code refers to permanent redirect (PermanentRedirect). When the server receives the client's

HTML, CSS and jQuery: Make a button with a floating effect HTML, CSS and jQuery: Make a button with a floating effect Oct 24, 2023 pm 12:09 PM

HTML, CSS and jQuery: Making a button with a floating effect requires specific code examples. Introduction: Nowadays, web design has become an art form. By using technologies such as HTML, CSS and JavaScript, we are able to add various aspects to the page. Such special effects and interactive effects. This article will briefly introduce how to use HTML, CSS and jQuery to create a button with a floating effect, and provide specific code examples. 1. HTML structure First, we need to

How to use Nginx Proxy Manager to implement automatic jump from HTTP to HTTPS How to use Nginx Proxy Manager to implement automatic jump from HTTP to HTTPS Sep 26, 2023 am 11:19 AM

How to use NginxProxyManager to implement automatic jump from HTTP to HTTPS. With the development of the Internet, more and more websites are beginning to use the HTTPS protocol to encrypt data transmission to improve data security and user privacy protection. Since the HTTPS protocol requires the support of an SSL certificate, certain technical support is required when deploying the HTTPS protocol. Nginx is a powerful and commonly used HTTP server and reverse proxy server, and NginxProxy

Send POST request with form data using http.PostForm function Send POST request with form data using http.PostForm function Jul 25, 2023 pm 10:51 PM

Use the http.PostForm function to send a POST request with form data. In the http package of the Go language, you can use the http.PostForm function to send a POST request with form data. The prototype of the http.PostForm function is as follows: funcPostForm(urlstring,dataurl.Values)(resp*http.Response,errerror)where, u

HTTP 200 OK: Understand the meaning and purpose of a successful response HTTP 200 OK: Understand the meaning and purpose of a successful response Dec 26, 2023 am 10:25 AM

HTTP Status Code 200: Explore the Meaning and Purpose of Successful Responses HTTP status codes are numeric codes used to indicate the status of a server's response. Among them, status code 200 indicates that the request has been successfully processed by the server. This article will explore the specific meaning and use of HTTP status code 200. First, let us understand the classification of HTTP status codes. Status codes are divided into five categories, namely 1xx, 2xx, 3xx, 4xx and 5xx. Among them, 2xx indicates a successful response. And 200 is the most common status code in 2xx

Quick Application: Practical Development Case Analysis of PHP Asynchronous HTTP Download of Multiple Files Quick Application: Practical Development Case Analysis of PHP Asynchronous HTTP Download of Multiple Files Sep 12, 2023 pm 01:15 PM

Quick Application: Practical Development Case Analysis of PHP Asynchronous HTTP Download of Multiple Files With the development of the Internet, the file download function has become one of the basic needs of many websites and applications. For scenarios where multiple files need to be downloaded at the same time, the traditional synchronous download method is often inefficient and time-consuming. For this reason, using PHP to download multiple files asynchronously over HTTP has become an increasingly common solution. This article will analyze in detail how to use PHP asynchronous HTTP through an actual development case.

See all articles