Computers Windows Internet

Like man in the middle. Terms. Injection of malicious code

In this article, we will try to figure out the theory of man-in-the-middle attacks and some practical points that will help prevent these types of attacks. This will help us understand the risk that such intrusions pose to our privacy, as MitM attacks allow us to intrude on communications and listen in on our conversations.

Understanding how the internet works

To understand the man-in-the-middle attack, you must first understand how the Internet itself works. The main points of interaction: clients, routers, servers. The most common communication protocol between a client and a server is the Hypertext Transfer Protocol (HTTP). Web surfing with a browser, e-mail, instant messaging - all done through HTTP.

When you type in your browser's address bar, the client (you) sends a request to display a web page to the server. The packet (HTTP GET request) is sent through multiple routers to the server. The server then responds with a web page that is sent to the client and displayed on its monitor. HTTP messages must be transmitted in secure mode to ensure confidentiality and anonymity.

Figure 1. Client-server interaction

Securing the communication protocol

A secure communication protocol must have each of the following properties:

  1. privacy- Only the intended recipient can read the message.
  2. Authenticity- the identity of the interacting parties is proven.
  3. Integrity- confirmation that the message has not been modified in transit.

If at least one of these rules is not followed, the entire protocol is compromised.

Man-in-the-middle attack over HTTP protocol

An attacker can easily carry out a man-in-the-middle attack using a technique called ARP spoofing. Anyone on your Wi-Fi network can send you a fake ARP packet, causing you to unknowingly send all your traffic through an attacker instead of a router.

After that, the attacker takes full control over the traffic and can monitor requests sent in both directions.

Figure 2. Man-in-the-middle attack scheme


To prevent such attacks, a secure version of the HTTP protocol was created. Transport Layer Security (TLS) and its predecessor, Secure Socket Layer (SSL), are cryptographic protocols that provide secure communication over a network. Hence, the secure protocol will be called HTTPS. You can see how the secure protocol works by typing in the browser's address bar (note the S in https).

Man-in-the-middle attack on poorly implemented SSL

Modern SSL uses a good encryption algorithm, but it doesn't matter if it's not implemented correctly. If a hacker can intercept the request, they can change it by removing the "S" from the requested URL, thereby bypassing SSL.

Such interception and modification of the request can be noticed. For example, if you request https://login.yahoo.com/ and the response is http://login.yahoo.com/ , this should raise suspicion. At the time of writing, such an attack actually works on the Yahoo email service.

Figure 3. Intercepting and modifying a request


To prevent such an attack, servers can implement HTTP Strict Transport Security (HSTS), a mechanism that enforces a forced secure connection over the HTTPS protocol. In this case, if an attacker modifies the request by removing the “S” from the URL, the server will still redirect the user with a 302 redirect to a page with a secure protocol.

Figure 4. Scheme of HSTS operation


This way of implementing SSL is vulnerable to another type of attack - the attacker creates an SSL connection to the server, but tricks the user into using HTTP.

Figure 5. Attack scheme for HSTS


To prevent such attacks, modern browsers like Chrome, Firefox, and Tor monitor sites that use HSTS and enforce a client-side SSL connection with them. In this case, an attacker conducting a man-in-the-middle attack will have to create an SSL connection with the victim.

Figure 6. Scheme of the attack, where the attacker establishes an SSL connection with the victim


In order to secure an SLL connection to a user, an attacker must know how to act as a server. Let's understand the technical aspects of SSL.

Understanding SSL

From a hacker's point of view, compromising any communication protocol comes down to finding a weak link among the components listed above (privacy, authenticity, and integrity).

SSL uses an asymmetric encryption algorithm. In symmetric encryption, the problem is that the same key is used to encrypt and decrypt data, this approach is unacceptable for Internet protocols, since an attacker can trace this key.

Asymmetric encryption, on the other hand, involves 2 keys for each side: the public key used to encrypt and the private key used to decrypt the data.

Figure 7. Work of public and private keys

How does SSL provide the three properties required for secure communications?

  1. Because asymmetric cryptography is used to encrypt data, SSL provides a private connection. This encryption is not so easy to crack and go unnoticed.
  2. The server proves its legitimacy by sending the client an SSL certificate issued by a certificate authority, a trusted third party.

If an attacker somehow manages to get hold of the certificate, they can set the stage for a man-in-the-middle attack. Thus, it will create 2 connections - with the server and with the victim. The server in this case thinks that the attacker is a normal client, and the victim has no way to identify the attacker, since he provided a certificate proving that he is a server.

Your messages reach and arrive in encrypted form, but they pass along the chain through the computer of the cybercriminal, where he has complete control.

Figure 8. Scheme of the attack if the attacker has a certificate


The certificate need not be forged if the attacker has the ability to compromise the victim's browser. In this case, it can insert a self-signed certificate that will be trusted by default. This is how most man-in-the-middle attacks are implemented. In more complex cases, the hacker must go the other way - forge the certificate.

Problems of certificate authorities

The certificate sent by the server is issued and signed by a certificate authority. Each browser has a list of trusted CAs and you can add or remove them. The problem here is that if you decide to remove the large authorities, you will not be able to visit sites that use certificates signed by these authorities.

Certificates and CAs have always been the weakest link in an HTTPS connection. Even if everything was implemented correctly and each certificate authority has a solid authority, it is still difficult to come to terms with the fact that you have to trust many third parties.

