如何找到在不同域名上运行的 php 版本?

发布于 2024-10-12 03:37:27 字数 152 浏览 8 评论 0原文

如何找到在具有不同域名的不同服务器上运行的 php 版本? (如 www.abc.com)这不是我的服务器,没有 ftp 访问权限来使用以下代码创建 php 文件:

<?php
    echo PHP_VERSION;
?>

How can I find the version of php that is running on a distinct server with distinct domain name? (like www.abc.com) It is not my server, no ftp access for making a php file with this code:

<?php
    echo PHP_VERSION;
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

暗恋未遂 2024-10-19 03:37:27

这对我有用:

curl -I http://websitename.com

显示这样的结果或类似的结果,包括 PHP 版本:

HTTP/1.1 200 OK
Date: Thu, 13 Feb 2014 03:40:38 GMT
Server: Apache
X-Powered-By: PHP/5.4.19
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Cache-Control: no-cache
Pragma: no-cache
Set-Cookie: 7b79f6f1623da03a40d003a755f75b3f=87280696a01afebb062b319cacd3a6a9; path=/
Content-Type: text/html; charset=utf-8

请注意,如果您收到此消息:

HTTP/1.1 301 Moved Permanently

您可能需要卷曲网站的 www 版本,即:

curl -I http://www.websitename.com

This works for me:

curl -I http://websitename.com

Which shows results like this or similar including the PHP version:

HTTP/1.1 200 OK
Date: Thu, 13 Feb 2014 03:40:38 GMT
Server: Apache
X-Powered-By: PHP/5.4.19
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Cache-Control: no-cache
Pragma: no-cache
Set-Cookie: 7b79f6f1623da03a40d003a755f75b3f=87280696a01afebb062b319cacd3a6a9; path=/
Content-Type: text/html; charset=utf-8

Note that if you receive this message:

HTTP/1.1 301 Moved Permanently

You may need to curl the www version of the website instead i.e.:

curl -I http://www.websitename.com
喜你已久 2024-10-19 03:37:27

我使用 redbot,这是一个很棒的工具,可以查看 PHP 版本,还可以查看许多其他有用的信息,例如标头、编码、keepalive 等等。

上尝试一下,

http://redbot.org

我喜欢它!

我也赞成尼尔的回答:curl -I http://websitename.com

I use redbot, a great tool to see the PHP version, but also many other useful infos like headers, encoding, keepalive and many more.

Try it on

http://redbot.org

I love it!

I also up vote Neil's answer: curl -I http://websitename.com

煮茶煮酒煮时光 2024-10-19 03:37:27

有时,PHP 会发出一个 X-Powered-By: 响应标头,您可以使用 Firebug 等查看该标头。

如果此设置(由 ini 设置 expose_php 控制) ) 被关闭(通常是这样),没有办法知道所使用的 PHP 版本 - 确实如此。运行什么 PHP 版本与外界无关,从安全角度来看,掩盖这一点是有好处的。

Sometimes, PHP will emit a X-Powered-By: response header which you can look at e.g. using Firebug.

If this setting (controlled by the ini setting expose_php) is turned off (it often is), there is no way to tell the PHP version used - and rightly so. What PHP version is running is none of the outside world's business, and it's good to obscure this from a security perspective.

别理我 2024-10-19 03:37:27

有一种令人惊讶的有效方法,包括使用 复活节彩蛋

它们因版本而异。

There is a surprisingly effective way that consists of using the easter eggs.

They differ from version to version.

夜光 2024-10-19 03:37:27

偶然:默认错误页面通常包含详细信息,例如

Apache/{版本} ({操作系统}) {模块} PHP/{版本} {模块} 服务器位于 {域}

不太容易:找出服务器上运行的 PHP 应用程序版本以及它们需要哪个版本的 PHP。

另一种方法,只是为了完整性而提及;阅读后请忘记:您可以(但您不会!)通过尝试已知的漏洞来检测 PHP 版本。

By chance: Default error pages often contain detailed information, e.g.

Apache/{Version} ({OS}) {Modules} PHP/{Version} {Modules} Server at {Domain}

Not so easy: Find out which versions of PHP applications run on the server and which version of PHP they require.

