【发布时间】:2017-06-23 10:19:36
【问题描述】:
Client1 向Server1 发送请求并通过php curl 获得响应。我只能访问 Client1 源代码,我需要记录所有发出和进入 Client1 的请求和响应,并将其保存为 txt 文件。
这样做的原因是用新的服务器替换 Server1。 Client1 源代码非常复杂,因此我决定记录所有请求和响应,以便对 Server1 进行逆向工程。
使用 Linux 命令(例如使用 --verbose 和 --trace-ascii)或使用 WireShark 有一些类似问题的答案,但我也无法理解它们,我必须在我的代码中实现它而不是使用命令。该怎么做?
下面是curl函数:
private function fba8eb($ia61712c)
{
if (empty($this->v9e19674cb))
return false;
$this->query = $ia61712c;
preg_match('/action=(.*?)&/', $ia61712c, $i43da24755ffd);
$i87f2ea = $i43da24755ffd[1];
switch ($this->v488f1ce) {
case 'no-ssl':
case 'ssl':
fwrite($this->v9e19674cb, "POST " . $this->v7d5fd . " HTTP/1.0\r\n");
fwrite($this->v9e19674cb, "User-Agent: Smsmidlet-api/1.0 (" . $this->v488f1ce . "; " . $this->v9f1e7fea . "; " . $this->v9f1e7fea_version . "; call: $i87f2ea)\r\n");
fwrite($this->v9e19674cb, "Host: " . $this->v45213b . "\r\n");
fwrite($this->v9e19674cb, "Content-type: application/x-www-form-urlencoded; charset=utf-8\r\n");
fwrite($this->v9e19674cb, "Content-length: " . strlen($ia61712c) . "\r\n");
fwrite($this->v9e19674cb, "\r\n" . $ia61712c . "\r\n");
$i3bd625bb = '';
while (!feof($this->v9e19674cb)) {
@$i3bd625bb .= fgets($this->v9e19674cb, 2048);
}
$ie4a1f55ce = fclose($this->v9e19674cb);
list($ie3dffdbcc, $this->data) = explode("\r\n\r\n", $i3bd625bb, 2);
return $this->data;
break;
case 'curl':
case 'curl-ssl':
if (get_resource_type($this->v9e19674cb) == 'curl') {
@curl_setopt($this->v9e19674cb, CURLOPT_POST, 1);
@curl_setopt($this->v9e19674cb, CURLOPT_POSTFIELDS, $ia61712c);
@curl_setopt($this->v9e19674cb, CURLOPT_FOLLOWLOCATION, 1);
@curl_setopt($this->v9e19674cb, CURLOPT_HEADER, 0);
@curl_setopt($this->v9e19674cb, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($this->v9e19674cb, CURLOPT_SSL_VERIFYPEER, false);
@curl_setopt($this->v9e19674cb, CURLOPT_USERAGENT, 'Seridlet-api/1.0 (' . $this->v488f1ce . '; ' . $this->v9f1e7fea . '; ' . $this->v9f1e7fea_version . "; call: $i87f2ea )");
@$i3bd625bb = curl_exec($this->v9e19674cb);
$i3bd625bb = html_entity_decode($i3bd625bb);
curl_close($this->v9e19674cb);
return $this->data = $i3bd625bb;
}
break;
}
return false;
}
【问题讨论】:
-
离题:有趣的变量和函数名称。