Today there are more than 650 organizations capable of issuing certificates. If an attacker hacks any of them, he will get any certificates he wants.

Even when there was only one certificate authority, VeriSign, there was a problem - the people who were supposed to prevent man-in-the-middle attacks were selling interception services.

Also, many certificates were created by hacking certificate authorities. Various techniques and tricks have been used to force the attacked user to trust fraudulent certificates.

Criminalistics

Because the attacker sends fake ARP packets, you can't see his IP address. Instead, you need to pay attention to the MAC address, which is specific to each device on the network. If you know your router's MAC address, you can compare it to the default gateway's MAC address to find out if it's really your router or an intruder.

For example, on Windows, you can use the ipconfig command in the command line (CMD) to see the IP address of your default gateway (last line):

Figure 9 Using the ipconfig command


Then use the arp -a command to find out the MAC address of this gateway:

Figure 10. Using the arp –a command


But there is another way to notice an attack - if you were monitoring the network activity at the time it started and watching the ARP packets. For example, you can use Wireshark for this purpose, this program will notify you if the MAC address of the default gateway has changed.

Note: If an attacker correctly spoofs MAC addresses, it will become a big problem to trace him.

Conclusion

SSL is a protocol that forces an attacker to do a lot of work to carry out an attack. But it won't protect you from government-sponsored attacks or qualified hacker organizations.

The task of the user is to protect their browser and computer in order to prevent the insertion of a fake certificate (a very common technique). You should also pay attention to the list of trusted certificates and remove those you do not trust.

Denoting a situation when an attacker is able to read and modify at will messages exchanged by correspondents, and none of the latter can guess about his presence in the channel.


Wikimedia Foundation. 2010 .

See what "Man in the middle (attack)" is in other dictionaries:

    Man in the middle attack, MITM attack (eng. Man in the middle) is a term in cryptography that refers to a situation where a cryptanalyst (attacker) is able to read and modify messages exchanged at will ... ... Wikipedia

    - ... Wikipedia

    Cryptanalysis (from the Greek κρυπτός hidden and analysis) is the science of methods for obtaining the initial value of encrypted information without having access to the secret information (key) necessary for this. In most cases, this means ... ... Wikipedia

    A hacker attack in the narrow sense of the word is currently understood by the phrase "Assault on a security system", and tends more to the meaning of the following term Cracker attack. This happened due to a distortion of the meaning of the word "hacker" ... Wikipedia

    - (from other Greek κρυπτός hidden and analysis) the science of methods for decrypting encrypted information without a key intended for such decryption. The term was introduced by the American cryptographer William F. Friedman in 1920. Informally ... ... Wikipedia

Attack "man in the middle" (Eng. Man in the middle, MitM-attack) - a term in cryptography, denoting a situation where an attacker is able to read and modify messages exchanged by correspondents at will, and none of the latter can guess about his presence in the channel.

A method of compromising a communication channel, in which an attacker, having connected to a channel between counterparties, actively intervenes in the transmission protocol, deleting, distorting information or imposing false information.

Attack principle:

Let's say object "A" plans to send some information to object "B". Object "C" has knowledge about the structure and properties of the data transmission method used, as well as the fact of the planned transmission of the actual information that "C" plans to intercept.

To perform an attack, "C" is "represented" to object "A" as "B", and to object "B" as "A". Object "A", mistakenly believing that it is sending information to "B", sends it to object "C".

Object "C", having received the information, and having performed some actions with it (for example, copying or modifying it for its own purposes) sends the data to the recipient itself - "B"; object "B", in turn, believes that the information was received by him directly from "A".

An example of a MitM attack:

Suppose Alice is in financial trouble and using an instant messaging program decides to ask John for a sum of money by sending a message:
Alice: John, hi!
Alice: Please send the encryption key, there is a small request!
John: Hey! Wait a second!

But, at this time, Mr. X, who, while analyzing traffic with a sniffer, noticed this message, and the words "encryption key", aroused curiosity. That's why he decided to intercept the following messages and replace them with the data he needs, and when he received the following message:
John: Here is my key: 1111_D

He changed John's key to his own, and sent a message to Alice:
John: Here is my key: 6666_M

Alice, unaware and thinking it is John's key, using the private key 6666_M, sends encrypted messages to John:
Alice: John, I'm in trouble and I need money urgently, please transfer $300 to my account: Z12345. Thank you. p.s. My key: 2222_A

Having received the message, Mister-X decrypts it using his key, reads it, and rejoicing, changes Alice's account number and encryption key to his own, encrypts the message with the key 1111_D, and sends John a message:
Alice: John, I have problems and I urgently need money, please transfer $300 to my account: Z67890. Thank you. p.s. My key: 6666_A

After receiving the message, John decrypts it using the key. 1111_D, and without even a doubt, will transfer money to the account Z67890...

And so Mr. X, using the man-in-the-middle attack, made $300, but Alice now has to explain that she didn't get the money... And John? John has to prove to Alice that he sent them...

Implementation:

A similar type of attack is used in some software products for listening to the network, for example:
NetStumbler- a program with which you can collect a lot of useful data about a wireless network and solve some problems associated with its operation. NetStumbler allows you to determine the range of the network and help you accurately direct the antenna for communication over long distances. For each found access point, you can find out the MAC address, signal-to-noise ratio, the name of the service and the degree of its security. If the traffic is not encrypted, then the ability of the program to detect unauthorized connections will be useful.

