tcpdump

资讯 2024-07-10 阅读:56 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

转自源地址:https://www.cnblogs.com/maifengqiang/p/3863168.html

Source address: https://www.cnblogs.com/maifengqiang/p/3863168.html

超级详细Tcpdump 的用法

1、抓取回环网口的包:tcpdump -i lo

1, bag to retrieve the ring portal: tcpdump-i lo

2、防止包截断:tcpdump -s0

2, to prevent package interruption: tcpdump-s0

3、以数字显示主机及端口:tcpdump -n

3, host and port by number: tcpdump-n


?第一种是关于类型的关键字,主要包括host,net,port, 例如 host 210.27.48.2,指明 210.27.48.2是一台主机,net 202.0.0.0 指明 202.0.0.0是一个网络地址,port 23 指明端口号是23。如果没有指定类型,缺省的类型是host.

? The first is a key word about types, mainly host, net, port, e.g. host 210.27.48.2, specifying 210.27.48.2, net 202.0.0, indicating 202.0.0 is a web address, port 23 indicating the port number 23. If no specified type, the default type is host.

第二种是确定传输方向的关键字,主要包括src , dst ,dst or src, dst and src ,这些关键字指明了传输的方向。举例说明,src 210.27.48.2 ,指明ip包中源地址是210.27.48.2 , dst net 202.0.0.0 指明目的网络地址是202.0.0.0 。如果没有指明方向关键字,则缺省是src or dst关键字。

The second is the key words that determine the direction of transmission, including mainly src, dst, dst or src, dst and src, which indicate the direction of transmission. For example, src 210.27.48.2, indicating the source address in the ip package is 210.27.48.2, dst net 202.0.0, specifying the target network address is 202.0.0. If no key to the direction is specified, the default is src or dst.

第三种是协议的关键字,主要包括fddi,ip,arp,rarp,tcp,udp等类型。Fddi指明是在FDDI(分布式光纤数据接口网络)上的特定 的网络协议,实际上它是"ether"的别名,fddi和ether具有类似的源地址和目的地址,所以可以将fddi协议包当作ether的包进行处理和 分析。其他的几个关键字就是指明了监听的包的协议内容。如果没有指定任何协议,则tcpdump将会监听所有协议的信息包。

The third is the key word for the protocol, mainly the type of fddi, ip, arp, rp, tcp, udp, etc.. Fddi indicates a specific network protocol on the FDDI (distributed fibre-optic data interface network), which is actually an alias for "ether" and fddi and ether have similar source and destination addresses, so the package can be processed and analysed as a body package. The other key words are the content of the package for listening. If no agreement is specified, tcpdump will listen to all protocols.


? 除了这三种类型的关键字之外,其他重要的关键字如下:gateway, broadcast,less,greater,还有三种逻辑运算,取非运算是 'not ' '! ', 与运算是'and','&&;或运算 是'or' ,'||';这些关键字可以组合起来构成强大的组合条件来满足人们的需要,下面举几个例子来说明。

• In addition to these three types of keywords, other important key words are as follows: Gateway, Broadcast, less, Greater, and there are three logical calculations, which are called 'not '! ', 'and 'and 'and 'and 'and 'and 'and 'and 'and 'and 'and ', or 'or','; these keywords can be combined to form powerful combinations to meet people's needs, as illustrated by a few examples below.

普通情况下,直接启动tcpdump将监视第一个网络界面上所有流过的数据包。

Normally, the tcpdump will be activated directly to monitor all passing data packages on the first network interface.

# tcpdump

tcpdump: listening on fxp0

11:58:47.873028 202.102.245.40.netbios-ns > 202.102.245.127.netbios-ns: udp 50

11:58:47.974331 0:10:7b:8:3a:56 > 1:80:c2:0:0:0 802.1d ui/C len=43

0000 0000 0080 0000 1007 cf08 0900 0000

0e80 0000 902b 4695 0980 8701 0014 0002

000f 0000 902b 4695 0008 00

11:58:48.373134 0:0:e8:5b:6d:85 > Broadcast sap e0 ui/C len=97

ffff 0060 0004 ffff ffff ffff ffff ffff

0452 ffff ffff 0000 e85b 6d85 4008 0002

0640 4d41 5354 4552 5f57 4542 0000 0000

0000 00

使用-i参数指定tcpdump监听的网络界面,这在计算机具有多个网络界面时非常有用,

To specify a network interface for tcpdump listening using the -i parameter, which is very useful when computers have multiple web interfaces.

使用-c参数指定要监听的数据包数量,

Specifies the number of packets to be bugged using the -c parameter,

使用-w参数指定将监听到的数据包写入文件中保存

