主页 > 网络知识 > Black Hat USA 2020议题When TLS Hacks You(2)

Black Hat USA 2020议题When TLS Hacks You(2)

 

image-20210409160012125.png

 

抓包观察DNS响应结果
在DNS服务器的打印结果中,也可以看到,第一次解析结果为真实ip,后续的解析结果为127.0.0.1

 

image-20210412101552195.png

 

抓包观察响应结果,第一次DNS应答为正常的ip,TTL设置为0

 

image-20210412105438502.png

 

后续的响应结果为127.0.0.1

 

image-20210412105537284.png

 

0x023 结果分析

通过浏览器实验是符合预期的,但是该攻击还存在一些局限性:

1.在真实的应用环境中,java默认的TTL值为10s,这个配置会导致DNS Rebinding攻击失败,可以通过修改配置来完成实验。

java.security.Security.setProperty("networkaddress.cache.negative.ttl" , "0");

也可以设置https server来耗尽TTL的时间。
2. Linux环境中,默认不进行dns缓存,windows中会进行dns缓存。
3. PHP环境中默认TTL为0

0x03 TLS session resumption 0x031 TLS 握手

TLS握手包括以下过程:

 

unnamed.jpg

 

步骤如下:

1.Client 发送 ClientHello;Server 回复 Server Hello

2.Client 回复最终确定的 Key,Finished;Server 回复 Finished

3.握手完毕,Client 发送加密后的 HTTP 请求;Server 回复加密后的 HTTP 响应

在此过程中需要消耗两个RTT(Round-Trip Time),抓包分析:

 

image-20210412113636583.png

 

第一个RTT中,客户端发送了Client Hello,服务器响应了Server Hello,同时发送了自己的证书和公钥。

第二个RTT中,客户端计算出了加密key,并使用服务器公钥加密了key,发送给服务器,服务器使用私钥解密数据获取了key,握手完成。

0x032 session resumption

session resumption是指将第一次通过握手协商出来的key保存起来,在后续的请求中直接使用,这样可以节省传送的开销。如下图所示:

 

image-20210412141255228.png

 

可以看到使用session resumption后,节省了一次RTT。

实现session resumption有两种主要方案:

session id

session id用于复用连接信息来减少TLS握手的次数,其机制是在Server Hello时返回session id,客户端在下次建立连接时发送的Client Hello包里可以包含此session_id来恢复之前的会话。

参考rfc5246

The ClientHello message includes a variable-length session identifier. If not empty, the value identifies a session between the same client and server whose security parameters the client wishes to reuse. The session identifier MAY be from an earlier connection,this connection, or from another currently active connection. The second option is useful if the client only wishes to update the random structures and derived values of a connection, and the third option makes it possible to establish several independent secure connections without repeating the full handshake protocol. These independent connections may occur sequentially or simultaneously; a SessionID becomes valid when the handshake negotiating it completes with the exchange of Finished messages and persists until it is removed due to aging or because a fatal error was encountered on a connection associated with the session. The actual contents of the SessionID are defined by the server.

opaque SessionID<0..32>;

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!