dsniff- is a set of programs for network audit and penetration checks, provides passive network monitoring to search for data of interest (passwords, e-mail addresses, files, etc.), interception of network traffic that is normally inaccessible for analysis (for example, on a switched network), as well as the possibility of organizing MITM attacks to intercept SSH and HTTPS sessions by exploiting PKI flaws.

Cain & Abel- a free program that allows you to recover lost passwords for operating systems of the Windows family. Several recovery modes are supported: brute-force brute-force cracking, dictionary selection, viewing passwords hidden by asterisks, etc. There are also options for password detection by intercepting information packets and their subsequent analysis, recording network conversations, cache analysis, and others.

Ettercap- is a sniffer, packet interceptor and registrar for local Ethernet networks, which supports active and passive analysis of many protocols, as well as "tossing" own data into an existing connection and filtering "on the fly" without disrupting the connection synchronization. The program allows you to intercept SSH1, HTTPS and other secure protocols and provides the ability to decrypt passwords for the following protocols: TELNET, ftp, POP, RLOGIN, SSH1, icq, SMB, Mysql, HTTP, NNTP, X11, NAPSTER, IRC, RIP, BGP, SOCKS 5, IMAP 4, VNC, LDAP, NFS, SNMP, HALF LIFE, QUAKE 3, MSN, YMSG.

KARMA- a set of utilities for assessing the security of wireless clients, is a wireless sniffer that, by passively listening to 802.11 Probe Request frames, allows you to discover clients and their preferred / trusted networks. A fake access point can then be created for one of the requested networks, to which it can be automatically connected. High-level fake services can be used to steal personal data or exploit client-side vulnerabilities on the host.

airjack- a set of programs that, according to experts in the field of WiFi hacking, is the best tool for generating various 802.11 frames. AirJack includes a number of utilities designed to detect a hidden ESSID, send session termination frames with a fake MAC, conduct MitM attacks and modify it.

Opposition:

To avoid attacks of this type, it is enough for subscribers "A" and "B" to transfer digital signatures of public encryption keys to each other using a reliable channel. Then, when comparing key signatures in encryption sessions, it will be possible to establish with which key the data was encrypted, and whether the keys have been spoofed.

A man-in-the-middle attack is a generic name for various techniques aimed at gaining access to traffic as an intermediary. Due to the wide variety of these techniques, it is problematic to implement a single tool for detecting these attacks that would work for all possible situations. For example, in a man-in-the-middle attack on a local network, ARP spoofing (poisoning) is commonly used. And many man-in-the-middle attack detection tools watch for Ethernet address pair changes/or report suspicious ARP activity by passive monitoring of ARP requests/responses. But if this attack is used on a maliciously configured proxy server, VPN, or other options when ARP poisoning is not used, then such tools are helpless.

The purpose of this section is to look at some techniques for detecting man-in-the-middle attacks, as well as some tools designed to determine that you are under a MitM attack. Due to the variety of methodologies and implementation scenarios, 100% detection cannot be guaranteed.

1. Traffic modification detection

As already mentioned, ARP spoofing is not always used in man-in-the-middle attacks. Therefore, although ARP level activity detection is the most popular detection method, traffic modification detection is a more universal method. The mitmcanary program can help us with this.

The principle of the program is that it makes "control" requests and saves the received answers. After that, it repeats the same requests at certain intervals and compares the responses received. The program is quite intelligent and, to avoid false positives, it detects dynamic elements in responses and processes them correctly. As soon as the program has recorded traces of the activity of tools for MitM attacks, it reports about it.

Examples of how some tools can "inherit":

  • MITMf , by default changes all HTTPS URLs in HTML code to HTTP. Detected by comparing HTTP content.
  • Zarp + MITMProxy , MITMProxy has a feature that allows you to clear HTTP compression, this is used for the transparency of transmitted traffic, this bundle is detected by the disappearance of previously present compression
  • Responder , detected by sudden changes in mDNS response translation: unexpected response; the response is internal, but external is expected; response is different than expected IP
  • MITMCanary vs MITMF:

  • MITMCanary vs Responder:

  • MITMCanary vs Zarp + MITMProxy:

sudo pip install Cython sudo apt-get install python-kivy python-dbus sudo pip install plyer uuid urlopen analysis request simplejson datetime git clone https://github.com/CylanceSPEAR/mitmcanary.git cd mitmcanary/

As already mentioned, the work of mitmcanary must be started with control requests. To do this, go to the directory

cd service/

And run the file setup_test_persistence.py:

Python2 setup_test_persistence.py

This will take some time - wait until the end. No error messages should be displayed (if so, then you are missing some dependencies).

Something like this will be output:

[email protected]:~/bin/mitmcanary/service$ python2 setup_test_persistence.py Older configuration version detected (0 instead of 14) Upgrading configuration in progress. Purge log fired. Analyzing... Purge finished! Record log in /home/mial/.kivy/logs/kivy_16-11-01_0.txt v1.9.1 v2.7.12+ (default, Sep 1 2016, 20:27:38)

After finishing this process, in the same directory, execute (this will start a background process):

Python2 main.py

After that, open a new terminal window and change to the root directory with mitmcanary. My directory is bin/mitmcanary/, so I enter

cd bin/mitmcanary/

