扫描服务器端口时如何隐藏Linux上的Web服务器名称和openssh版本?

扫描服务器端口时如何隐藏Linux上的Web服务器名称和openssh版本?

当我从外部映射( nmap -A -T4 192.168.40.12 )ip服务器时,显示:

Starting Nmap 4.62 ( http://nmap.org ) at 2009-11-05 14:11 IRST LUA INTERPRETER in nse_init.cc:763: /usr/share/nmap/scripts/robots.nse:4: module 'http' not found: no field package.preload['http'] no file '/usr/share/nmap/nselib/http.lua' no file './http.lua' no file '/usr/local/share/lua/5.1/http.lua' no file '/usr/local/share/lua/5.1/http/init.lua' no file '/usr/local/lib/lua/5.1/http.lua' no file '/usr/local/lib/lua/5.1/http/init.lua' no file '/usr/lib/nmap/nselib-bin/http.so' no file './http.so' no file '/usr/local/lib/lua/5.1/http.so' no file '/usr/local/lib/lua/5.1/loadall.so' SCRIPT ENGINE: Aborting script scan. Interesting ports on 192.168.40.12: Not shown: 1710 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh **OpenSSH 3.9p1** (protocol 1.99) 53/tcp open domain dnsmasq 2.47 80/tcp open http **Apache httpd** 222/tcp open ssh **OpenSSH 3.9p1** (protocol 1.99) 8081/tcp open http CherryPy httpd 2.3.0 MAC Address: 00:10:F3:0F:59:B7 (Nexcom International Co.) Device type: firewall Running: IPCop Linux 2.4.X OS details: IPCop firewall 1.4.10 - 1.4.15 (Linux 2.4.31 - 2.4.34) Network Distance: 1 hop OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.032 seconds 

我修改httpd.conf并更改两行

 ServerSignature Off ServerTokens Prod 

并重新启动Apache服务器,但它仍然显示我的Apache名称

任何人都可以帮助我!

我不相信你可以从NMap中隐藏服务器types,因为它足够聪明地检测握手协商,故障处理等软件types。对于OpenSSH,从FAQ :

2.14 – 为什么OpenSSH向客户报告其版本?

与大多数SSH实现一样,OpenSSH在连接时向客户端报告名称和版本,例如

SSH-2.0-OpenSSH_3.9

客户端和服务器使用此信息来启用协议兼容性调整,以解决与其交谈的实现中已更改,错误或缺less的function。 目前仍然需要这种协议特性检查,因为SSH协议还没有作为RFC发布,在这种情况发生之前可能会有更多不兼容的修改。

如果你真的想要修补SSH以防止版本显示,那么下面是如何做 (未经testing),以下是对你的心态的描述( 通过默默无闻的 利弊得到的 安全性 ),这就是为什么我认为它不好 ,为什么布鲁斯·施奈尔认为 在其他时间 有时 好坏 。

对于OpenSSH尝试以下内容:

 me@lappy:~# ncat 192.168.0.222 22 SSH-2.0-OpenSSH_5.1p1 Debian-3ubuntu1 

酷没有利用或任何东西,但让我们编辑它只是为了好玩。 首先让我们制作一份sshd的副本。

 root@mohsen-desktop:~# mkdir tmp root@mohsen-desktop:~# cd tmp root@mohsen-desktop:~/tmp# cp /usr/sbin/sshd . 

现在让我们修改它。

 root@mohsen-desktop:~/tmp# hexedit sshd 

确定一个蓝色的窗口应该popup,现在看下面的通知命令。 我们要使用search,所以按控制+确保“search文本string”是在白色的打中input。 现在input“OpenSSH”,然后input你需要修改的部分。

它会看起来像这样,只要将所有红色的内容都改为0,最后我就会看到下面的内容。 如果你想input其他东西按Tab键,然后input你想要的ascii部分,只要记住没有退格键。

 00053FE0 6E 64 2D 6C 69 6E 65 00 4F 70 65 6E 53 53 48 5F nd-line.OpenSSH_ 00053FF0 35 2E 31 70 31 20 44 65 62 69 61 6E 2D 33 75 62 5.1p1 Debian-3ub 00054000 75 6E 74 75 31 00 25 73 2C 20 25 73 0A 00 4B 52 untu1.%s, %s..KR 

它现在应该是这样的。

 00053FE0 6E 64 2D 6C 69 6E 65 00 4F 70 65 6E 53 53 48 00 nd-line.OpenSSH. 00053FF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00054000 00 00 00 00 00 00 25 73 2C 20 25 73 0A 00 4B 52 ......%s, %s..KR 

当你完成击中控制+ x保存它,并启动它,记住它需要确切的path。

 root@mohsen-desktop:~/tmp# /root/tmp/sshd root@mohsen-desktop:~/tmp# ncat localhost 22 SSH-2.0-OpenSSH 

只要确保你可以连接到它,你的好去。

 killall sshd rm /usr/sbin/sshd mv /root/tmp/sshd /usr/sbin/ 

对于隐藏Web服务器名称,您应该编译源apache和edite conf文件。

sshd版本string在运行时不可configuration。 您可以在修改SSH_VERSION #define或在sshd.c中使用它之后,通过重新编译OpenSSH来更改它:

  snprintf(buf, sizeof buf, "SSH-%d.%d-%.100s%s", major, minor, SSH_VERSION, newline); 

这不是一个可configuration的选项。 在这两种情况下,您都需要对源代码进行更改。

OpenSSH 依靠版本横幅来协商服务器和客户端之间的某些特性和偏差。 您可以find像这样的更改的旧补丁程序,您可能能够适应更新的版本。

对于Apache ,过去和最近都有一些关于 ServerTokensOff选项的讨论 ,它们将删除产品名称。 但我相信每次都被否决了。 同样,你可能希望使用或修改一些可用的修补程序,但是你可以自己修改。

坦率地说,你会保持更安全的,确实比脱离发布更可靠,只要确保软件在需要时得到更新。 隐藏这些信息可能会推迟一些偷渡者的攻击。 但是对于盲目的或更坚决的攻击,这不会有什么好处。

对于OpenSSH,请尝试以下操作:在/ etc / ssh / sshd_config文件中添加string:

 Banner /etc/ssh/banner 

并在/ etc / ssh / banner中input一些奇怪的东西,如“MS Telnet Service 1.2”:)

对于Apache服务,您可以尝试以下技术:

在httpd.conf文件中写下这个指令:

 ServerTokens ProductOnly ServerSignature Off 

但是之后你会看到一个“Apache”string,没有版本。 如果你想为“mod_security”的Apache谷歌更安全。

祝你好运!

似乎没有认识到Apache版本。 但是,有很多方法可以告诉它的Apache,例如通过查看服务器错误消息。

什么罗曼陀罗说。 不pipe你是否试图伪装软件版本,坏人都会挑起你,如果你有一个可访问的,易受攻击的服务器。 你会得到更好的结果:

  • 打开sshd中的特权分离( UsePrivilegeSeparation – 应该默认为yes
  • 禁用ssh的密码login( PasswordAuthentication noUsePAM no
    • 除非你需要PAM,那么这是更多的configuration – 但你可能不需要
  • 确保Apache被连接到nobody或者相当于( httpd.conf UserGroup指令)

并保持最新的一切。 尤其是apache。