Skip to content

Commit 8a10d29

Browse files
added some chapters
1 parent f9225b2 commit 8a10d29

File tree

8 files changed

+225
-16
lines changed

8 files changed

+225
-16
lines changed

doc/_static/assets/css/toctree-icons.css

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,37 @@
1919
content: "\f502";
2020
}
2121

22-
/* Advanced usage */
22+
/* SSH Agent */
2323
#docs-nav .toctree-l1:nth-child(4):before,
2424
#docs-cards .toctree-l1:nth-child(4) i:before {
2525
font-family: FontAwesome;
26-
content: "\f0e8";
26+
content: "\f084";
2727
}
2828

29-
/* Port Forwarding */
29+
/* File transfer */
3030
#docs-nav .toctree-l1:nth-child(5):before,
3131
#docs-cards .toctree-l1:nth-child(5) i:before {
3232
font-family: FontAwesome;
33-
content: "\f542";
33+
content: "\f56f";
3434
}
3535

36-
/* SSH Vurnabilities */
36+
/* Port Forwarding */
3737
#docs-nav .toctree-l1:nth-child(6):before,
3838
#docs-cards .toctree-l1:nth-child(6) i:before {
39+
font-family: FontAwesome;
40+
content: "\f542";
41+
}
42+
43+
/* Advanced usage */
44+
#docs-nav .toctree-l1:nth-child(7):before,
45+
#docs-cards .toctree-l1:nth-child(7) i:before {
46+
font-family: FontAwesome;
47+
content: "\f0e8";
48+
}
49+
50+
/* SSH Vurnabilities */
51+
#docs-nav .toctree-l1:nth-child(8):before,
52+
#docs-cards .toctree-l1:nth-child(8) i:before {
3953
font-family: FontAwesome;
4054
content: "\f714";
4155
}

doc/advanced-usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Advanced usage
2-
==============
1+
Advanced usage cases
2+
====================
33

44
SSH-MITM is capable of advanced man-in-the-middle attacks. It
55
can be used in scenarios where the remote host is not known or a single

doc/authentication.rst

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
11
Authentication
22
==============
3+
4+
5+
none Authentication
6+
-------------------
7+
8+
The none authentication takes a special position among the authentication methods.
9+
The reason is that this authentication method is used to tell the client which methods are accepted by the server. For this reason, none-Authentication is executed before all other authentication methods.
10+
11+
However, it can also be used to give a user access to a system without requiring an explicit login.
12+
13+
password authentication
14+
-----------------------
15+
16+
Password authentication is one of the most common login methods. Almost all current operating systems support this method both for local logins and over the network. By default, OpenSSH and many other SSH servers have this type of authentication active.
17+
18+
With SSH, within the encrypted channel, the password is transmitted in clear text. If a client connects to a Man in the Middle server, the server is able to read the username and password in clear text. This information can then be used to log in to other servers if the user exists and uses the same password.
19+
20+
Another problem is that accounts with weak passwords can be compromised relatively easily through a brute force attack. This happens very often with IoT devices because they often have the same username on many devices and they are protected by a default password or only a weak password is set.
21+
22+
.. warning::
23+
24+
Password authentication should not be used for these reasons!
25+
26+
27+
Example SSH-MITM session intercepting password authentication:
28+
29+
.. code-block:: none
30+
31+
$ ssh-mitm
32+
2021-09-02 09:51:35,354 [INFO] starting SSH-MITM 0.5.13
33+
2021-09-02 09:51:38,590 [INFO] connected client version: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
34+
2021-09-02 09:51:48,629 [INFO] Client connection established with parameters:
35+
Remote Address: 127.0.0.1
36+
Port: 22
37+
Username: testuser
38+
Password: secret
39+
Key: None
40+
Agent: no agent
41+
42+
43+
keyboard-interactive authentication
44+
-----------------------------------
45+
46+
keyboard-interactive is similar to password authentication. The main difference is that the server can send any number of requests to the client, which are necessary for the login process. The server defines both the prompt text and whether the value is visible or not when entered.
47+
48+
In many cases keyboard-interactive is used for 2 factor authentication. In the first step a password is requested and then e.g. the input of a time-based token is necessary (TOTP).
49+
50+
Unless special tools are used to create cryptographically secured input, all input via keyboard-interactive can be reused during a man in the middle attack to login to another server.
51+
52+
53+
54+
publickey authentication
55+
------------------------
56+
57+
In contrast to password authentication, where the password is transmitted in plain text, publickey authentication is based on asymmetric encryption. In asymmetric encryption, a key pair consisting of a private part and a public part is created.
58+
59+
With SSH, the public key is stored on the server while the private key remains in the possession of the user.
60+
61+
With OpenSSH, the private key can be additionally protected by a password in case it is stolen. Starting with OpenSSH 8.2, FIDO2 tokens are supported and can be used for a 2 factor confirmation when using the key.
62+
63+
As an alternative to a FIDO2 token, SSH-Askpass can also be used to confirm cryptographic operations. If there is an increased need for security, SSH-Askpass should only be used if the use of a FIDO2 token is not possible.
64+
65+
Publickey authentication is only partially suitable for a man-in-the-middle attack. Unlike password authentication, no data is exchanged that can be used for a complete login.
66+
67+
Another problem is that the key that should be used for the login is not known. This can lead to FIDO2 and SSH-Askpass protected keys displaying a prompt for an incorrect key to the user.
68+
69+
An attacker should use PublicKey authentication only if the client does not accept other authentication methods.