and execute there:

Python2 main.py

The first window will display something like:

[email protected]:~/bin/mitmcanary/service$ python2 main.py Record log in /home/mial/.kivy/logs/kivy_16-11-01_1.txt v1.9.1 v2.7.12+ (default, Sep 1 2016, 20:27 :38) using for socket listening for Tuio on 127.0.0.1:3000 Sleeping for 60 seconds Sleeping for 60 seconds Sleeping for 60 seconds Sleeping for 60 seconds Sleeping for 60 seconds Sleeping for 60 seconds

Those. the program makes control requests once a minute and looks for signs of a man-in-the-middle attack in them.

In the second window there is also an output + a dark window opens, the authors of the program call this window a “graphical interface”:

You can wait a while, surf the Internet to make sure that the program does not make any false alerts.

Let's try the classic Ettercap program.

I'm running a regular MitM attack with ARP spoofing. mitmcanary does not react to etching itself. The mitmcanary tool generates traffic itself, i.e. no user action is required. After some time, a single warning appears, which is not confirmed during subsequent next checks. But the same warning appears after a few minutes. Without additional analysis, I find it difficult to say whether this is an example of a false positive - it is very similar to this. It is possible that this warning is caused by a connection failure due to the need for traffic to go through additional routes, or by the peculiarities of my poor Internet connection.

Since the result is not obvious (rather "no" than "yes"), let's try the Bettercap program, which has a variety of modules. I have no doubt that when using various Ettercap plugins and / or additional programs to extend functionality, we would also “light up” for mitmcanary.

For the purity of the experiment, I restart the equipment, run mitmcanary on the attacked machine and Bettercap on the attacking one. At the same time, it is not necessary to make control requests again on the attacked machine - they are saved in a file inside the directory with the program. Those. it is enough to start the service and the graphical interface.

And in the attacking machine, we will run Bettercap with parsers enabled:

Sudocap -X

Separate warnings appear, which also look more like false positives.

But running this command:

sudo bettercap -X --proxy

On the attacked machine, it causes a large number of warnings about a possible man-in-the-middle attack:

So, the more functional the man-in-the-middle attack tool, the more traces it leaves in traffic. For the practical use of mitmcanary, the following conditions must be met:

  • make initial requests in a trusted network when you are sure that there is no intermediary in the transmission of traffic;
  • edit the resources to which verification requests are made, since a professional attacker can add default resources to exceptions, which will make him invisible to this tool.

2. Detection of ARP spoofing (arp cache poisoning)

Very often, a man-in-the-middle attack on a local network starts with ARP poisoning. That is why many tools designed to detect MitM attacks are based on a mechanism for tracking changes in the ARP cache, in which correspondences between Ethernet (MAC addresses) and IP addresses are assigned.

Examples of such programs include arpwatch , arpalert and a large number of new programs. The ArpON program not only monitors ARP cache changes, but also protects it from them.

As an example, let's run arpwatch in debug mode, without creating forks in the background and sending messages by mail. Instead, messages are sent to stderr (standard error output).

sudo /usr/sbin/arpwatch -d

On the attacking machine, run Ettercap and start ARP spoofing. On the attacked machine we observe:

The arpwatch program will help you quickly learn about new devices connected to your local network, as well as changes to the ARP cache.

Another tool for detecting real-time ARP spoofing is a plugin by Ettercap itself called arp_cop. On the attacked machine, run Ettercap as follows:

sudo ettercap -TQP arp_cop ///

And on the attacker, let's start ARP-etching. Warnings immediately begin to appear on the attacked machine:

3. DNS Spoofing Detection

DNS spoofing indicates that there is an intermediary between you and the destination that can modify your traffic. How can you detect that DNS records have been spoofed? The easiest way to do this is to compare against the responses of a nameserver you trust. But after all, the entries in the response sent to your request can also be substituted ...

Those. you need to check either through an encrypted channel (for example, via Tor), or use non-standard settings (another port, TCP instead of UDP). The sans program from XiaoxiaoPu is intended for this approximately (at least, as I understand it). I managed to use this program to redirect DNS queries through Tor and through non-standard settings to my DNS server. But I was never able to get her to show me messages about DNS response spoofing. And without this, the meaning of the program is lost.

I couldn't find better alternatives.

In principle, given that DNS spoofers usually monitor only port 53, and only UDP protocol, even manually it is enough to simply check the fact of DNS spoofing, although this requires your own DNS server with a non-standard configuration. For example, on the attacking machine, I created the file dns.conf with the following content:

Local mi-al.ru

Those. when requesting a DNS record for the site mi-al.ru, instead of the real IP, the IP of the attacker's machine will be sent.

I run on the attacking machine:

sudo bettercap --dns dns.conf

And on the attacked I do two checks:

Dig mi-al.ru # and dig mi-al.ru -p 4560 @185.117.153.79

Results:

