### **方法说明**
插件中的方法名称是固定的,主系统会直接调用以上方法发送使用该方法设置的报文。
在说明文件中提及的函数之外,为了满足更加复杂的需求,允许自定义创建其他方法。用来处理各种数据。
以下方法中各种`POC`、`EXP`的构建模式相同,**这里仅以`POC`为例**。`EXP`与`POC`结构完全相同,后续将不再赘述。
*****
### **Poc_GetHeaders基本方法**
*案例说明:以下案例以 CNVD-2018-24942为例(thinkphp5.1.x远程代码执行漏洞)*
```
public Dictionary<string,string> Poc_GetHeaders(Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> headers = new Dictionary<string, string>();
headers["UserAgent"] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) QQBrowser/6.9.11079.201";
return headers;
}
```
*****
### ***Poc_GetHeaders创建多次请求**
与`Poc_GetUrl`一样,在某些多次请求的EXP中,需要多次请求并修改header。可以使用如下代码:
```
public Dictionary<string,string> (Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> other= new Dictionary<string, string>();
Dictionary<string, string> headers = new Dictionary<string, string>();
other=data["other"];
if (other["numberOfTime"] == "0")
{
//获取到numberOfTime为0,说明还未开始第一次请求。拼接第一次url请求。
headers["UserAgent"] = “payload1”;
}
if(other["numberOfTime"]=="1")
{//第二次请求。
headers["UserAgent"] = “payload2”;
}
else
{//其他情况
headers["UserAgent"] = “payload3”;
}
return headers;
}
```
*****
### **Poc_GetHeaders创建自定义载荷**
自定义载荷在输入框中由用户输入
如果需要处理传入进来的`其他载荷`可以使用以下方式
```
public Dictionary<string, string> Poc_GetHeaders(Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> other= new Dictionary<string, string>();
Dictionary<string, string> headers = new Dictionary<string, string>();
if (data["others"]["otherPayload"] != null && data["others"]["otherPayload"] != "其他载荷")
{
foreach(var name in data["headers"])
{
//数据来自于用户的输入,在主程序的首页三个键值对。
headers["name.Key"]=headers["name.Value"];
}
}
else
{
headers["UserAgent"]=@"UserAgent";
}
return headers;
}
```
除了获取程序中的键值对, 也可以自行在第三个文本框中自定义其他载荷。
*****
### **Poc_GetHeaders方法扩展**
该方法主要用于处理需要发送数据的`header`部分,如果载荷在`header`中,那么就需要构造这部分的数据。
header的名称和值将以`Dictionary`键值对的方式返回。目前限定的头名称和值和使用方法如下:
![](https://img.kancloud.cn/81/a9/81a9e45c158b98dab6bc2a4221745624_242x291.png)
如果需要使用其他类型的header也可以自定义。代码如下:
```
public Dictionary<string,string> Poc_GetHeaders(Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> headers = new Dictionary<string, string>();
headers["test"] ="abc";
return headers;
}
```
*****