1

为什么我的 cURL 上传文件被 forti 防火墙检测为 IPS 攻击:

function post_files($url, $files,$data=array()) {


    if (!is_array($files)) {
        //Convert to array
        $files[] = $files;
    }
    $n = sizeof($files);
    for ($i = 0; $i < $n; $i++) {
        $data['file' + $i] = "@" . $files[$i];
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    $response = curl_exec($ch);
    return $response;
}

有卷曲选项吗?

4

1 回答 1

2

有了这个,请求似乎来自 Firefox:

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6');

这样上传似乎来自实际站点:

curl_setopt ($ch, CURLOPT_REFERER, "http://domain you should have come from");
于 2013-03-27T14:33:24.870 回答