[email protected]:~$ dig mi-al.ru ;<<>> DiG 9.10.3-P4-Debian<<>> mi-al.ru ;; global options: +cmd ;; got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51993 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; QUESTION SECTION: ;mi-al.ru. IN A ;; ANSWER SECTION: mi-al.ru. 86400 IN A 192.168.1.48 ;; Query time: 2 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Wed Nov 02 09:25:20 MSK 2016 ;; MSG SIZE rcvd: 42 [email protected]:~$ dig mi-al.ru -p 4560 @185.117.153.79 ;<<>> DiG 9.10.3-P4-Debian<<>> mi-al.ru -p 4560 @185.117.153.79 ;; global options: +cmd ;; got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 401 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;mi-al.ru. IN A ;; ANSWER SECTION: mi-al.ru. 3799 IN A 185.26.122.50 ;; Query time: 304 msec ;; SERVER: 185.117.153.79#4560(185.117.153.79) ;; WHEN: Wed Nov 02 09:25:27 MSK 2016 ;; MSG SIZE rcvd: 53

It can be seen that for a “normal” DNS query, the local IP 192.168.1.48 was sent, and when querying DNS on an atypical port, the correct server IP is sent.

If the server were configured to work with TCP (rather than UDP), then the command would look like this:

Dig mi-al.ru -p 4560 +tcp @185.117.153.79

Obviously, there is a lack of a tool that would track DNS responses in traffic itself, double-check them against an alternative source, and raise an alarm in case of spoofing.

To avoid setting up your own remote DNS, you can query the nameserver via Tor. Since all Tor traffic is encrypted, the DNS responses received in this way are too tough for an intermediary. If Tor is not already installed, then install it.

sudo apt-get install tor

Sudo pacman -S tor

Start the service:

sudo systemctl start tor

If you need it, add this service to startup:

sudo systemctl enable tor

Open file /etc/tor/torrc and add the following lines there:

DNSPort 530 AutomapHostsOnResolve 1 AutomapHostsSuffixes .exit, .onion

Pay attention to the number 530. This is the port number, instead of 530, you can specify any other (unoccupied) port. Most importantly, remember it.

Again we check:

Dig mi-al.ru # and dig mi-al.ru -p 530 @localhost

Now we specify as the server localhost, and write the port number as specified in the /etc/tor/torrc.

As you can see from the following screenshot, a DNS spoofing attack is being carried out against the machine on which the check was made:

4. Search for network interfaces in promiscuous mode

If your local network has (and especially if it suddenly appeared) equipment in promiscuous mode, this is very suspicious, although it does not clearly indicate a man-in-the-middle attack.

In this mode, the network card allows you to receive all packets, regardless of who they are addressed to.

In the normal state, link layer packet filtering is used on the Ethernet interface, and if the MAC address in the destination header of the received packet does not match the MAC address of the current network interface and is not broadcast, then the packet is discarded. In promiscuous mode, filtering on the network interface is disabled and all packets, including those not destined for the current host, are allowed into the system.

Most operating systems require administrator rights to enable promiscuous mode. Those. putting a network card into promiscuous mode is a conscious act that may serve the purpose of sniffing.

To search for network interfaces in promiscuous mode, there is an Ettercap plugin called search_promisc.

Plugin launch example:

sudo ettercap -TQP search_promisc ///

Plugin operation is not completely reliable, there may be errors in determining the network interface mode.

Conclusion

Some man-in-the-middle attack methods leave a lot of traces, and some (for example, passively looking for credentials on a proxy) are impossible or almost impossible to detect.

In which an attacker, having connected to a channel between counterparties, intervenes in the transmission protocol, deleting or distorting information.

Principle of attack

The attack usually begins with listening to the communication channel and ends with the cryptanalyst trying to replace the intercepted message, extract useful information from it, and redirect it to some external resource.

Suppose object A plans to send some information to object B. Object C has knowledge about the structure and properties of the data transfer method used, as well as the fact that the planned transfer of the actual information that C plans to intercept. To carry out an attack, C “appears” to object A as B, and to object B as A. Object A, mistakenly believing that it is sending information to B, sends it to object C. Object C, having received the information and performing some actions with it (for example, , copying or modifying for their own purposes) sends the data to the recipient itself - B; object B, in turn, believes that the information was received by him directly from A.

Attack Example

Injection of malicious code

A man-in-the-middle attack allows a cryptanalyst to inject his code into emails, SQL statements, and web pages (i.e., allows SQL injection, HTML/script injection, or XSS attacks), and even modify user-uploaded binaries in order to to access a user account or change the behavior of a program downloaded by the user from the Internet.

Downgrade attack

The term "Downgrade Attack" refers to such an attack in which the cryptanalyst forces the user to use less secure functions, protocols that are still supported for compatibility reasons. This type of attack can be carried out on the SSH , IPsec and PPTP protocols.

To protect against a Downgrade Attack, insecure protocols must be disabled on at least one side; just supporting and using secure protocols by default is not enough!

SSH V1 instead of SSH V2

An attacker may try to change the connection parameters between the server and the client when a connection is established between them. According to a talk at the Blackhat Conference Europe 2003, a cryptanalyst can "force" a client to start an SSH1 session instead of an SSH2 session by changing the version number "1.99" of the SSH session to "1.51", which means using SSH V1. The SSH-1 protocol has vulnerabilities that a cryptanalyst can exploit.

IPsec

In this attack scenario, the cryptanalyst misleads his victim into thinking that an IPsec session cannot start at the other end (server). This causes messages to be forwarded explicitly if the host machine is in rollback mode.

PPTP

At the stage of negotiating PPTP session parameters, the attacker can force the victim to use a less secure PAP authentication, MSCHAP V1 (that is, "roll back" from MSCHAP V2 to version 1), or not use encryption at all.

