Method for injecting advertisements based on Openwrt router

A router and advertising technology, which is applied in the field of embedded software design and intelligent router, can solve the problems of large user influence and inconvenient local management, and achieve the effect of fast access speed and convenient modification

Inactive Publication Date: 2016-06-08
UNIV OF SCI & TECH OF CHINA
5 Cites 14 Cited by

AI-Extracted Technical Summary

Problems solved by technology

At present, the implementation of advertisement injection mostly adopts the method of replacing web pag...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Method used

After transplanting Privoxy on the Openwrt router, by HTTP port redirection, guarantee that the request data of user can first arrive at the local agent of router before reaching browser, after local agent completes the processing to data, then data is forwarded to user. After the data arrives at the local agent, by searching for the specified HTML tag...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Abstract

The invention provides a method for injecting advertisements based on an Openwrt router. The method comprises the steps that 1, Web service is performed on a local terminal of the Openwrt router, and local storage of advertisement resource and rapid access inside a local area network are achieved; 2, injection of designated advertisement content inside the local area network is achieved, network firewall of the system is utilized for terminal redirection, unified management of access data of a user is achieved, designated tags are searched for and replacement operation is performed by analyzing HTML data returned by a website, the modified data are pushed to the user inside the local area network, and therefore injection of advertisement codes inside the webpage and display of advertisement content on a user browser inside the local area network can be achieved. All the advertisement resources are stored on the local router, modification and updating can be performed conveniently, meanwhile, the access speed is high, and the normal webpage browsing speed of the user is not affected basically. All the functions can be achieved on the Openwrt router, no extra equipment support is needed.

Application Domain

Technology Topic

Rapid accessLocal area network +2

Image

  • Method for injecting advertisements based on Openwrt router

Examples

  • Experimental program(1)

Example Embodiment