Specifies that the monitored package will be saved in the file using the -w parameter

A想要截获所有210.27.48.1 的主机收到的和发出的所有的数据包:

A seeks to intercept all data packages received and sent by all 210.27.48.1 hosts:

#tcpdump host 210.27.48.1

B想要截获主机210.27.48.1 和主机210.27.48.2 或210.27.48.3的通信,使用命令:(在命令行中适用 括号时,一定要

B seeks to intercept communications from hosts 210.27.48.1 and 210.27.48.2 or 210.27.48.3 by command: (When the brackets are applied in the command line, be sure)

#tcpdump host 210.27.48.1 and / (210.27.48.2 or 210.27.48.3 /)

C如果想要获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包,使用命令:

C uses an order if it wishes to obtain an ip package for all mainframe communications except for the host and host 210.27.48.2.

#tcpdump ip host 210.27.48.1 and ! 210.27.48.2

D如果想要获取主机210.27.48.1接收或发出的telnet包,使用如下命令:

If D wishes to obtain host 210.27.48.1 receiving or sending a Telnet package, use the following order:

#tcpdump tcp port 23 host 210.27.48.1

E 对本机的udp 123 端口进行监视 123 为ntp的服务端口

E to monitor the udp 123 port of this machine 123 service port for ntp

# tcpdump udp port 123

F 系统将只对名为hostname的主机的通信数据包进行监视。主机名可以是本地主机,也可以是网络上的任何一台计算机。下面的命令可以读取主机hostname发送的所有数据:

F The system will only monitor the communication data package of the hostname. The host name can be either the local host or any computer on the network. The following command can read all data sent by hostname:

#tcpdump -i eth0 src host hostname


G 下面的命令可以监视所有送到主机hostname的数据包:

G The following orders can monitor all data packages delivered to hostname:

#tcpdump -i eth0 dst host hostname

H? 我们还可以监视通过指定网关的数据包:

H? We can also monitor data packages via designated gateways:

#tcpdump -i eth0 gateway Gatewayname

I 如果你还想监视编址到指定端口的TCP或UDP数据包,那么执行以下命令:

i If you also want to monitor a TCP or UDP data package with a location to a specified port, then execute the following command:

#tcpdump -i eth0 host hostname and port 80

J 如果想要获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包

J If you want to get an ip package for all mainframe communications except for the mainframe and host 210.27.48.2.

,使用命令:

, use command:

#tcpdump ip host 210.27.48.1 and ! 210.27.48.2

K 想要截获主机210.27.48.1 和主机210.27.48.2 或210.27.48.3的通信,使用命令

K. Trying to intercept communications from mainframe 210.27.48.1 and mainframe 210.27.48.2 or 210.27.48.3, using orders

:(在命令行中适用 括号时,一定要

: When the brackets are applied in the command line, make sure

#tcpdump host 210.27.48.1 and / (210.27.48.2 or 210.27.48.3 /)

L 如果想要获取主机210.27.48.1除了和主机210.27.48.2之外所有主机通信的ip包,使用命令:

L If you want to get an ip package for all mainframe communications except for the host and host 210.27.48.2, use the command:

#tcpdump ip host 210.27.48.1 and ! 210.27.48.2

M 如果想要获取主机210.27.48.1接收或发出的telnet包,使用如下命令:

M If you want to get the host 210.27.48.1 received or sent out of the Telnet package, use the following order:

#tcpdump tcp port 23 host 210.27.48.1

第三种是协议的关键字,主要包括fddi,ip ,arp,rarp,tcp,udp等类型

The third is the key word of the agreement, mainly the type of fddi, ip, arp, rp, tcp, udp, etc.

除了这三种类型的关键字之外,其他重要的关键字如下:gateway, broadcast,less,

In addition to these three types of keywords, other important keywords are as follows: Gateway, Broadcast, less,

greater,还有三种逻辑运算,取非运算是 'not ' '! ', 与运算是'and','&&';或运算 是'o

Greater, there are three other logical calculations, which are "not '! ', and "and", and "and" and "and" or "o"

r' ,'||';

第二种是确定传输方向的关键字,主要包括src , dst ,dst or src, dst and src ,

The second is the key word that determines the direction of the transmission, including mainly src, dst, dst or src, dst and src,

如果我们只需要列出送到80端口的数据包,用dst port;如果我们只希望看到返回80端口的数据包,用src port。

If we just need to list the data packs sent to port 80, use the dst port; if we just want to see the data pack back to port 80, use the src port.

#tcpdump –i eth0 host hostname and dst port 80? 目的端口是80

#tcpdump-i eth0 hostname and dst port 80?

或者

Or...

#tcpdump –i eth0 host hostname and src port 80? 源端口是80? 一般是提供http的服务的主机

#tcpdump –i eth0 hostname and src port 80?

如果条件很多的话? 要在条件之前加and 或 or 或 not

If there's a lot of conditions, you have to add them before the conditions or not.

#tcpdump -i eth0 host ! 211.161.223.70 and ! 211.161.223.71 and dst port 80

如果在ethernet 使用混杂模式 系统的日志将会记录

If you use hybrid mode in the restnet, the logs of the system will be recorded.

May? 7 20:03:46 localhost kernel: eth0: Promiscuous mode enabled.

May? 7 20:03:46 localhost kernel: device eth0 entered promiscuous mode

May? 7 20:03:57 localhost kernel: device eth0 left promiscuous mode

tcpdump对截获的数据并没有进行彻底解码,数据包内的大部分内容是使用十六进制的形式直接打印输出的。显然这不利于分析网络故障,通常的解决办法是先使用带-w参数的tcpdump 截获数据并保存到文件中,然后再使用其他程序进行解码分析。当然也应该定义过滤规则,以避免捕获的数据包填满整个硬盘。

tcpdump does not decode the intercepted data thoroughly, and most of the contents in the package are printed directly in hexadecimal format. This is clearly not conducive to analysis of network failures. The usual solution is to intercept data using tcpdump with-w parameters and save them to the file before using other programs to decode the analysis. Of course, filtering rules should also be defined in order to avoid the capture of a complete hard disk.

# tcpdump -i eth1 src? host 211.167.237.199

00:02:03.096713 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 2010208:2010352(144) ack 33377 win 8576

00:02:03.096951 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 2010352:2010496(144) ack 33377 win 8576

00:02:03.100928 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 2010496:2010640(144) ack 33377 win 8576

00:02:03.101165 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 2010640:2010784(144) ack 33377 win 8576

00:02:03.102554 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 2010784:2010928(144) ack 33425 win 8576

表明在00:02:03点的时候,211.167.237.199通过ssh源端口连接到221.216.165.189的1467端口

Indicates that at 00:02:03, 211.167.237.199 was connected to the 1467 port at 221.216.165.189 via the ssh port

#tcpdump -i eth1 src host 211.167.237.199 and dst port 1467

00:09:27.603075 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 180400:180544(144) ack 2833 win 8576

00:09:27.605631 IP 211.167.237.199.ssh > 221.216.165.189.1467: P 180544:180688(144) ack 2881 win 8576

截获所有由eth0进入、源地址(src)为192.168.0.5的主机(host),并且(and)目标(dst)端口(port)为80的数据包

Interception of all hosts (host) entering eth0, source address (src) 192.168.0.5 and (and) target (dst) port (port) 80 data packs

观看网卡传送、接收数据包的状态

Watching the network card transfer, receiving the package status

$ netstat? -i

Kernel Interface table

Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg

eth0 1500? 0? 14639 0? 0? 0? 5705? 119? 0 0 BMRU

Iface:? 网卡

Internet:?

RX-OK RX-ERR RX-DRP RX-OVR : 网卡正确接收数据包的数量以及发生错误、流失、碰撞的总数

RX-OK RX-ERR RX-DRP RX-OVR: Number of correct data packages received by webcards and total number of errors, losses, collisions

TX-OK TX-ERR TX-DRP TX-OVR : 网卡正确发送数据包的数量以及发生错误、流失、碰撞的总数

TX-OK TX-ERR TX-DRP TX-OVR: Number of correct data packages sent by webcards and total number of errors, losses, collisions



[root@linux ~]#tcpdump [-nn] [-i 介面] [-w 儲存檔名] [-c 次數] [-Ae]? ? ? ? [-qX] [-r 檔案] [所欲擷取的資料內容]參數:

[root@linux~] #b>tcpdump[-nn] [-i interface] [-w storage name] [-c] [-Ae]?? [-qX] [-r] [wanted data content] arguments:

-nn:直接以 IP 及 port number 顯示,而非主機名與服務名稱

-nn: Display directly in IP and port number instead of host name and service name

-i :後面接要『監聽』的網路介面,例如 eth0, lo, ppp0 等等的介面;

-i: follow a network interface for `advocating', e.g. eth0, lo, ppp0, etc.;

-w :如果你要將監聽所得的封包資料儲存下來,用這個參數就對了!後面接檔名

-w: If you want to save the package from the bugging, use this parameter!

-c :監聽的封包數,如果沒有這個參數, tcpdump 會持續不斷的監聽,

-c: The number of envelopes that listen, and if this parameter is not available, tcpdump will continue to listen.

? ? 直到使用者輸入 [ctrl]-c 為止。

♪ Until the user enters [ctrl]-c.

-A :封包的內容以 ASCII 顯示,通常用來捉取 WWW 的網頁封包資料。

-A: The contents of the package are shown in ASCII and are usually used to capture the WWW web envelope data.

-e :使用資料連接層 (OSI 第二層) 的 MAC 封包資料來顯示;

-e: use MAC package data from the data interface (OSI level 2) for display;

-q :僅列出較為簡短的封包資訊,每一行的內容比較精簡

-q: Only short package information is listed, and each line is more concise

-X :可以列出十六進位 (hex) 以及 ASCII 的封包內容,對於監聽封包內容很有用

-X: Listing the package contents of hexadecimal (hex) and ASCII is useful for listening to the package contents

-r :從後面接的檔案將封包資料讀出來。那個『檔案』是已經存在的檔案,

-r: Reads the package from the file that comes back. The "file" is an existing file.

? ? 並且這個『檔案』是由 -w 所製作出來的。

♪ And this "file" was made by-w.

所欲擷取的資料內容:我們可以專門針對某些通訊協定或者是 IP 來源進行封包擷取,

The content of the data that we want to capture: we can focus on some communications protocols or IP sources, and we can use them as a package.

? ? 那就可以簡化輸出的結果,並取得最有用的資訊。常見的表示方法有:

♪ So you can simplify the output and get the most useful information.

? ? 'host foo', 'host 127.0.0.1' :針對單部主機來進行封包擷取

♪ 'host foo', 'host 127.0.0.1': sealing a single host

? ? 'net 192.168' :針對某個網域來進行封包的擷取;

♪ 'net192.168': wrapping a domain;

? ? 'src host 127.0.0.1' 'dst net 192.168':同時加上來源(src)或目標(dst)限制

♪'src host 127.0.0.1' 'dst net 192,168': add source (src) or target (dst) limits

? ? 'tcp port 21':還可以針對通訊協定偵測,如 tcp, udp, arp, ether 等

♪ 'tcp port 21': Communication protocols can also be detected, e. g. tcp, udp, arp, etc.

? ? 還可以利用 and 與 or 來進行封包資料的整合顯示呢!範例一:以 IP 與 port number 捉下 eth0 這個網路卡上的封包,持續 3 秒[root@linux ~]#tcpdump -i eth0 -nntcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes01:33:40.41 IP 192.168.1.100.22 > 192.168.1.11.1190: P 116:232(116) ack 1 win 964801:33:40.41 IP 192.168.1.100.22 > 192.168.1.11.1190: P 232:364(132) ack 1 win 9648<==按下 [ctrl]-c 之後結束6680 packets captured<==捉下來的封包數量14250 packets received by filter<==由過濾所得的總封包數量7512 packets dropped by kernel<==被核心所丟棄的封包

An example is: the package on this web card was captured with IP and port number on eth0 for 3 seconds [root@linux~] #b>tcpdump -i eth0 -n/b>tpdump: verbose output suppressed, use-v-v for full protocol decodeling on eth0, link-type EN10MB (Ethernet), capture size 96 bytes01:33:40.41 IP1981.100.22 & gt; 192168.11.1990: P 116:232 (116) cppp:33:40.41 IP19268.1.100 & gt; 192.1990:40 = kert = 2,2364 (kt) = 98 t;

如果你是第一次看 tcpdump 的 man page 時,肯定一個頭兩個大,因為 tcpdump 幾乎都是分析封包的表頭資料,使用者如果沒有簡易的網路封包基礎,要看懂粉難吶! 所以,至少您得要回到網路基礎裡面去將 TCP 封包的表頭資料理解理解才好啊! ^_^!至於那個範例一所產生的輸出範例中,我們可以約略區分為數個欄位, 我們以範例一當中那個特殊字體行來說明一下:

If you're looking at the man page of tcpdump for the first time, you're sure to have the first two big ones, because tcpdump almost always analyses the surface data of the package, and users will have to read it if they don't have an easy web envelope base! So at least you have to go back to

01:33:40.41:這個是此封包被擷取的時間,『時:分:秒』的單位;

01:33:40.41: This is the time when the package was taken, 'Time: minutes: seconds' unit;

IP:透過的通訊協定是 IP ;

IP: The communication protocol is defined as IP;

192.168.1.100.22 >:傳送端是 192.168.1.100 這個 IP,而傳送的 port number 為 22,您必須要瞭解的是,那個大於 (>) 的符號指的是封包的傳輸方向喔!

192.168.1.100.22 & gt;: The sender is 192.168.1.1.100 of this IP and the port number is 22. You must understand that the symbol larger than (>) refers to the transfer direction of the package!

192.168.1.11.1190:接收端的 IP 是 192.168.1.11, 且該主機開啟 port 1190 來接收;

192.168.1.11.1190: The recipient's IP is 192.168.1.11 and the host opens the port 1190 to receive;

P 116:232(116):這個封包帶有 PUSH 的資料傳輸標誌, 且傳輸的資料為整體資料的 116~232 byte,所以這個封包帶有 116 bytes 的資料量;

P 116:232(116): This package contains PUSH data transfer tags and the transferred data is 116~232 byte of the whole data, so the package contains 116 bytes of data.

ack 1 win 9648:ACK與 Window size 的相關資料。

Back 1 win 9648: ACK and Windows size.

最簡單的說法,就是該封包是由 192.168.1.100 傳到 192.168.1.11,透過的 port 是由 22 到 1190 , 且帶有 116 bytes 的資料量,使用的是 PUSH 的旗標,而不是 SYN 之類的主動連線標誌。 呵呵!不容易看的懂吧!所以說,上頭才講請務必到TCP 表頭資料的部分去瞧一瞧的啊!

The simplest thing to say is that the package was sent from 192.1681.100 to 192.1681.11, via port from 22 to 1190, and with 116 bytes, using PUSH flag, not SYN, or something. Oh! It's not easy to read! So it's only !

再來,一個網路狀態很忙的主機上面,你想要取得某部主機對你連線的封包資料而已時, 使用 tcpdump 配合管線命令與正規表示法也可以,不過,畢竟不好捉取! 我們可以透過 tcpdump 的表示法功能,就能夠輕易的將所需要的資料獨立的取出來。 在上面的範例一當中,我們僅針對 eth0 做監聽,所以整個 eth0 介面上面的資料都會被顯示到螢幕上, 不好分析啊!那麼我們可以簡化嗎?例如只取出 port 21 的連線封包,可以這樣做:

And again, when you want to get a package of information about a host that's busy with your connection, you can use tcpdump to match a line command with a regular expression, but it's not easy to capture it! We can easily take out the data we need through the tcpdump expression function. In the example above, we just listen to eth0, so the data on the eth0 interface will be displayed on the screen.

[root@linux ~]#tcpdump -i eth0 -nn port 21tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes01:54:37.96 IP 192.168.1.11.1240 > 192.168.1.100.21: . ack 1 win 6553501:54:37.96 IP 192.168.1.100.21 > 192.168.1.11.1240: P 1:21(20) ack 1 win 584001:54:38.12 IP 192.168.1.11.1240 > 192.168.1.100.21: . ack 21 win 6551501:54:42.79 IP 192.168.1.11.1240 > 192.168.1.100.21: P 1:17(16) ack 21 win 6551501:54:42.79 IP 192.168.1.100.21 > 192.168.1.11.1240: . ack 17 win 584001:54:42.79 IP 192.168.1.100.21 > 192.168.1.11.1240: P 21:55(34) ack 17 win 5840

瞧!這樣就僅提出 port 21 的資訊而已,且仔細看的話,你會發現封包的傳遞都是雙向的, client 端發出『要求』而 server 端則予以『回應』,所以,當然是有去有回啊! 而我們也就可以經過這個封包的流向來瞭解到封包運作的過程。 舉例來說:

Look, this is just the information about Port 21, and if you look closely, you'll find that the package's transmissions are two-way, and the client sends the "request" and the server sends the "reply," so of course it goes back! And we can pass through the package to understand how it works. For example:

我們先在一個終端機視窗輸入『 tcpdump -i lo -nn 』 的監聽,

We first enter the "tcpdump-i lo-nn" bug in a terminal window.

再另開一個終端機視窗來對本機 (127.0.0.1) 登入『ssh localhost』

Open another terminal window to access (127.0.1) to "sh localhost"

那麼輸出的結果會是如何?

So what's the result?

[root@linux ~]#tcpdump -i lo -nn 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 2 listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes 3 11:02:54.253777 IP 127.0.0.1.32936> 127.0.0.1.22:S933696132:933696132(0)? ? win 32767 4 11:02:54.253831 IP 127.0.0.1.22 > 127.0.0.1.32936:S920046702:920046702(0)ack933696133 win 32767 5 11:02:54.253871 IP 127.0.0.1.32936 > 127.0.0.1.22: .ack1 win 8192 6 11:02:54.272124 IP 127.0.0.1.22 > 127.0.0.1.32936: P 1:23(22) ack 1 win 8192? ? 7 11:02:54.272375 IP 127.0.0.1.32936 > 127.0.0.1.22: . ack 23 win 8192

上表顯示的頭兩行是 tcpdump 的基本說明,然後:

The first two rows shown in the table above are the basic instructions for tcpdump, and then:

第 3 行顯示的是『來自 client 端,帶有 SYN 主動連線的封包』,

Line 3 shows "a package with SYN main connection from the client end",

第 4 行顯示的是『來自 server 端,除了回應 client 端之外(ACK),還帶有 SYN 主動連線的標誌;

Line 4 shows 'from the server'end with a sign with the SYN main connection, in addition to responding to the clitend (ACK);

第 5 行則顯示 client 端回應 server 確定連線建立 (ACK)

Line 5 shows clit response server confirmed connection creation (ACK)

第 6 行以後則開始進入資料傳輸的步驟。

After line 6, the process of data transfer begins.

從第 3-5 行的流程來看,熟不熟悉啊?沒錯!那就是三向交握的基礎流程啦!夠有趣吧! 不過 tcpdump 之所以被稱為駭客軟體之一可不止上頭介紹的功能吶! 上面介紹的功能可以用來作為我們主機的封包連線與傳輸的流程分析, 這將有助於我們瞭解到封包的運作,同時瞭解到主機的防火牆設定規則是否有需要修訂的地方。

From the 3rd to 5th line, is familiar with it? Yes, that's the

更神奇的使用要來啦!如果我們使用 tcpdump 在 router 上面監聽『明碼』的傳輸資料時, 例如 FTP 傳輸協定,你覺得會發生什麼問題呢? 我們先在主機端下達『 tcpdump -i lo port 21 -nn -X 』然後再以 ftp 登入本機,並輸入帳號與密碼, 結果你就可以發現如下的狀況:

What do you think is going to happen when we use tcpdump to monitor the transmissions of the code over the router, such as the FTP Transfer Agreement? We reach 'tcpdump-i-loport 21-nn-X' under the mainframe and then board the plane with ftp and enter the account and password, and you can see the following:

[root@linux ~]#tcpdump -i lo -nn -X 'port 21'0x0000:? 4500 0048 2a28 4000 4006 1286 7f00 0001? E..H*(@.@.......? ? 0x0010:? 7f00 0001 0015 80ab 8355 2149 835c d825? .........U!Ihttps://www.jianshu.com/p/.%? ? 0x0020:? 8018 2000 fe3c 0000 0101 080a 0e2e 0b67? .....<.........g? ? 0x0030:? 0e2e 0b61 3232 3020 2876 7346 5450 6420? ...a220.(vsFTPd.0x0040:? 322e 302e 3129 0d0a? ? ? ? ? ? ? ? ? ? ? 2.0.1)..? ? 0x0000:? 4510 0041 d34b 4000 4006 6959 7f00 0001? E..A.K@.@.iY....? ? 0x0010:? 7f00 0001 80ab 0015 835c d825 8355 215d? .......https://www.jianshu.com/.%.U!]? ? 0x0020:? 8018 2000 fe35 0000 0101 080a 0e2e 1b37? .....5.........7? ? 0x0030:? 0e2e 0b67 5553 4552 2064 6d74 7361 690d? ...gUSER.dmtsai.? ? 0x0040:? 0a? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? .? ? 0x0000:? 4510 004a d34f 4000 4006 694c 7f00 0001? E..J.O@.@.iL....? ? 0x0010:? 7f00 0001 80ab 0015 835c d832 8355 217f? .......https://www.jianshu.com/.2.U!.? ? 0x0020:? 8018 2000 fe3e 0000 0101 080a 0e2e 3227? .....>........2'? ? 0x0030:? 0e2e 1b38 5041 5353 206d 7970 6173 7377? ...8PASS.mypassw0x0040:? 6f72 6469 7379 6f75 0d0aordisyou..

上面的輸出結果已經被簡化過了,你必須要自行在你的輸出結果當中搜尋相關的字串才行。 從上面輸出結果的特殊字體中,我們可以發現『該 FTP 軟體使用的是 vsftpd ,並且使用者輸入 dmtsai 這個帳號名稱,且密碼是 mypasswordisyou』 嘿嘿!你說可不可怕啊!如果使用的是明碼的方式來傳輸你的網路資料? 所以我們才常常在講啊,網路是很不安全低!

The output results have already been simplified, and you have to search for the relevant string in your output results. From the special characters of the output results, we can see that the FTP software uses vsftpd, and that the user entered the account name dmtsai, and the password is mypasswordsyou.

另外你得瞭解,為了讓網路介面可以讓 tcpdump 監聽,所以執行 tcpdump 時網路介面會啟動在 『錯亂模式 (promiscuous)』,所以你會在 /var/log/messages 裡面看到很多的警告訊息, 通知你說你的網路卡被設定成為錯亂模式!別擔心,那是正常的。 至於更多的應用,請參考 man tcpdump 囉!

And you have to understand that, in order for the tcpdump interface to allow tcpdump to listen, the tcpdump interface will be activated in the "promiscuous" mode, so you will see a lot of warning messages in /var/ log/ messages, telling you that your Internet card is set to be a mess mode! Don't worry, it's normal. As for more applications, look at man tcpdump!

例題:如何使用 tcpdump 監聽 (1)來自 eth0 介面卡且 (2)通訊協定為 port 22 ,(3)目標來源為 192.168.1.100 的封包資料?

Case: How can tcpdump be used to listen to (i) package data from the eth0 interface card and (ii) communication protocol as port 22, and (iii) target source as 192168.1.100?

答:

Response:

tcpdump -i eth0 -nn 'port 22 and src host 192.168.1.100'

ethereal

除了 tcpdump 這個軟體之外,其實你還可以使用 ethereal 這個好用的網路流量分析軟體吶! ethereal 分為文字介面與圖形介面,文字介面的用法與 tcpdump 相當的類似,不過他的指令名稱為 tethereal 就是了。因為用法差不多,所以建議您直接使用 man tethereal 查閱吧! 在 CentOS 上原本就有 ethereal 了,所以請拿出光碟來安裝即可喔! 需要安裝 ethereal 與 ethereal-gnome 才行吶!

In addition to this tcpdump software, you can actually use anothereal, a good network flow analysis software! Etheeal is a text interface with a graphic interface that is similar to tcpdump, but his command name is "tetheal". Because of similar usage, it is recommended that you use a man technical search! There is already anothereal on Centos, so please come up with a disk to install it!

啟動的方法很簡單,你必須要在 X Window 底下,先開啟一個終端機,然後直接輸入 ethereal 後, 就會出現如下的畫面了:

The starting method is simple, and you have to open a terminal under X Windows and enter it directly into the othereal, and the following images will appear:

圖五、ethereal 使用範例圖

Figure V. Ethereal use example diagrams

簡單的作法,你可以點選如上圖顯示的那個按鈕,會出現挑選監聽的介面視窗,如下所示:

In a simple way, you can click on the button as shown in the figure above, and there will be a selection of the listening interface window, as follows:

圖六、ethereal 使用範例圖

Figure VI. Etherial use of example diagrams

你應該選擇要監聽的介面,在這裡因為是測試用的,所以鳥哥使用的是 lo 這個內部介面, 你當然應該要選擇你自己的網路介面才是。然後按下 start 後,就會出現開始偵測的畫面了:

You should choose the interface that you want to listen to, because it's for testing here, so Brother Bird uses the internal interface lo, and of course you should choose your own network interface. Press start and then you'll have a start-up video:

圖七、ethereal 使用範例圖

Figure VII. Etherial use of example diagrams

在這個畫面當中你可以看到很多類型的封包協定,在等你處理完畢後,就可以按下『stop』結束監聽, 而開始進入如下的封包分析畫面。

You can see a lot of packages on this screen, and when you're done with them, you can press "stop" to finish listening and start entering the package analysis screen below.

圖八、ethereal 使用範例圖

Figure VIII. Etherial use of example diagrams

封包分析畫面共分為三大區塊,如上圖所示,第一區塊主要顯示的是封包的標頭資料, 內容就有點類似 tcpdump 的顯示結果,第二區塊則是詳細的表頭資料, 包括訊框的內容、通訊協定的內容以及 socket pair 等等資訊。 第三區塊則是 16 進位與 ASCII 碼的顯示結果。透過這個 ethereal 您就可以一口氣得到所需要的所有封包內容啦! 而且還是圖形介面的,很方便吧!透過在第一區塊選擇不同的封包,就能夠查閱每個封包的資料內容囉!

Packet analysis shows three main sections, as shown in the figure above. The first section shows mainly the header data of the package, which is similar to the tcpdump results, while the second section contains detailed table headers, including the contents of the message box, the content of the communication agreement and the information of the locket pair. The third section is the results of the 16-point entry and ASCII code. Through this body, you can get all the contents of the envelopes you need by breath. It's also the graphic interface. It's convenient. It's easy to read the contents of each envelope by choosing a different envelope in the first block.

nc, netcat

這個 nc 可以用來作為某些服務的檢測,因為他可以連接到某個 port 來進行溝通, 此外,還可以自行啟動一個 port 來傾聽其他用戶的連線吶!非常的不錯用! 如果在編譯的時候給予『GAPING_SECURITY_HOLE』參數的話,嘿嘿! 這個軟體還可以用來取得用戶端的 bash 哩!可怕吧!我們的 CentOS 比較人性化,並沒有給予上面的參數,所以我們不能夠用來作為駭客軟體~ 但是用來取代 telnet 也是個很棒的功能了!(有的系統將執行檔改名為 netcat 啦!)

This nc can be used as a test for certain services, because he can connect to a port, and he can start a port to listen to other users! It's very useful! If the GAPING_SECURITY_HOLE's parameter is given in the compilation, hey! This software can also be used to access client bash miles!

[root@linux ~]#nc [IP|host] [port][root@linux ~]#nc -l -p [port]參數:

[root@linux ~] nc [IPhost] [port] [root@linux ~] nc-l-p [port] parameter:

-l :作為監聽之用,亦即開啟一個 port 來監聽用戶的連線;

-l: Opening a port to listen to users for listening purposes;

-p :開啟的這個 port number範例一:連接本地端的 port 25 查閱相關訊息[root@linux ~]#nc localhost 25localhost.localdomain [127.0.0.1] 25 (smtp) open220 pc.dm.tsai ESMTP Postfixehlo localhost250-pc.dm.tsai250-PIPELINING250-SIZE 40000000250-ETRNquit221 Bye

-p: Open this port number sample number one: connects to local port 25 search-related information [root@linux~] nc localhost 25localhost.localdomain [127.0.1] 25 (smtp) open 220 pc.dm.tai ESMTP Postfixehlo localhost250-pc.dm.thai250-PIPELLING250-SIZE 40000000250-ETRNquit 221 Bye

這個最簡單的功能與 telnet 幾乎一樣吧!可以去檢查某個服務啦!不過,更神奇的在後面, 我們可以建立兩個連線來傳訊喔!舉個例子來說,我們先在 client 端的地方啟動一個 port 來進行傾聽:

The simplest function is almost the same as Telnet. It's possible to check a service. But, even more amazing in the back, we can create two links for transmission. For example, let's start a portal at the end of the client to listen:

範例二:啟動一個 port 來監聽使用者的連線要求[root@linux ~]#nc -l -p 20000# 啟動一個 port 20000? 在主機上,如果此時使用 netstat -tlnp

Example 2: Activate a port to listen to a user's connection request [root@linux~] #nc-l-p 20000# Start a port 20000? On the host, if you use netstat-tlnp at this time

# 就可以看到系統上多出來一個 port 20000 在傾聽使用者的連線喔!

# I can see an extra port 200000 on the system listening to the user's connection!

然後在主機端的地方,也利用 nc 來連線到用戶端,並且輸入一些指令看看喔!

Then use nc to connect to the client where the host is, and enter some instructions!

[root@linux ~]#nc localhost 20000<==這裡可以開始輸入字串了!

[root@linux ~] nc localhost 20000<= Here you can enter the string!

此時,在主機端我們可以打入一些字,你會發現在 client 端會同時出現你輸入的字眼吶! 如果你同時給予一些額外的參數,例如利用標準輸入與輸出 (stdout, stdin) 的話, 那麼就可以透過這個連線來作很多事情了! 當然 nc 的功能不只如此,你還可以發現很多的用途喔! 請自行到您主機內的 /usr/share/doc/nc-1.10/scripts 目錄下看看這些 script ,有幫助的吶! 不過,如果你需要額外的編譯出含有 GAPING_SECURITY_HOLE 功能, 以使兩端

At this point, we can type words on the mainframe, and you'll find the words you typed at the clit. If you give extra parameters at the same time, for example, using standard input and output (stdout, stdin), you can do a lot of things through this connection.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • ??今日BTC和ETH行情分析以及对BICO的看法

    ??今日BTC和ETH行情分析以及对BICO的看法
    ? 如果你刚认识我那么此刻开始你的幸福? 幸运之路正式开启!? ? 历史记录皆可追溯,往期的记录依然可查,山水相逢,皆是缘!?以后也会经常分享一些看好现货给大家! ? 本周热点 ? ? ? ? ? TON 启动公...
  • 孟洪涛谈威科夫交易法

    孟洪涛谈威科夫交易法
     大咖看市 | 判断趋势的工具(一)  原创2016-04-30孟洪涛期货日报 在讨论判断工具之前,我们先说下判断趋势。趋势包括以下几个阶段:趋势的开始,趋势在运行中,以及趋势的结束。我们判断趋势就是能够找出当前市场处于趋势的哪个阶段,以便调整交易。趋势的不同阶段伴随着交易者不同的行为,起始阶段是进场时机,结束阶段是出场时机,同时也是准备反转的进场时机。但是在交易中遇到的最头疼的问题是以上几个趋势阶段并不会白纸黑字表现出来。 ...
标签列表