An attacker can force his victim to repeat the stage of negotiating the PPTP session parameters (send a Terminate-Ack packet), steal the password from the existing tunnel and repeat the attack.

Public means of communication without protection of the authenticity, confidentiality, availability and integrity of information

The most common means of communication for this group is a social network, a public e-mail service, and an instant messaging system. The owner of the resource that provides the communication service has full control over the information exchanged by the correspondents and, at his own discretion, can easily carry out an attack at any time.

Unlike previous scenarios based on the technical and technological aspects of communications, in this case the attack is based on mental aspects, namely, on the rooting in the minds of users of the concept of ignoring information security requirements.

Will encryption save?

Consider the case of a standard HTTP transaction. In this case, the attacker can quite easily break the original TCP connection into two new ones: one between himself and the client, the other between himself and the server. This is fairly easy to do, since very rarely the connection between the client and the server is direct, and in most cases they are connected through a number of intermediate servers. A MITM attack can be carried out on any of these servers.

However, if the client and server communicate over HTTPS - a protocol that supports encryption - a man-in-the-middle attack can also be carried out. With this type of connection, TLS or SSL is used to encrypt requests, which, it would seem, makes the channel secure from sniffing and MITM attacks. An attacker can create two independent SSL sessions for each TCP connection. The client establishes an SSL connection with the attacker, who in turn creates a connection with the server. The browser in such cases usually warns that the certificate is not signed by a trusted certificate authority, but ordinary users of older browsers can easily bypass this warning. In addition, an attacker may have a certificate signed by a root CA (for example, such certificates are sometimes used for DLP) and not generate warnings. In addition, there are a number of attacks on HTTPS. Thus, the HTTPS protocol cannot be considered secure from MITM attacks by ordinary users. [ ] There are a number of measures that prevent some of the MITM attacks on https sites, in particular, HSTS , which prohibits the use of http connections from sites, Certificate pinning and HTTP Public Key Pinning , which prohibit certificate substitution.

MITM attack detection

To detect a man-in-the-middle attack, network traffic must be analyzed. For example, to detect an SSL attack, you should pay attention to the following parameters:

  • Server IP
  • DNS server
  • X.509 server certificate
    • Is the certificate self-signed?
    • Is the certificate signed by a certificate authority?
    • Has the certificate been revoked?
    • Has the certificate changed recently?
    • Have other clients on the Internet received the same certificate?

MITM attack implementations

The listed programs can be used to carry out man-in-the-middle attacks, as well as to detect them and test the system for vulnerabilities.

see also

  • Aspidistra (English) - British radio transmitter used during World War II "invasions", a variant of the MITM attack.
  • The Babington Plot (English) - a conspiracy against Elizabeth I, during which Walsingham intercepted correspondence.

Other attacks

  • Man in the Browser is a type of attack in which an attacker is able to instantly change transaction parameters, change pages completely transparently to the victim.
  • "Meet-in-the-middle attack" - a cryptographic attack that, like the birthday attack, uses a trade-off between time and memory.
  • "Loss in the middle" (Miss in the middle attack) is an effective method of the so-called impossible differential cryptanalysis.
  • Relay attack - A variant of a MITM attack based on forwarding an intercepted message to a valid recipient, but not to the intended recipient.
  • A rootkit is a program designed to hide traces of the presence of an intruder.

Write a review on the article "Attack of the intermediary"

Literature

Links

  • www.all.net/CID/Attack/Attack74.html
  • www.nag.ru/2003/0405/0405.shtml
  • www.schneier.com/blog/archives/2006/04/rfid_cards_and.html

An excerpt characterizing the attack of the middleman

