# 最近Cilium的Service Mesh中使用到IPSec,所以我们今天来一起看一下IPSec的技术细节。
1.IPSec Overview
https://docs.oracle.com/cd/E19253-01/819-7058/ipsec-ov-2/index.html
2.使用Wireshark解析IPSec
# 1. 通常我们抓取到的IPSec报文都是ESP格式,没有办法解开对应的报文,所以我们先了解怎么把这个密文解开来感受一下,然后再去看具体的实践原理:
# 参考这篇文章: https://blog.csdn.net/xqjcool/article/details/115873905
# 实际上我们需要在Wireshark上添加对应的SPI(Security parameter index)。但是添加这个SPI的信息,需要知道加密的key和认证秘钥以及对应的算法。
我们这里给出一个demo wiresharp的包:
# 这个信息我们在普通的Linux上,我们可以通过 ip x s 去获取对应的信息:[在VPP中的,可以使用 vppctl show ipsec sa]
# ip xfrm state
src 10.2.29.8 dst 10.2.29.12
proto esp spi 0x01fb01bd reqid 48 mode transport
replay-window 0
auth-trunc hmac(md5) 0x00000000000000000000000000000002 96 # Authentication Type and Authentication Key.
enc cbc(aes) 0x00000000000000000000000000000001 # Encryption Type and Encryption Key.
sel src 0.0.0.0/0 dst 0.0.0.0/0
src 10.2.29.12 dst 10.2.29.8
proto esp spi 0x80000001 reqid 47 mode transport
replay-window 0
auth-trunc hmac(md5) 0x00000000000000000000000000000002 96
enc cbc(aes) 0x00000000000000000000000000000001
sel src 0.0.0.0/0 dst 0.0.0.0/0
# 需要把这些信息填些在wirehsakr中:[这样我们就可以把原始的ESP解析成明文来解读]
加上对应的加解密的Key,我们就可以看到明文的信息:
具体的Wirehark报文可以从获取:
https://github.com/BurlyLuo/train/blob/main/IPSec/sip_ipsec.pcap
核心逻辑便是拿到加解密的Key,然后填些到Wireshark中去做相应的解析即可。