使用 ping 命令来探测目标主机的操作系统类型

发布于 2023-01-20 14:23:55 字数 7992 浏览 120 评论 0

http://subinsb.com/default-device-ttl-values/ 里学到的。

原来不同的操作系统默认的 TTL(Time To Live)值是不同的,因此通过 ping 命令返回的 ttl 值加上 traceroute 获得的跳转节点数就能算出目标节点设置的 TTL 数,从而推测出目标节点的操作系统类型。

比如,我们要探测 sachachua.com 的操作系统类型,可以这么做:

先用 traceroute 确定跳转数

traceroute sachachua.com

结果为:

traceroute to sachachua.com (104.28.7.65), 30 hops max, 60 byte packets
 1  _gateway (192.4.4.4)  1.493 ms  1.857 ms  1.785 ms
 2  * * *
 3  192.168.254.254 (192.168.254.254)  3.066 ms  3.508 ms  4.061 ms
 4  61.142.7.17 (61.142.7.17)  21.018 ms  21.446 ms  21.389 ms
 5  113.98.5.221 (113.98.5.221)  4.585 ms 113.98.5.217 (113.98.5.217)  6.898 ms 113.98.5.221 (113.98.5.221)  5.993 ms
 6  113.98.22.25 (113.98.22.25)  5.033 ms  3.565 ms 113.98.22.33 (113.98.22.33)  10.527 ms
 7  * * *
 8  113.98.37.37 (113.98.37.37)  27.135 ms 113.98.37.29 (113.98.37.29)  17.216 ms 113.98.37.33 (113.98.37.33)  10.132 ms
 9  202.97.66.166 (202.97.66.166)  9.187 ms *  9.839 ms
10  202.97.60.42 (202.97.60.42)  12.112 ms 202.97.91.145 (202.97.91.145)  9.883 ms  9.838 ms
11  202.97.22.122 (202.97.22.122)  159.378 ms 202.97.58.130 (202.97.58.130)  238.142 ms 202.97.27.238 (202.97.27.238)  159.718 ms
12  202.97.50.58 (202.97.50.58)  167.309 ms  177.650 ms  176.709 ms
13  218.30.53.214 (218.30.53.214)  241.310 ms  240.190 ms  239.304 ms
14  104.28.7.65 (104.28.7.65)  199.621 ms  176.317 ms  198.775 ms

从中可以看到,从本地到目标主机一共经过了 14-1=13

ping 之

ping -c 4 sachachua.com

结果为:

PING sachachua.com (104.28.7.65) 56(84) bytes of data.
64 bytes from 104.28.7.65 (104.28.7.65): icmp_seq=1 ttl=51 time=159 ms
64 bytes from 104.28.7.65 (104.28.7.65): icmp_seq=2 ttl=51 time=159 ms
64 bytes from 104.28.7.65 (104.28.7.65): icmp_seq=3 ttl=51 time=177 ms
64 bytes from 104.28.7.65 (104.28.7.65): icmp_seq=4 ttl=51 time=159 ms

--- sachachua.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 159.164/163.926/177.276/7.720 ms

最终可以算出,目标主机设置的 TTL 为 51+13=64

查表

下面这张表是不同设备/操作系统默认 TTL 值的明细表:

Device / OSVersionProtocolTTL
AIX TCP60
AIX UDP30
AIX3.2, 4.1ICMP255
BSDIBSD/OS 3.1 and 4.0ICMP255
CompaTru64 v5.0ICMP64
Cisco ICMP254
DEC PathworksV5TCP and UDP30
Foundry ICMP64
FreeBSD2.1RTCP and UDP64
FreeBSD3.4, 4.0ICMP255
FreeBSD5ICMP64
HP-UX9.0xTCP and UDP30
HP-UX10.01TCP and UDP64
HP-UX10.2ICMP255
HP-UX11ICMP255
HP-UX11TCP64
Irix5.3TCP and UDP60
Irix6.xTCP and UDP60
Irix6.5.3, 6.5.8ICMP255
juniper ICMP64
MPE/IX (HP) ICMP200
Linux2.0.x kernelICMP64
Linux2.2.14 kernelICMP255
Linux2.4 kernelICMP255
LinuxRed Hat 9ICMP and TCP64
MacOS/MacTCP2.0.xTCP and UDP60
MacOS/MacTCPX (10.5.6)ICMP/TCP/UDP64
NetBSD ICMP255
Netgear FVG318 ICMP and UDP64
OpenBSD2.6 & 2.7ICMP255
OpenVMS07.01.2002ICMP255
OS/2TCP/IP 3.0 64
OSF/1V3.2ATCP60
OSF/1V3.2AUDP30
Solaris2.5.1, 2.6, 2.7, 2.8ICMP255
Solaris2.8TCP64
StratusTCP_OSICMP255
StratusTCP_OS (14.2-)TCP and UDP30
StratusTCP_OS (14.3+)TCP and UDP64
StratusSTCPICMP/TCP/UDP60
SunOS4.1.3/4.1.4TCP and UDP60
SunOS5.7ICMP and TCP255
UltrixV4.1/V4.2ATCP60
UltrixV4.1/V4.2AUDP30
UltrixV4.2 – 4.5ICMP255
VMS/Multinet TCP and UDP64
VMS/TCPware TCP60
VMS/TCPware UDP64
VMS/Wollongong1.1.1.1TCP128
VMS/Wollongong1.1.1.1UDP30
VMS/UCX TCP and UDP128
Windowsfor WorkgroupsTCP and UDP32
Windows95TCP and UDP32
Windows98ICMP32
Windows98, 98 SEICMP128
Windows98TCP128
WindowsNT 3.51TCP and UDP32
WindowsNT 4.0TCP and UDP128
WindowsNT 4.0 SP5- 32
WindowsNT 4.0 SP6+ 128
WindowsNT 4 WRKS SP 3, SP 6aICMP128
WindowsNT 4 Server SP4ICMP128
WindowsMEICMP128
Windows2000 proICMP/TCP/UDP128
Windows2000 familyICMP128
WindowsServer 2003 128
WindowsXPICMP/TCP/UDP128
WindowsVistaICMP/TCP/UDP128
Windows7ICMP/TCP/UDP128
WindowsServer 2008ICMP/TCP/UDP128
Windows10ICMP/TCP/UDP128

但其实这张表可以缩减为:

Device / OSTTL
*nix (Linux/Unix)64
Windows128
Solaris/AIX254

因此,大概可以推测出 sachachua.com 使用的是 *nix 类操作系统,当然很大可能就是 Linux 操作系统。

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

落花随流水

暂无简介

文章
评论
28 人气
更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

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