[0015] The present invention will be further explained below in conjunction with the drawings.
[0016] The technical scheme of the present invention is divided into two parts. The first part implements Web services at the local end of the Openwrt router to realize local storage of advertisement resources and access in the local area network; the second part is to realize the injection of specified advertisement content in the local area network, using the system's own The network firewall performs port redirection to realize the unified management of user access data. By parsing the HTML data returned by the website, searching for designated tags and performing replacement operations, the modified data is pushed to the users in the local area network to realize the advertisement code in the web page. Injection and display of advertising content on the user’s browser within the local area network.
[0017] 1) Implementation of the local web service of the router
[0018] The Openwrt router itself provides uhttpd services, supports CGI, Lua scripts and static files, and is used to implement the router's web management interface. Use the uhttpd service to add a new Web server, so that the advertisement resource files are stored locally for users to access, in preparation for the realization of advertisement injection. At the same time, local management of advertising resources is realized, facilitating subsequent addition and modification of content.
[0019] 2) Advertising injection in the local area network
[0020] Advertisement injection is mainly aimed at the user's web browsing behavior and is carried out for the HTTP protocol. When users in the local area network use a browser to access the website, the general access mode is "Browser-WebServer". In order to manage user access behavior, we deploy Privoxy on the router for proxy access, so that the user's access mode becomes "browser-Privoxy-WebServer". Using port redirection, management and control of all HTTP access behaviors in the LAN can be achieved. Before the webpage data is sent to the user, the Openwrt router searches and replaces the specific tag content in the HTML data, and sends the HTML data with the advertisement resource request code to the user, so as to ensure that the user browses the webpage normally. Realize the effect of advertising push. The specific flowchart is as figure 1 Shown:
[0021] Step 1: The website returns the web page data requested by the user, and the data reaches the router;
[0022] Step 2: The HTTP protocol uses port 80 for communication by default. By writing the router's Iptable rules, the data on port 80 is redirected to the designated port (for example, 8118), so as to realize the management of the web access behavior of LAN users;
[0023] Step 3: Search and label in webpage data;
[0024] Step 4: Perform a replacement operation on the first label found, introduce the local link address of the JS file and the CSS file required for advertisement display before; introduce the advertisement window code before, thereby inject the advertisement module into the original webpage file.
[0025] Step 5: The webpage file injected with the advertising code is pushed to the user, and the user's browser displays the original requested page;
[0026] Step 6: According to the link in the webpage, request the JS, CSS and image file resources needed for the advertisement from the router's local server;
[0027] Step 7: Display advertising content on the web page.
[0028] Examples of implementation are as follows:
[0029] After transplanting Privoxy on the Openwrt router, redirect through the HTTP port to ensure that the user's request data will first reach the router's local proxy before reaching the browser. After the local proxy completes the processing of the data, it will forward the data to the user. After the data arrives at the local agent, it searches for the specified HTML tags and replaces them with regular expressions to realize the code injection and complete the placement of the ad code without affecting the display of the original web page. Because the resource files required for advertisements are stored locally, the access speed is faster, and the resource content is also easy to manage and update.
[0030] 1. Establishment of Openwrt local web server
[0031] uhttpd is the Web server used by Openwrt by default. It supports CGI (CommonGatewayInterface), Lua scripting language and static web file services, and can provide streamlined Web services for routers. In order to store advertising resources locally on the Openwrt router and provide access to LAN users, we use uhttpd to build a new web server locally on the router. In the /etc/config/uhttpd file, a web server named "main" has been configured by default, using port 80, which corresponds to the Openwrt web management interface. We create a new web server, use port 88 to communicate and set the router's local file directory, so that the local web server's resources can be accessed through 192.168.1.1:88. We compile the JS files, CSS files and image resources needed for advertising display, and save them in the directory designated by the web server for users in the local area network to access.
[0032] 2. Injection of advertising code
[0033] In order to realize the interception and modification of users' web browsing data on the Openwrt router, we first transplanted and installed Privoxy in Openwrt to realize the router's local proxy access, and used Iptable rules to realize the redirection of the HTTP access port, thus changing the user's access mode to the website from " "Browser-WebServer" becomes "Browser-Router Proxy-WebServer", which provides the possibility of advertising code injection.
[0034] In HTML, pairs of tags are usually used to identify the beginning and end of a region. A simple web page usually contains tags such as, and. Tags describe various attributes and information of web documents, and also include references to external files; tags define the specific content of the document. Through various tags in the web page, we can implement positioning operations in HTML.
[0035] When the HTTP data returned by the website to the user arrives at the proxy server, it uses Privoxy’s support for regular expressions to add the specified HTML code before the tag and to inject the advertisement into the required resource files, JS files, CSS files and HTML codes. The user’s original HTML page file. Two replacement commands need to be used here. The first replacement command adds access to the file resources under the local ad server 192.168.1.1:88 in the original web page, so as to push custom JS files and CSS files to users; the second one The replacement command is to add some HTML codes to the original web page. These newly added HTML codes call CSS files and JS files to realize the display of advertising modules.
[0036] Write the above operation code into Privoxy's user.filter, and use the {+filter{rule name}} command to introduce the above rules in user.action. It can be found that when all web pages are displayed normally, an advertisement module will appear , The content of the advertising module comes from the local web server of the Openwrt router. In addition, router administrator users can modify JS and CSS files to achieve different display effects, and modify pictures to achieve different display content.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Similar technology patents

Classification and recommendation of technical efficacy words

  • Easy to modify
  • Fast access

Closed-loop testing system for simulating static synchronous compensator and testing method of same

InactiveCN102401863AEasy to modifyMeet precise modelingElectrical testingDevice parametersControl mode
Owner:ELECTRIC POWER RESEARCH INSTITUTE, CHINA SOUTHERN POWER GRID CO LTD

Multifunctional gate inhibition machine

InactiveCN101161980ATight blockadeFast accessGates/doorsPower-operated mechanismEngineeringIdentification device
Owner:张发胜
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products