doc/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@
7777
}
7878

7979
page_descriptions = {
80-
'install.html': 'SSH-MITM is easy to install with Python and PIP',
8180
'quickstart.html': 'Short guide to setup an intercepting SSH-MITM server with a single command',
81+
'fingerprint.html': 'Description of host fingerprints and how to detect if a client already knows a host fingerprint',
82+
'authentication.html': 'SSH authentication methods explained and how to use them during audits',
83+
'sshagent.html': 'SSH agent and agent forwarding explained and security considerations discussed',
84+
'filetransfer.html': 'Description of the SCP/SFTP protocols and how to manipulate files during audits',
85+
'portforwarding.html': 'Introduction to port forwarding features of SSH-MITM',
8286
'advanced-usage.html': 'Guide on how to setup a SSH-MITM server for advanced security audits in large networks and special use cases',
8387
'ssh_vulnerabilities.html': 'Explanation of vulnerabilities related to the ssh protocol',
84-
'jumphosts.html': 'SSH-MITM should not be used as jump host. This page describes alternatives and security considerations when operating a jump host',
85-
'portforwarding.html': 'Introduction to port forwarding features of SSH-MITM'
8688
}
8789

8890
html_context = {

doc/filetransfer.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SCP/SFTP iletransfers
2+
=====================

doc/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ SSH-MITM Docs - Main Page
88
quickstart
99
fingerprint
1010
authentication
11-
advanced-usage
11+
sshagent
12+
filetransfer
1213
portforwarding
14+
advanced-usage
1315
ssh_vulnerabilities

doc/quickstart.rst

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,69 @@ In cases, when no agent was forwarded, SSH-MITM can rediredt the session to a ho
2727

2828
</p>
2929
</p>
30-
31-
Installation
32-
------------
30+
<section class="how-section py-5">
31+
<div class="container">
32+
<div class="row">
33+
<div class="item col-12 col-md-4">
34+
<div class="icon-holder">
35+
<img src="https://www.ssh-mitm.at/assets/images/streamline-free/monitor-loading-progress.svg" alt="">
36+
<div class="arrow-holder d-none d-lg-inline-block"></div>
37+
</div><!--//icon-holder-->
38+
<div class="desc p-3">
39+
<h5><span class="step-count mr-2">1</span>Install SSH-MITM</h5>
40+
<p>
41+
To install SSH-MITM, simply run this command in your terminal of choice:<br/>
42+
<code>
43+
$ sudo snap install ssh-mitm
44+
</code>
45+
</p>
46+
<p><a href="https://snapcraft.io/ssh-mitm">
47+
<img alt="Get it from the Snap Store" src="https://snapcraft.io/static/images/badges/en/snap-store-black.svg" />
48+
</a></p>
49+
</div><!--//desc-->
50+
</div><!--//item-->
51+
<div class="item col-12 col-md-4">
52+
<div class="icon-holder">
53+
<img src="https://www.ssh-mitm.at/assets/images/streamline-free/programmer-male.svg" alt="">
54+
<div class="arrow-holder d-none d-lg-inline-block"></div>
55+
</div><!--//icon-holder-->
56+
<div class="desc p-3">
57+
<h5><span class="step-count mr-2">2</span>Connect to the network</h5>
58+
<p>
59+
To start an intercepting mitm-ssh server on Port 10022,
60+
all you have to do is run a single command.<br/>
61+
<code>$ ssh-mitm --remote-host 192.168.0.x</code>
62+
</p>
63+
<p>
64+
Now let's try to connect to the ssh-mitm server.<br/>
65+
<code>$ ssh -p 10022 user@proxyserver</code>
66+
</p>
67+
</div><!--//desc-->
68+
</div><!--//item-->
69+
<div class="item col-12 col-md-4">
70+
<div class="icon-holder">
71+
<img src="https://www.ssh-mitm.at/assets/images/streamline-free/customer-service-woman.svg" alt="">
72+
</div><!--//icon-holder-->
73+
<div class="desc p-3">
74+
<h5><span class="step-count mr-2">3</span>Hijack SSH sessions</h5>
75+
<p>
76+
When a client connects, the ssh-mitm starts a new server, which is used for session hijacking.<br/>
77+
<code>[INFO] created injector shell on port 34463</code>
78+
</p><p>
79+
To hijack this session, you can use your favorite ssh client.
80+
All you have to do is to connect to the hijacked session.<br/>
81+
<code>$ ssh -p 34463 127.0.0.1</code>
82+
</p>
83+
</div><!--//desc-->
84+
</div><!--//item-->
85+
</div><!--//row-->
86+
</div><!--//container-->
87+
</section><!--//how-section-->
88+
89+
90+
91+
Alternative installation methods
92+
--------------------------------
3393

3494
This part of the documentation covers the installation of SSH-MITM.
3595
The first step to using any software package is getting it properly installed.
@@ -51,8 +111,17 @@ Install with pip
51111
52112
$ python -m pip install ssh-mitm
53113
54-
Start ssh-mitm proxy server
55-
---------------------------
114+
Install as AppImage
115+
"""""""""""""""""""
116+
117+
.. code-block:: bash
118+
119+
$ wget https://github.com/ssh-mitm/ssh-mitm/releases/latest/download/ssh-mitm-x86_64.AppImage
120+
$ chmod +x ssh-mitm*.AppImage
121+
122+
123+
Start SSH-MITM
124+
--------------
56125

57126
Let’s get started with some simple examples.
58127

doc/sshagent.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
SSH Agent
2+
=========
3+
4+
There are several ways in which SSH keys can be managed locally. One of the most common use cases is to store a key in the file system. SSH clients are able to read them from specific directories. For example, an RSA key may be stored as .ssh/id_rsa in the user's home directory.
5+
6+
To protect these keys from unauthorized access after theft or loss, it is recommended to store them encrypted. For this purpose it is necessary to enter a password.
7+
8+
The SSH Agent can be used to manage these keys. The password input, for decrypting is only necessary once during loading into the SSH Agent. All further cryptographic operations are then performed without the need to enter a password.
9+
10+
For the communication between SSH Agent and SSH Client a Unix socket is created and stored in a new subdirectory in /tmp. Because of this design, any user with appropriate privileges, such as the root user, is able to access and use this Unix socket.
11+
12+
For this reason, it is important that privileged users are trusted or that their accounts are not compromised.
13+
14+
To protect against misuse, a key can be secured with SSH-Askpass or a FIDO2 key. In both cases, user confirmation is required.
15+
16+
The big advantage of a FIDO2 key is that the confirmation is done via a separate hardware and cannot be compromised by a malware infected machine. SSH-Askpass is a software solution that can be bypassed by malware or an attacker who controls the victim's desktop.
17+
18+
For this reason, the use of a FIDO2 key is recommended over the use of SSH-Askpass.
19+
20+
21+
SSH Agent Forwarding
22+
--------------------
23+
24+
Many SSH clients offer the possibility to pass a local agent to a remote server. The corresponding protocol was defined in draft-ietf-secsh-agent-00. The corresponding draft was already defined in 2001 and almost all SSH clients support it.
25+
26+
A passed SSH agent can then be used to login to another server.
27+
28+
The advantage is that no sensitive data, such as private SSH keys, need to be stored permanently on the remote servers, but a secure login using Publickey authentication is still possible.
29+
30+
In most cases, agent forwarding is only supported for a shell connection. Agent forwarding is theoretically also possible for file transfers using SCP and SFTP, but most programs do not support this feature.
31+
32+
OpenSSH has implemented agent forwarding with version 8.4 for the client programs scp and sftp as well, in order to not have to copy these files via the local host for remote to remote file operations.
33+
34+
However, SSH Agent Forwarding is associated with a security risk. This is because privileged users can access and abuse the forwarded agent sockets.
35+
36+
For this reason, agent forwarding should not be used.
37+
38+
However, there are use cases where working without agent forwarding, is more costly. One possibility is working on a development server. From this server, it is often necessary to access a Git server to synchronize changes. Without a forwarded agent, custom keys would have to be created to access the Git server. These, in turn, could be stolen and thus abused if the server were compromised.
39+
40+
There is a tutorial on Github (https://docs.github.com/en/developers/overview/using-ssh-agent-forwarding) that describes how to configure OpenSSH to pass an agent through to a remote server.
41+
42+
However, it does not address the risk that a leaked agent is a potential security risk. The only warning is that the configuration must only be done for a specific host, otherwise the agent will be passed through to all servers you connect to.
43+
In order to make it as difficult as possible to misuse the leaked keys, it is necessary to protect them with a FIDO2 token or SSH-Askpass. In the case of a passed-through agent, both solutions have a comparable level of security.
44+
45+
Nevertheless, the use of FIDO2 keys is recommended because a vulnerability in the client could eventually leak them. An example of this was the experimental support for roaming in OpenSSH 5.4. This feature should make it possible for a client to resume an unexpectedly terminated connection. Although the OpenSSH server did not support roaming, roaming was enabled in the client by default.
46+
47+
The roaming implementation had two vulnerabilities that allowed an attacker to access sensitive information such as private keys under certain circumstances.
48+
49+
.. warning::
50+
51+
SSH Agent Forwarding should not be used. The reason is that it can prevent a lot of security risks. Agent forwarding often makes it easier to work with multiple servers. However, for most use cases there are ways to accomplish the same tasks without agent forwarding.
52+
53+
If agent forwarding is still required, an FIDO2 token should be used. If this is not possible, e.g. because the server does not support the required algorithms, SSH-Askpass can also be used.

0 commit comments

Comments
 (0)