### **方法说明**
插件中的方法名称是固定的,主系统会直接调用以上方法发送使用该方法设置的报文。
在说明文件中提及的函数之外,为了满足更加复杂的需求,允许自定义创建其他方法。用来处理各种数据。
以下方法中各种`POC`、`EXP`的构建模式相同,**这里仅以`POC`为例**。`EXP`与`POC`结构完全相同,后续将不再赘述。
### **Poc_GetBody方法**
*案例说明:以下案例以 CNVD-2018-24942为例(thinkphp5.1.x远程代码执行漏洞)*
### **Body设置基本方法**
```
public Dictionary<string, string> Poc_GetBody(Dictionary<string, Dictionary<string, string>> data)
{
//这里因为在thinkphp的POC中并不需要设置body内容,这里就直接创建一个符合返回类型的body值即可
Dictionary<string, string> body = new Dictionary<string, string>();
return body;
}
```
*****
### **Poc_GetUrl创建多次请求**
与`Poc_GetUrl`一样,在某些EXP中,需要多次访问某网站的时候,本质上是发送多次http请求。则可以使用以下方式完成。
```
public Dictionary<string, string> Poc_GetUrl(Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> body= new Dictionary<string, string>();
Dictionary<string, string> other = new Dictionary<string, string>();
other = data["others"];
if (other["numberOfTime"] == "0")
{
//获取到numberOfTime为0,说明还未开始第一次请求。拼接第一次url请求。
body["body"]="payload1";
}
if(other["numberOfTime"]=="1")
{//第二次请求。
body["body"]="payload2";
}
else
{//其他情况
body["body"]="payload3";
}
return body;
}
```
*****
### **创建自定义载荷**
自定义载荷在输入框中由用户输入
如果需要处理传入进来的`其他载荷`可以使用以下方式
```
public Dictionary<string, string> Poc_GetBody(Dictionary<string, Dictionary<string, string>> data)
{
Dictionary<string, string> body = new Dictionary<string, string>();
if (data["others"]["otherPayload"] != null && data["others"]["otherPayload"] != "其他载荷")
{
//数据来自于用户的输入,在主程序的首页第三个大文本框中。
body["body"]=data["others"]["otherPayload"];
}
else
{
body["body"]=@"payload";
}
return body;
}
```
与`Poc_GetUrl`一样,这里的`data`也可以读取`**主体向插件传输的数据格式**`的所有数据。数据结构参见第一章末尾。
*****
其中,`other["numberOfTime"]` 由方法`Poc_GetOther`或者`Exp_GetOther`来进行控制。详情请参考后续内容。