Another approach, only mentioned for the sake of completeness; please forget after reading: You could (but you won't!) detect the PHP version by trying known exploits.

千纸鹤带着心事 2024-10-19 03:37:27

我建议您更简单且独立于平台的解决方案 - 适用于 Google Chrome 的 wappalyzer:

参见此处

I suggest you much easier and platform independent solution to the problem - wappalyzer for Google Chrome:

See here

烟酒忠诚 2024-10-19 03:37:27

可能使用类似 firefox 的 tamperdata 的东西并查看返回的标头(如果它们启用了发布)。

Possibly use something like firefox's tamperdata and look at the header returned (if they have publishing enabled).

强辩 2024-10-19 03:37:27

正如其他人已经提到的那样,可以通过开发人员工具检查浏览器中的“X-Powered-By”响应标头来找到其他域的 PHP 版本。如果它没有通过 php.ini 配置公开,除非您有权访问服务器,否则您无法获取它。

There is a possibility to find the PHP version of other domain by checking "X-Powered-By" response header in the browser through developer tools as other already mentioned it. If it is not exposed through the php.ini configuration there is no way you can get it unless you have access to the server.

守护在此方 2024-10-19 03:37:27

由于提出这个问题时隐含 PHP 作为用于提取任何网站的 PHP 版本信息的工具,因此我认为该代码为该问题提供了一个可行的解决方案。

下面的类用于提取给定一组 cURL 参数 ($opts) 的标头。

class get_site_php_info {
  public $headers;

  public function __construct() {
    $this->headers = array();
  }
  public function fetch_headers($opts){
    $opts[CURLOPT_HEADERFUNCTION] = array($this, '_setHeader');
    $ch = curl_init();
    curl_setopt_array($ch, $opts);
    return curl_exec($ch);
  }

  private function _setHeader($ch, $header) {
    $this->headers[] = $header;
    return strlen($header);
  }
}

当以下面代码中指定的形式提交 URL 时,将调用此类。

echo "<h1>Get Site Header Information</h1>";
echo "<h3>Domain input form</h3>";
echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post' enctype=''>" .
  "<table>" .
  "<tr><td>Enter URL: </td>" .
  "<td><input type='text' name='url' value='' size='40' maxlength='128' placeholder='your domain here' /></td>" .
  "</tr>" .
  "<tr><td colspan='2'><input type='hidden' name='action' value='submitted' />" .
  "<input type='submit' name='submit' value='Submit' /> " .
  "<input type='reset' value='Reset' /></td></tr>" .
  "</table>" .
  "</form>";
 
if (isset($_POST['action']) && $_POST['action'] == "submitted") {
  echo "<h4>Output</h4>";
  if ($_POST['url']) {
    $url = substr($_POST['url'], 0, 4) == 'http'? $_POST['url']: 'http://' . $_POST['url'];
    echo "<h3>General [" . $url . "]</h3>";
    $opts = array(
        CURLOPT_URL => $url,                // set the URL
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CONNECTTIMEOUT => 120,
        CURLOPT_TIMEOUT => 120,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_MAXREDIRS => 3,
    );
    $info = new get_site_php_info;

    $data = $info->fetch_headers($opts);
    echo "<h3>Headers</h3><pre>" . var_export($info->headers, true) . "</pre>";

  } else {
      echo "<p>The field is not set!!</p>";
  }
  echo "<p><a href='" . $_SERVER['PHP_SELF'] . "'>Try again</a></p>";
}

我确信代码和 cURL 选项可以改进,但这提供了一个工作 PHP 代码,用于提取允许提取 PHP 版本和其他信息的标头。 Helow 是示例输出:

显示 PHP 版本的示例输出

我希望这段代码对某人有用并节省一些时间。

As this questions was asked with PHP implied as the tool to use to extract the PHP version information for any website, I felt that the code provides a working solution to the question.

The class below is used to extract the headers given a set of cURL parameters ($opts).

class get_site_php_info {
  public $headers;

  public function __construct() {
    $this->headers = array();
  }
  public function fetch_headers($opts){
    $opts[CURLOPT_HEADERFUNCTION] = array($this, '_setHeader');
    $ch = curl_init();
    curl_setopt_array($ch, $opts);
    return curl_exec($ch);
  }

  private function _setHeader($ch, $header) {
    $this->headers[] = $header;
    return strlen($header);
  }
}

This class is called when a URL is submitted in the form specified in the code below.

echo "<h1>Get Site Header Information</h1>";
echo "<h3>Domain input form</h3>";
echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post' enctype=''>" .
  "<table>" .
  "<tr><td>Enter URL: </td>" .
  "<td><input type='text' name='url' value='' size='40' maxlength='128' placeholder='your domain here' /></td>" .
  "</tr>" .
  "<tr><td colspan='2'><input type='hidden' name='action' value='submitted' />" .
  "<input type='submit' name='submit' value='Submit' /> " .
  "<input type='reset' value='Reset' /></td></tr>" .
  "</table>" .
  "</form>";
 
if (isset($_POST['action']) && $_POST['action'] == "submitted") {
  echo "<h4>Output</h4>";
  if ($_POST['url']) {
    $url = substr($_POST['url'], 0, 4) == 'http'? $_POST['url']: 'http://' . $_POST['url'];
    echo "<h3>General [" . $url . "]</h3>";
    $opts = array(
        CURLOPT_URL => $url,                // set the URL
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CONNECTTIMEOUT => 120,
        CURLOPT_TIMEOUT => 120,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_MAXREDIRS => 3,
    );
    $info = new get_site_php_info;

    $data = $info->fetch_headers($opts);
    echo "<h3>Headers</h3><pre>" . var_export($info->headers, true) . "</pre>";

  } else {
      echo "<p>The field is not set!!</p>";
  }
  echo "<p><a href='" . $_SERVER['PHP_SELF'] . "'>Try again</a></p>";
}

I am sure that the code and cURL options can be improved but this provides a working PHP code for extracting the headers that allow the PHP version and other information to be extracted. Helow is a sample output:

Sample output showing PHP version

I hope that this code is useful to someone and saves a bit of time.

深爱不及久伴 2024-10-19 03:37:27

你不能。原因之一是并非每个网站都使用 PHP。另一个原因是:即使有一些迹象表明可能使用 PHP(例如 .php 文件扩展名、一些“PHPSESSID”参数、X-Powered-By 标头包含“PHP”等的字段)这些信息可能会被欺骗,让您认为使用了 PHP。

You can’t. One reason is that not every web site uses PHP. And another reason is: Even if there are some signs that PHP might be used (e.g. .php file name extension, some “PHPSESSID” parameter, X-Powered-By header field containing “PHP”, etc.) those information might be spoofed to let you think PHP is used.

鸠魁 2024-10-19 03:37:27

答案是:NMAP 程序

感谢您的关注...

另一种方法是通过此站点 (http://web-sniffer.net/) 获取 HTTP 标头
或用于获取 HTTP 标头的 firefox 附加组件...

最好的问候

THE ANSWER IS : NMAP PROGRAM

THANKS FOR YOUR ATTENTIONS ...

another way is getting HTTP Headers by this site (http://web-sniffer.net/)
or firefox add-on for getting HTTP Headers...

Best Regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文