你可以在不离开你的终端的情况下找到这些东西的答案。
让我们来看看自己:
# strace netstat -su &> netstat_strace
这将是一个“开放”和“读”,因为它正从某个数据(但用grep出它无法读取/开):
# grep -E 'open|read' netstat_strace | grep -v ENOENT
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/proc/meminfo", O_RDONLY|O_CLOEXEC) = 3
read(3, "MemTotal: 3854816 kB\nMemF"..., 1024) = 1024
open("/proc/net/snmp", O_RDONLY) = 3
read(3, "Ip: Forwarding DefaultTTL InRece"..., 4096) = 1261
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 4
read(4, "# Locale name alias data base.\n#"..., 4096) = 2570
read(4, "", 4096) = 0
read(3, "", 4096) = 0
open("/proc/net/netstat", O_RDONLY) = 3
read(3, "TcpExt: SyncookiesSent Syncookie"..., 4096) = 2158
read(3, "", 4096) = 0
,并从检查strace
输出,我们可以看到它写的字符串:
write(1, "IcmpMsg:\n InType0: 11\n InT"..., 373IcmpMsg:
InType0: 11
好吧,那很有趣。让我们来看看男人页netstat
:
man netstat
如果你看看FILES
下:
FILES
/etc/services -- The services translation file
/proc -- Mount point for the proc filesystem, which gives access to kernel status information via the following files.
/proc/net/dev -- device information
/proc/net/raw -- raw socket information
/proc/net/tcp -- TCP socket information
/proc/net/udp -- UDP socket information
/proc/net/igmp -- IGMP multicast information
...
你可以看到为什么它open
版,并从上述read
。在搜索“清除”或“重置”(或阅读它)时,您会发现这些不是该命令的选项。
下一步将检查man proc
,它将自己描述为“过程信息伪文件系统”。
从这里,你可以得到这样的想法,如果你修改了netstat读取的文件,你可以改变netstat的输出(在我看来,/proc/net/netstat
看起来特别有趣) - 而且你可以 - 但是我会建议让它只读。
我喜欢这个很聪明的“逆向工程”类方法 – Marged