nslookup 查询的 shell

编程入门 行业动态 更新时间:2024-10-26 22:25:01
本文介绍了nslookup 查询的 shell_exec 空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 Ubuntu 和 xampp,我正在尝试通过执行命令 nslookup gmail.PHP,但我得到一个空的响应.当我在 Windows 机器以及运行 CentOS 的 Linux 服务器上尝试时,同样的事情也有效.

I am using Ubuntu and xampp, I am trying to execute the command nslookup gmail via. PHP, but I am getting an empty response. The same thing worked while I tried on a windows machine as well as in a Linux server running CentOS.

仅供参考 nslookup gmail 当我直接在终端上运行命令时会给出正确的响应,只有当我尝试通过它来执行时才会出现问题.

FYI nslookup gmail gives proper response when I run the command directly on my terminal, the problem is only when I try to do it via. php.

我什至尝试做一个 which nslookup 然后$nslookup = shell_exec("/usr/bin/nslookup $server"); 没有帮助,但同样的空白响应.

I even tried doing a which nslookup and then $nslookup = shell_exec("/usr/bin/nslookup $server"); with no help, but the same blank response.

虽然注意命令 whoami 在从 PHP 执行时(我在下面的代码中已经注释过)确实给出了 daemon

Although Note that the command whoami when executed from PHP(which I have commented in the following code) does give a proper response of daemon

我对 Ubuntu 很陌生,所以一点帮助会很棒.

I am very new to Ubuntu, so a little help would be great.

<?php
$email = $_GET['email'];
$server = explode("@", $email)[1];
echo $server;

$nslookup = shell_exec("nslookup $server");
// $nslookup = shell_exec("whoami");
print_r($nslookup);
?>

推荐答案

当您通过 Web 浏览器执行时,php 脚本将以较低特权的 www 用户(在您的情况下为守护程序)执行.它没有足够的权限来执行命令 nslookup.我不建议增加 www 用户的权限,这是一个安全风险.作为替代尝试 gethostbyname php 函数.它返回与给定 Internet 主机名对应的 IPv4 地址.

The php script executes as less privileged www user (daemon in your case) when you execute via web browser. It doesn't have enough privilege to execute command nslookup. I won't recommend increasing privilege of www user, which is a security risk. As an alternative try gethostbyname php function. It returns IPv4 address corresponding to a given Internet host name.

<?php
 $email = $_GET['email'];
 $server = explode("@", $email)[1];
 echo $server;
 $ip = gethostbyname($server);
 echo $ip;
?>

这篇关于nslookup 查询的 shell_exec 空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 07:43:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:nslookup   shell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!