“Quartire, quartire, logement,” said the officer, looking down at the little man with a condescending and good-natured smile. – Les Francais sont de bons enfants. Que diable! Voyons! Ne nous fachons pas, mon vieux, [Apartments, apartments… The French are good guys. Damn it, let's not quarrel, grandfather.] - he added, patting the frightened and silent Gerasim on the shoulder.
– A ca! Dites donc, on ne parle donc pas francais dans cette boutique? [Well, doesn't anyone speak French here, too?] he added, looking around and meeting Pierre's eyes. Pierre moved away from the door.
The officer again turned to Gerasim. He demanded that Gerasim show him the rooms in the house.
"No master - don't understand... my yours..." said Gerasim, trying to make his words clearer by speaking them backwards.
The French officer, smiling, spread his hands in front of Gerasim's nose, making it feel that he did not understand him either, and, limping, went to the door where Pierre was standing. Pierre wanted to move away in order to hide from him, but at that very moment he saw Makar Alekseich leaning out of the kitchen door opening with a pistol in his hands. With the cunning of a madman, Makar Alekseevich looked at the Frenchman and, raising his pistol, took aim.
- Aboard!!! - the drunk shouted, pressing the trigger of the pistol. The French officer turned around at the cry, and at the same moment Pierre rushed at the drunk. While Pierre grabbed and raised the pistol, Makar Alekseich finally hit the trigger with his finger, and a shot rang out that deafened and doused everyone with powder smoke. The Frenchman turned pale and rushed back to the door.
Having forgotten his intention not to reveal his knowledge of the French language, Pierre, snatching the pistol and throwing it away, ran up to the officer and spoke to him in French.
- Vous n "etes pas blesse? [Are you injured?] - he said.
“Je crois que non,” the officer answered, feeling himself, “mais je l "ai manque belle cette fois ci,” he added, pointing to the chipped plaster in the wall. “Quel est cet homme? [It seems not ... but this once it was close. Who is this man?] - looking sternly at Pierre, the officer said.
- Ah, je suis vraiment au desespoir de ce qui vient d "arriver, [Ah, I really am in despair over what happened,] - Pierre said quickly, completely forgetting his role. - C" est un fou, un malheureux qui ne savait pas ce qu "il faisait. [This is an unfortunate madman who did not know what he was doing.]
The officer went up to Makar Alekseevich and seized him by the collar.
Makar Alekseich, with parted lips, as if falling asleep, swayed, leaning against the wall.
“Brigand, tu me la payeras,” said the Frenchman, withdrawing his hand.
– Nous autres nous sommes clements apres la victoire: mais nous ne pardonnons pas aux traitres, [Robber, you will pay me for this. Our brother is merciful after the victory, but we do not forgive the traitors,] he added with gloomy solemnity in his face and with a beautiful energetic gesture.
Pierre continued to persuade the officer in French not to exact from this drunken, insane man. The Frenchman listened in silence, without changing his gloomy look, and suddenly turned to Pierre with a smile. He looked at him silently for a few seconds. His handsome face took on a tragically tender expression, and he held out his hand.
- Vous m "avez sauve la vie! Vous etes Francais, [You saved my life. You are a Frenchman,]" he said. For a Frenchman, this conclusion was undeniable. Only a Frenchman could do a great thing, and saving his life, m r Ramball capitaine du 13 me leger [Monsieur Rambal, captain of the 13th light regiment] was, without a doubt, the greatest deed.
But no matter how undoubted this conclusion and the officer’s conviction based on it, Pierre considered it necessary to disappoint him.
“Je suis Russe, [I am Russian],” Pierre said quickly.
- Ti ti ti, a d "autres, [tell this to others] - said the Frenchman, waving his finger in front of his nose and smiling. - Tout a l "heure vous allez me conter tout ca," he said. – Charme de rencontrer un compatriote. Eh bien! qu "allons nous faire de cet homme? [Now you will tell me all this. It is very nice to meet a compatriot. Well! what should we do with this man?] - he added, addressing Pierre, already as his brother. If only Pierre was not a Frenchman, having once received this highest title in the world, he could not renounce it, said the expression on the face and tone of the French officer. To the last question, Pierre once again explained who Makar Alekseich was, explained that just before their arrival this a drunken, insane man dragged off a loaded pistol, which they did not have time to take away from him, and asked that his act be left without punishment.
The Frenchman stuck out his chest and made a royal gesture with his hand.
- Vous m "avez sauve la vie. Vous etes Francais. Vous me demandez sa grace? Je vous l" accorde. Qu "on emmene cet homme, [You saved my life. You are a Frenchman. Do you want me to forgive him? I forgive him. Take this man away,] the French officer said quickly and energetically, taking by the arm what he had produced for saving his life into Pierre's French, and went with him to the house.
The soldiers who were in the yard, hearing the shot, went into the passage, asking what had happened, and expressing their readiness to punish the guilty; but the officer severely stopped them.
“On vous demandera quand on aura besoin de vous, [When needed, you will be called,” he said. The soldiers left. The batman, who had meanwhile been in the kitchen, approached the officer.
“Capitaine, ils ont de la soupe et du gigot de mouton dans la cuisine,” he said. - Faut il vous l "apporter? [The captain has soup and roast lamb in the kitchen. Would you like to bring it?]
- Oui, et le vin, [Yes, and wine,] - said the captain.

The French officer, together with Pierre, entered the house. Pierre considered it his duty to assure the captain again that he was not a Frenchman, and wanted to leave, but the French officer did not want to hear about it. He was so courteous, amiable, good-natured and truly grateful for saving his life that Pierre did not have the courage to refuse him and sat down with him in the hall, in the first room into which they entered. To Pierre's assertion that he was not a Frenchman, the captain, obviously not understanding how it was possible to refuse such a flattering title, shrugged his shoulders and said that if he certainly wants to be known as a Russian, then so be it, but that he, despite then, all the same forever connected with him by a feeling of gratitude for saving a life.
If this person had been gifted with at least some ability to understand the feelings of others and had guessed about Pierre's feelings, Pierre would probably have left him; but the lively impenetrability of this man to everything that was not himself defeated Pierre.
- Francais ou prince russe incognito, [Frenchman or Russian prince incognito,] - said the Frenchman, looking at Pierre's dirty, but thin underwear and the ring on his hand. - Je vous dois la vie je vous offre mon amitie. Un Francais n "oublie jamais ni une insulte ni un service. Je vous offre mon amitie. Je ne vous dis que ca. [I owe you my life, and I offer you friendship. A Frenchman never forgets insults or services. I offer my friendship to you, I say no more.]
In the sounds of his voice, in the expression of his face, in the gestures of this officer, there was so much good nature and nobility (in the French sense) that Pierre, responding with an unconscious smile to the smile of the Frenchman, shook the outstretched hand.
- Capitaine Ramball du treizieme leger, decore pour l "affaire du Sept, [Captain Ramball, thirteenth light regiment, cavalier of the Legion of Honor for the cause of the seventh of September,] - he introduced himself with a smug, uncontrollable smile that wrinkled his lips under his mustache. - Voudrez vous bien me dire a present, a qui "j" ai l "honneur de parler aussi agreablement au lieu de rester a l" ambulance avec la balle de ce fou dans le corps. [Will you be so kind as to tell me now who I am with I have the honor of talking so pleasantly, instead of being at the dressing station with this madman's bullet in his body?]
Pierre answered that he could not say his name, and, blushing, began, trying to invent a name, to talk about the reasons why he could not say this, but the Frenchman hastily interrupted him.
“De grace,” he said. - Je comprends vos raisons, vous etes officier ... officier superieur, peut etre. Vous avez porte les armes contre nous. Ce n "est pas mon affaire. Je vous dois la vie. Cela me suffit. Je suis tout a vous. Vous etes gentilhomme? [Complete, please. I understand you, you are an officer ... a staff officer, maybe. You served against us It's none of my business. I owe you my life. That's enough for me, and I'm all yours. Are you a nobleman?] - he added with a hint of a question. Pierre tilted his head. - Votre nom de bapteme, s "il vous plait? Je ne demande pas davantage. Monsieur Pierre, dites vous… Parfait. C "est tout ce que je desire savoir. [Your name? I don't ask anything else. Mr. Pierre, did you say? Fine. That's all I need.]
When roast lamb, scrambled eggs, a samovar, vodka and wine from a Russian cellar, which the French had brought with them, were brought, Ramball asked Pierre to take part in this dinner and immediately, eagerly and quickly, like a healthy and hungry man, began to eat, chewing quickly with his strong teeth, constantly smacking his lips and saying excellent, exquis! [wonderful, excellent!] His face was flushed and covered with sweat. Pierre was hungry and gladly took part in the dinner. Morel, the orderly, brought a pot of warm water and put a bottle of red wine in it. In addition, he brought a bottle of kvass, which he took from the kitchen for testing. This drink was already known to the French and got the name. They called the kvass limonade de cochon (pork lemonade), and Morel praised this limonade de cochon he found in the kitchen. But since the captain had wine obtained during the passage through Moscow, he provided kvass to Morel and took up a bottle of Bordeaux. He wrapped the bottle up to the neck in a napkin and poured himself and Pierre wine. The satisfaction of hunger and wine enlivened the captain still more, and he did not stop talking during dinner.
- Oui, mon cher monsieur Pierre, je vous dois une fiere chandelle de m "avoir sauve ... de cet enrage ... J" en ai assez, voyez vous, de balles dans le corps. En voila une (on pointed to his side) a Wagram et de deux a Smolensk, - he showed the scar that was on his cheek. - Et cette jambe, comme vous voyez, qui ne veut pas marcher. C "est a la grande bataille du 7 a la Moskowa que j" ai recu ca. Sacre dieu, c "etait beau. Il fallait voir ca, c" etait un deluge de feu. Vous nous avez taille une rude besogne; vous pouvez vous en vanter, nom d "un petit bonhomme. Et, ma parole, malgre l" atoux que j "y ai gagne, je serais pret a recommencer. Je plains ceux qui n" ont pas vu ca. [Yes, my dear Mr. Pierre, I am obliged to light a good candle for you for saving me from this madman. You see, I've had enough of the bullets that I have in my body. Here is one near Wagram, the other near Smolensk. And this leg, you see, that doesn't want to move. This is during the big battle of the 7th near Moscow. O! it was wonderful! You should have seen it, it was a deluge of fire. You have given us a hard job, you can boast. And by God, despite this trump card (he pointed to the cross), I would be ready to start all over again. I pity those who did not see it.]
- J "y ai ete, [I was there] - said Pierre.
- Bah, vraiment! Eh bien, tant mieux, said the Frenchman. - Vous etes de fiers ennemis, tout de meme. La grande redoute a ete tenace, nom d "une pipe. Et vous nous l" avez fait cranement payer. J "y suis alle trois fois, tel que vous me voyez. Trois fois nous etions sur les canons et trois fois on nous a culbute et comme des capucins de cartes. Oh!! c" etait beau, monsieur Pierre. Vos grenadiers ont ete superbes, tonnerre de Dieu. Je les ai vu six fois de suite serrer les rangs, et marcher comme a une revue. Les beaux hommes! Notre roi de Naples, qui s "y connait a crie: bravo! Ah, ah! soldat comme nous autres! - he said, smiling, ate a moment of silence. - Tant mieux, tant mieux, monsieur Pierre. Terribles en bataille ... galants ... - he winked with a smile, - avec les belles, voila les Francais, monsieur Pierre, n "est ce pas? [Ba, really? All the better. You are dashing enemies, I must admit. The big redoubt held up well, dammit. And you made us pay dearly. I've been there three times, as you can see. Three times we were on the cannons, three times we were knocked over like card soldiers. Your grenadiers were great, by God. I saw how their ranks closed six times and how they marched exactly to the parade. Wonderful people! Our Neapolitan king, who ate the dog in these cases, shouted to them: bravo! - Ha, ha, so you are our brother soldier! “So much the better, so much the better, Monsieur Pierre. Terrible in battle, kind to beauties, here are the French, Monsieur Pierre. Is not it?]
To such an extent, the captain was naively and good-naturedly cheerful, and wholehearted, and pleased with himself, that Pierre almost winked himself, looking at him cheerfully. Probably, the word "galant" made the captain think about the position of Moscow.