CN107733633A - 一种基于算力的防爬虫方法 - Google Patents
一种基于算力的防爬虫方法 Download PDFInfo
- Publication number
- CN107733633A CN107733633A CN201710863740.1A CN201710863740A CN107733633A CN 107733633 A CN107733633 A CN 107733633A CN 201710863740 A CN201710863740 A CN 201710863740A CN 107733633 A CN107733633 A CN 107733633A
- Authority
- CN
- China
- Prior art keywords
- client
- key
- webpage
- decryption
- javascript
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0618—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
- H04L9/0631—Substitution permutation network [SPN], i.e. cipher composed of a number of stages or rounds each involving linear and nonlinear transformations, e.g. AES algorithms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/04—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks
- H04L63/0428—Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks wherein the data content is protected, e.g. by encrypting or encapsulating the payload
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/10—Network architectures or network communication protocols for network security for controlling access to devices or network resources
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L63/00—Network architectures or network communication protocols for network security
- H04L63/14—Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
- H04L63/1441—Countermeasures against malicious traffic
- H04L63/145—Countermeasures against malicious traffic the attack involving the propagation of malware through the network, e.g. viruses, trojans or worms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/0618—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation
- H04L9/0625—Block ciphers, i.e. encrypting groups of characters of a plain text message using fixed encryption transformation with splitting of the data block into left and right halves, e.g. Feistel based algorithms, DES, FEAL, IDEA or KASUMI
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L9/00—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
- H04L9/06—Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols the encryption apparatus using shift registers or memories for block-wise or stream coding, e.g. DES systems or RC4; Hash functions; Pseudorandom sequence generators
- H04L9/065—Encryption by serially and continuously modifying data stream elements, e.g. stream cipher systems, RC4, SEAL or A5/3
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/02—Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Hardware Design (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Virology (AREA)
- Storage Device Security (AREA)
Abstract
本发明公开了一种基于算力的防爬虫方法,在服务器端生成客户端请求的页面;将网页使用随机生成的密钥及加密算法进行加密,并生成解密的JavaScript代码,包括一个与正确解密密钥邻近或相关联的密钥;客户端接收到请求后,执行JavaScript解密代码,通过暴力尝试将网页解密;通过浏览器渲染解密后的网页。本发明采用将网页加密并返回加密后的页面和解密代码,让客户端暴力尝试解密密钥,通过调整加密强度,可不同程度消耗客户端CPU资源,避免同一客户端在短时间内大量抓取网站内容,有效缓解大规模的网络爬虫对服务器资源的消耗。
Description
技术领域
本发明涉及防爬虫技术领域,具体为一种基于算力的防爬虫方法。
背景技术
目前传统的防爬虫系统通常采用IP黑名单、User-Agent及其他访问参数黑名单、请求频率、各种交互类型的验证码等对网络爬虫进行限制。
采用IP黑名单的方法,WEB服务器在收到一个请求时,先计算出这个请求IP的访问频率,超过设定的阈值时,向客户端返回错误信息提示页面。但是,在NAT网络环境下可能出现误报,而且通过使用代理IP,可以绕过IP访问频率限制,防护效果不是很理想。
采用User-Agent的方法,通过WEB访问日志或抓包获取部分网络爬虫的请求特征(User-Agent及其他HTTP请求头信息),设置相应的拦截规则,拦截网络爬虫的请求。但是,User-Agent及HTTP请求头信息都可以自定义,通过随机化这些值,就可绕过设置的网络爬虫拦截规则,防护效果也不理想。
使用其他形式的验证码进行人机识别时,由于网络爬虫不能直接输入正确的验证码,所以网络爬虫不能对网站内容进行抓取。对正常访问的用户体验不好,需要频繁的输入验证码。
术语解释:
网络爬虫:一种按照一定的规则,自动地抓取万维网信息的程序或者脚本。
NAT网络:通过网络地址转换技术使用少量的公有IP地址代表较多的私有IP地址。即大量设备共享同一个共有IP。
算力:计算机的运算能力。
发明内容
针对上述问题,本发明的目的在于提供一种采用加密响应内容,让客户端暴力尝试解密,以消耗网络爬虫的CPU资源,避免网络爬虫在短时间内大量抓取网站内容的基于算力的防爬虫方法。技术方案如下:
一种基于算力的防爬虫方法,包括以下步骤:
步骤1:在服务器端生成客户端请求的页面;
步骤2:将网页使用随机生成的密钥及加密算法进行加密,并生成解密的JavaScript代码。
进一步的,所述解密的JavaScript代码包括一个与正确解密密钥邻近或相关联的密钥。
更进一步的,所述加密算法采用AES加密算法、RSA加密算法、DES加密算法或RC4加密算法。
更进一步的,所述步骤2之后还包括:
步骤3:客户端接收到请求后,执行JavaScript解密代码,通过暴力尝试将网页解密;
步骤4:通过浏览器渲染解密后的网页。
本发明的有益效果是:
本发明采用将网页加密并返回加密后的页面和解密代码,让客户端暴力尝试解密密钥,通过调整加密强度,可不同程度消耗客户端CPU资源,避免同一客户端在短时间内大量抓取网站内容,有效缓解大规模的网络爬虫对服务器资源的消耗。
附图说明
图1为本发明基于算力的防爬虫方法的步骤流程图。
具体实施方式
下面结合具体实施例对本发明做进一步详细说明。本发明主要用于WEB服务器,通过客户端算力解密服务器端返回的加密页面,用于缓解网络爬虫对服务器资源的消耗及网络爬虫对网页内容进行拷贝。流程图如图1所示,具体步骤如下:
步骤一:在服务器端生成客户端请求的页面。
如客户端发起如下请求:
正常情况下,WEB服务器会读取文件index.html的内容并返回给客户端。此时生成的响应页面假设为:
步骤二:将网页使用随机生成的密钥及高强度的加密算法加密,并生成解密的JavaScript代码。
解密的JavaScript代码包含一个与正确解密密钥邻近或与正确解密密钥存在一定关系的密钥。
此处以AES(Advanced Encryption Standard高级加密标准)加密算法为例,在实际实施过程中,可替换其他加密算法,如RSA加密算法、DES(Data Encryption Standard,数据加密标准)、RC4加密算法等。响应体中,“This is html body.”是HTML的BODY部分。使用AES算法加密BODY内容,随机设置一个密钥,此处假设为:1000334,加密后结果为:
U2FsdGVkX1+pCGfezMQLG2rtuT5ZvG+gpS23i0KEnbhg4qJO4eB2c9KTwRMfJo5XKPk1xmPWrgIXX4jiS66R9DYoKeUDwfpYG+R38sTUYBw=
将加密后的结果替换成原始的BODY,再加入解密算法,并设置一个初始的与正确解密密钥邻近或相关联的解密密钥,如1000000。
最终返回给客户端的响应内容为:
此时,若是普通的网络爬虫,不会进行下面的步骤三和步骤四,所以抓取到的页面为加密后的内容,没有实际意义。若是有执行Javascript代码能力的爬虫,则会执行解密操作,但一次解密操作会一定消耗CPU资源和时间,具体根据初始密钥和正确密钥的差距。所以网络爬虫无法在短时间内解密大量加密页面,从而缓解了网络爬虫对网络服务器资源的消耗和内容拷贝。
步骤三:客户端接收到请求后,执行Javascript解密代码,虽然没有正确的密钥,但存在一个与正确密钥相关的有关的密钥,通过暴力尝试可将网页解密。
本实施例,初始密钥设置为1000000,正确的密码为1000334,客户将根据解密代码中设置的方法(递增)暴力尝试密钥。在实际实施过程中,可换做其他密钥变换方式(如哈希碰撞、大数因数分解等),防止攻击者采用二分法或其他方法跳过部分密钥以减少尝试次数。
客户端在尝试334次解密后,最终成功的解密出原始的BODY内容,将HTML中的密文的替换成解密后的结果。
步骤四:浏览器渲染解密后的网页。
本实施例采用加密响应内容,让客户端暴力尝试解密,可消耗网络爬虫的CPU资源,避免网络爬虫在短时间内大量抓取网站内容。
Claims (4)
1.一种基于算力的防爬虫方法,其特征在于,包括以下步骤:
步骤1:在服务器端生成客户端请求的页面;
步骤2:将网页使用随机生成的密钥及加密算法进行加密,并生成解密的JavaScript代码。
2.根据权利要求1所述的基于算力的防爬虫方法,其特征在于,所述解密的JavaScript代码包括一个与正确解密密钥邻近或相关联的密钥。
3.根据权利要求2所述的基于算力的防爬虫方法,其特征在于,所述步骤2之后还包括:
步骤3:客户端接收到请求后,执行JavaScript解密代码,通过暴力尝试将网页解密;
步骤4:通过浏览器渲染解密后的网页。
4.根据权利要求1所述的基于算力的防爬虫方法,其特征在于,所述加密算法采用AES加密算法、RSA加密算法、DES加密算法或RC4加密算法。
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710863740.1A CN107733633B (zh) | 2017-09-22 | 2017-09-22 | 一种基于算力的防爬虫方法 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710863740.1A CN107733633B (zh) | 2017-09-22 | 2017-09-22 | 一种基于算力的防爬虫方法 |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107733633A true CN107733633A (zh) | 2018-02-23 |
CN107733633B CN107733633B (zh) | 2020-11-10 |
Family
ID=61207721
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710863740.1A Active CN107733633B (zh) | 2017-09-22 | 2017-09-22 | 一种基于算力的防爬虫方法 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107733633B (zh) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108429757A (zh) * | 2018-03-26 | 2018-08-21 | 成都睿码科技有限责任公司 | 一种保护网站资源的反爬方法 |
CN109768973A (zh) * | 2018-12-28 | 2019-05-17 | 易票联支付有限公司 | 一种安全公告的发布监控方法、系统及装置 |
WO2020019477A1 (zh) * | 2018-07-27 | 2020-01-30 | 平安科技(深圳)有限公司 | 通信数据加密方法和装置 |
CN111666465A (zh) * | 2019-03-06 | 2020-09-15 | 上海晶赞融宣科技有限公司 | 爬取数据的方法及装置、存储介质、终端 |
CN114338146A (zh) * | 2021-12-27 | 2022-04-12 | 中国民航信息网络股份有限公司 | 一种基于动态码的反爬虫方法、系统、客户端和服务器 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100005311A1 (en) * | 2007-03-30 | 2010-01-07 | Fujitsu Limited | Electronic-data authentication method, Elctronic-data authentication program, and electronic-data, authentication system |
CN101635622A (zh) * | 2008-07-24 | 2010-01-27 | 阿里巴巴集团控股有限公司 | 一种网页加密和解密的方法、系统及设备 |
CN102624931A (zh) * | 2012-04-21 | 2012-08-01 | 华为技术有限公司 | Web客户端与服务器交互的方法、装置及系统 |
CN103780375A (zh) * | 2012-10-19 | 2014-05-07 | 中国电信股份有限公司 | 数据发送方法和装置、数据接收方法和装置 |
US20140282877A1 (en) * | 2013-03-13 | 2014-09-18 | Lookout, Inc. | System and method for changing security behavior of a device based on proximity to another device |
-
2017
- 2017-09-22 CN CN201710863740.1A patent/CN107733633B/zh active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100005311A1 (en) * | 2007-03-30 | 2010-01-07 | Fujitsu Limited | Electronic-data authentication method, Elctronic-data authentication program, and electronic-data, authentication system |
CN101635622A (zh) * | 2008-07-24 | 2010-01-27 | 阿里巴巴集团控股有限公司 | 一种网页加密和解密的方法、系统及设备 |
WO2010011274A1 (en) * | 2008-07-24 | 2010-01-28 | Alibaba Group Holding Limited | System and method for preventing web crawler access |
CN102624931A (zh) * | 2012-04-21 | 2012-08-01 | 华为技术有限公司 | Web客户端与服务器交互的方法、装置及系统 |
CN103780375A (zh) * | 2012-10-19 | 2014-05-07 | 中国电信股份有限公司 | 数据发送方法和装置、数据接收方法和装置 |
US20140282877A1 (en) * | 2013-03-13 | 2014-09-18 | Lookout, Inc. | System and method for changing security behavior of a device based on proximity to another device |
Non-Patent Citations (1)
Title |
---|
于北瑜: "《基于WEB的PGP加密技术在邮件系统中的应用安全研究》", 《网络安全技术与应用》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108429757A (zh) * | 2018-03-26 | 2018-08-21 | 成都睿码科技有限责任公司 | 一种保护网站资源的反爬方法 |
WO2020019477A1 (zh) * | 2018-07-27 | 2020-01-30 | 平安科技(深圳)有限公司 | 通信数据加密方法和装置 |
CN109768973A (zh) * | 2018-12-28 | 2019-05-17 | 易票联支付有限公司 | 一种安全公告的发布监控方法、系统及装置 |
CN111666465A (zh) * | 2019-03-06 | 2020-09-15 | 上海晶赞融宣科技有限公司 | 爬取数据的方法及装置、存储介质、终端 |
CN114338146A (zh) * | 2021-12-27 | 2022-04-12 | 中国民航信息网络股份有限公司 | 一种基于动态码的反爬虫方法、系统、客户端和服务器 |
CN114338146B (zh) * | 2021-12-27 | 2023-08-15 | 中国民航信息网络股份有限公司 | 一种基于动态码的反爬虫方法、系统、客户端和服务器 |
Also Published As
Publication number | Publication date |
---|---|
CN107733633B (zh) | 2020-11-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Hamouda | Comparative study of different cryptographic algorithms | |
CN107733633A (zh) | 一种基于算力的防爬虫方法 | |
US20220141038A1 (en) | Method of rsa signature or decryption protected using a homomorphic encryption | |
US8165286B2 (en) | Combination white box/black box cryptographic processes and apparatus | |
CN110166242A (zh) | 报文传输方法及装置 | |
JP6782864B2 (ja) | ブロック暗号を演算するデバイス及び方法 | |
US20160337324A1 (en) | Web form protection | |
Hayajneh et al. | An enhanced WLAN security system with FPGA implementation for multimedia applications | |
CN112217788A (zh) | 一种Web接口数据的加密方法及系统 | |
CN103414727A (zh) | 针对input密码输入框的加密保护系统及其使用方法 | |
Bali et al. | Lightweight authentication for MQTT to improve the security of IoT communication | |
JP5405658B2 (ja) | リセット可能な耐タンパー性ハードウェアトークンを使用する、効率的な秘匿関数計算の方法 | |
KR20130093557A (ko) | 적어도 하나의 암호화 명령어를 포함하는 소프트웨어 애플리케이션의 협력 실행을 위한 시스템, 장치, 및 방법 | |
Huang et al. | A secure communication over wireless environments by using a data connection core | |
Prajapat et al. | Time variant approach towards symmetric key | |
Klimushin et al. | Potential application of hardware protected symmetric authentication microcircuits to ensure the security of internet of things | |
Kwon et al. | (In-) security of cookies in HTTPS: Cookie theft by removing cookie flags | |
US20130283363A1 (en) | Secure data transfer over an arbitrary public or private transport | |
Suresha et al. | Enhancing data protection in cloud computing using key derivation based on cryptographic technique | |
Arora et al. | Securing web documents by using piggybacked framework based on Newton's forward interpolation method | |
Jain et al. | Honey2fish-a hybrid encryption approach for improved password and message security | |
CN101453335B (zh) | 用户信息安全输入方法、以及客户端 | |
Agrawal et al. | A new and more authentic cryptographic based approach for securing short message | |
CN115118455B (zh) | 面向网页安全的基于属性加密访问控制反爬虫系统及方法 | |
Begum et al. | Protecting Data Privacy in Cloud |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP02 | Change in the address of a patent holder | ||
CP02 | Change in the address of a patent holder |
Address after: 9/F, Block C, No. 28 Tianfu Avenue North Section, Chengdu High tech Zone, China (Sichuan) Pilot Free Trade Zone, Chengdu City, Sichuan Province, 610000 Patentee after: CHENGDU KNOWNSEC INFORMATION TECHNOLOGY Co.,Ltd. Address before: 610000, 11th floor, building 2, No. 219, Tianfu Third Street, hi tech Zone, Chengdu, Sichuan Province Patentee before: CHENGDU KNOWNSEC INFORMATION TECHNOLOGY Co.,Ltd. |