标签:
分析所用软件下载:Wireshark-win32-1.10.2.exe
一.阅读导览
1.分析FTP协议
2.分析DNS协议
3. 分析HTTP协议
二.分析要求
(1)ftp部分:
(2)dns部分:
(3)http部分
1. 设计应用以获取http报文
2. 分析http报文的格式与内容(分析至少5个报文,并理解它们之间的关系)
3. 分析http协议的工作过程
三.分析内容
(1)ftp部分:
配置域
配置用户权限
在命令行窗口中登录FTP 服务器,根据1 中的配置信息输入用户名和口令,同时使用抓包工具截获ftp报文,参考命令如下:
C:\ >ftp
ftp> open
To 172.16.10.100 //登录ftp 服务器
Connected to 172.16.10.100.
220 Serv-U FTP Server v6.2 for WinSock ready...
User(none): test1 //输入用户名
331 User name okay, need password.
Password:123 //输入用户密码
230 User logged in, proceed. //通过认证,登录成功
ftp> quit //退出FTP
221 Goodbye!
从浏览器访问ftp,再次抓包
分析见第四部分
(2)dns部分:
先清除DNS缓存然后ping西南大学主页swu.edu.cn获取并用抓包工具截获DNS报文
分析见第四部分
分析见第四部分
(3)http部分
1. 设计应用以获取http报文
访问一些特定的网址,如学校官网主页、百度主页……用抓包工具截获http协议报文:
访问西南大学主页,抓取http报文
2. 分析http报文的格式与内容(分析至少5个报文,并理解它们之间的关系)
分析见第四部分
3. 分析http协议的工作过程
分析见第四部分
四、分析结果及总结
1. 获取并分析ftp报文
(1)登录ftp服务器:172.18.3.136的第一个ftp报文:
32323020536572762d5520465450205365727665722076362e3020666f722057696e536f636b2072656164792e2e2e0d0a
状态码:32 32 30
Response code: Service ready for new user (220)
应答串:
Response arg: Serv-U FTP Server v6.0 for WinSock ready...
(2)登录ftp服务器:172.18.3.136第二个ftp报文:
5553455220746573740d0a
Request command: USER
Request arg: test
(3)登录ftp服务器:172.18.3.136第三个ftp报文:
07a200151ea58e9063bcdaf85010b5c9a7110000
Response code: User name okay, need password (331)
Response arg: User name okay, need password.
(4)登录ftp服务器:172.18.3.136第四个ftp报文:
50415353203132330d0a
Request command: PASS
Request arg: 123
(5)登录ftp服务器:172.18.3.136第五个ftp报文:
3233302055736572206c6f6767656420696e2c2070726f636565642e0d0a
Response code: User logged in, proceed (230)
Response arg: User logged in, proceed.
(6)登录ftp服务器:172.18.3.136第六个ftp报文:
515549540d0a
Request command: QUIT
(7)登录ftp服务器:172.18.3.136第七个ftp报文:
32323120476f6f64627965210d0a
Response code: Service closing control connection (221)
Response arg: Goodbye!
(8)使用浏览器访问ftp服务器172.18.3.136
ftp内容与cmd命令访问ftp服务器类似。
在命令行窗口中访问FTP 服务器时客户端使用的是PORT 模式连接服务器,浏览器访问ftp服务器是时客户端以PASV 模式连接服务器。
PORT模式:客户端从任意非特权端口N连接到服务器的命令端口21,然后把客户端监听端口N+1并发送PORT N+1到服务器,接着服务器从自己的数据端口20连接到客户端指定的端口N+1。断开连接时客户端向服务器发送quit命令,服务器回复221状态码,然后客户端开始向服务器发送TCP断开连接报文经三次握手结束连接
PASV模式:客户端打开任意两个非特权本地端口,第一个连接到服务器21端口,并提交PASV命令,服务器发送PORT P命令道客户端,然后本地客户端使用第二个端口连接服务器端口P进行数据传输。
2. 获取并分析DNS报文
(1)ping西南大学主页swu.edu.cn的DNS查询报文
106c01000001000000000000037377750365647502636e0000010001
标识:10 6c
Transaction ID: 0x106c
参数:01 00
Flags: 0x0100 Standard query
问题数:00 01
Questions: 1
回答数:00 00
Answer RRs: 0
管理机构数:00 00
Authority RRs: 0
附加信息数:00 00
Additional RRs: 0
问题区:037377750365647502636e0000010001
Queries: swu.edu.cn: type A, class IN
(2)ping西南大学主页swu.edu.cn的DNS响应报文
106c85800001000100010001037377750365647502636e0000010001c00c00010001000151800004caca6023c00c0002000100015180000704646e7332c00cc03800010001000151800004caca6022
标识:10 6c
Transaction ID: 0x106c
参数:8580
Flags: 0x8580 Standard query response, No error
问题数:00 01
Questions: 1
回答数:00 01
Answer RRs: 1
管理机构数:00 01
Authority RRs: 1
附加信息数:00 01
Additional RRs: 1
问题区:037377750365647502636e0000010001
swu.edu.cn: type A, class IN
回答区:c00c00010001000151800004caca6023
swu.edu.cn: type A, class IN, addr 202.202.96.35
管理机构区:c00c0002000100015180000704646e7332c00c
swu.edu.cn: type NS, class IN, ns dns2.swu.edu.cn
附加信息区:c03800010001000151800004caca6022
dns2.swu.edu.cn: type A, class IN, addr 202.202.96.34
(3)ping百度主页www.baidu.com(未登录外网)的DNS查询报文
6ab3010000010000000000000377777705626169647503636f6d0000010001
标识:6a b3
Transaction ID: 0x6ab3
参数:01 00
Flags: 0x0100 Standard query
问题数:00 01
Questions: 1
回答数:00 00
Answer RRs: 0
管理机构数:00 00
Authority RRs: 0
附加信息数:00 00
Additional RRs: 0
问题区:0377777705626169647503636f6d0000010001
www.baidu.com: type A, class IN
(4)ping百度主页www.baidu.com(未登录外网)的DNS响应报文
6ab3818000010003000500050377777705626169647503636f6d0000010001c00c00050001000000d2000f0377777701610673686966656ec016c02b000100010000005b0004b461216cc02b000100010000005b0004b461216bc02f00020001000000f50006036e7333c02fc02f00020001000000f50006036e7334c02fc02f00020001000000f50006036e7331c02fc02f00020001000000f50006036e7335c02fc02f00020001000000f50006036e7332c02fc078000100010000016d000473efd2b0c066000100010000016d00043d87a2d7c09c000100010000016d0004774bde11c08a000100010000016d00043d87a5e0c0ae000100010000016d0004b49585f1
标识:6a b3
Transaction ID: 0x6ab3
参数:8180
Flags: 0x8180 Standard query response, No error
问题数:00 01
Questions: 1
回答数:00 03
Answer RRs: 3
管理机构数:00 05
Authority RRs: 5
附加信息数:00 05
Additional RRs: 5
问题区:0377777705626169647503636f6d0000010001
www.baidu.com: type A, class IN
回答区:
c00c00050001000000d2000f0377777701610673686966656ec016c02b000100010000005b0004b461216cc02b000100010000005b0004b461216b
www.baidu.com: type CNAME, class IN, cname www.a.shifen.com
www.a.shifen.com: type A, class IN, addr 180.97.33.108
www.a.shifen.com: type A, class IN, addr 180.97.33.107
管理机构区:
c02f00020001000000f50006036e7333c02fc02f00020001000000f50006036e7334c02fc02f00020001000000f50006036e7331c02fc02f00020001000000f50006036e7335c02fc02f00020001000000f50006036e7332c02f
a.shifen.com: type NS, class IN, ns ns3.a.shifen.com
a.shifen.com: type NS, class IN, ns ns4.a.shifen.com
a.shifen.com: type NS, class IN, ns ns1.a.shifen.com
a.shifen.com: type NS, class IN, ns ns5.a.shifen.com
a.shifen.com: type NS, class IN, ns ns2.a.shifen.com
附加信息区:
c078000100010000016d000473efd2b0c066000100010000016d00043d87a2d7c09c000100010000016d0004774bde11c08a000100010000016d00043d87a5e0c0ae000100010000016d0004b49585f1
ns4.a.shifen.com: type A, class IN, addr 115.239.210.176
ns3.a.shifen.com: type A, class IN, addr 61.135.162.215
ns5.a.shifen.com: type A, class IN, addr 119.75.222.17
ns1.a.shifen.com: type A, class IN, addr 61.135.165.224
ns2.a.shifen.com: type A, class IN, addr 180.149.133.241
(5)ping微软主页www.microsoft.com的DNS查询报文
48030100000100000000000003777777096d6963726f736f667403636f6d0000010001
标识:48 03
Transaction ID: 0x4803
参数:01 00
Flags: 0x0100 Standard query
问题数:00 01
Questions: 1
回答数:00 00
Answer RRs: 0
管理机构数:00 00
Authority RRs: 0
附加信息数:00 00
Additional RRs: 0
问题区:03777777096d6963726f736f667403636f6d0000010001
www.microsoft.com: type A, class IN
(6)ping微软主页www.microsoft.com的DNS响应报文
4803818000010005000a000603777777096d6963726f736f667403636f6d0000010001c00c000500010000081c001a06746f67676c6503777777026d7306616b61646e73036e657400c02f0005000100000258001e03777777096d6963726f736f667405636f6d2d6307656467656b6579c044c05500050001000051b3002e03777777096d6963726f736f667405636f6d2d6307656467656b6579036e65740b676c6f62616c7265646972c03dc07f0005000100000660001306653130303838026361017304746c3838c044c0b900010001000002580004b81e489ac0c000020001000000e70007046e396361c0c3c0c000020001000000e70007046e326361c0c3c0c000020001000000e70007046e376361c0c3c0c000020001000000e70007046e306361c0c3c0c000020001000000e70007046e366361c0c3c0c000020001000000e70007046e346361c0c3c0c000020001000000e70007046e336361c0c3c0c000020001000000e70007046e316361c0c3c0c000020001000000e70007046e386361c0c3c0c000020001000000e70007046e356361c0c3c1210001000100000e9600043d93a527c16d000100010000077c0004db4c0e14c0fb00010001000018250004af0611c6c15a00010001000003bb00043acde0f7c14700010001000001cb00047437e527c1930001000100000450000458dd51c3
标识:48 03
Transaction ID: 0x4803
参数:81 80
Flags: 0x8180 Standard query response, No error
问题数:00 01
Questions: 1
回答数:00 05
Answer RRs: 5
管理机构数:00 0a
Authority RRs: 10
附加信息数:00 06
Additional RRs: 6
问题区:03777777096d6963726f736f667403636f6d0000010001
www.microsoft.com: type A, class IN
回答区:
c00c000500010000081c001a06746f67676c6503777777026d7306616b61646e73036e657400c02f0005000100000258001e03777777096d6963726f736f667405636f6d2d6307656467656b6579c044c05500050001000051b3002e03777777096d6963726f736f667405636f6d2d6307656467656b6579036e65740b676c6f62616c7265646972c03dc07f0005000100000660001306653130303838026361017304746c3838c044c0b900010001000002580004b81e489a
www.microsoft.com: type CNAME, class IN, cname toggle.www.ms.akadns.net
toggle.www.ms.akadns.net: type CNAME, class IN, cname www.microsoft.com-c.edgekey.net
www.microsoft.com-c.edgekey.net: type CNAME, class IN, cname www.microsoft.com-c.edgekey.net.globalredir.akadns.net
www.microsoft.com-c.edgekey.net.globalredir.akadns.net: type CNAME, class IN, cname e10088.ca.s.tl88.net
e10088.ca.s.tl88.net: type A, class IN, addr 184.30.72.154
管理机构区:
c0c000020001000000e70007046e396361c0c3c0c000020001000000e70007046e326361c0c3c0c000020001000000e70007046e376361c0c3c0c000020001000000e70007046e306361c0c3c0c000020001000000e70007046e366361c0c3c0c000020001000000e70007046e346361c0c3c0c000020001000000e70007046e336361c0c3c0c000020001000000e70007046e316361c0c3c0c000020001000000e70007046e386361c0c3c0c000020001000000e70007046e356361c0c3
ca.s.tl88.net: type NS, class IN, ns n9ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n2ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n7ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n0ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n6ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n4ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n3ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n1ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n8ca.s.tl88.net
ca.s.tl88.net: type NS, class IN, ns n5ca.s.tl88.net
附加信息区:
c1210001000100000e9600043d93a527c16d000100010000077c0004db4c0e14c0fb00010001000018250004af0611c6c15a00010001000003bb00043acde0f7c14700010001000001cb00047437e527c1930001000100000450000458dd51c3
n0ca.s.tl88.net: type A, class IN, addr 61.147.165.39
n1ca.s.tl88.net: type A, class IN, addr 219.76.14.20
n2ca.s.tl88.net: type A, class IN, addr 175.6.17.198
n3ca.s.tl88.net: type A, class IN, addr 58.205.224.247
n4ca.s.tl88.net: type A, class IN, addr 116.55.229.39
n5ca.s.tl88.net: type A, class IN, addr 88.221.81.195
DNS协议工作过程为:
需要解析域名时,电脑首先查找自己的缓存文件,如果没有则发送指令到本地DNS服务器进行解析,本地DNS服务器内域名和IP映射表中如果可以查询到网站IP,则可以立即访问,如果没有的话,本地DNS则会自动向根域名服务器发起查询,根域名服务器会把域名和IP映射信息发送给本地域名服务器,如果连跟域名服务器都没有该域名与IP映射信息,则会告诉本地域名服务器下一次向dns.访问域名.com发起查询,对方本地的域名服务器则会把该域名的IP信息发送到本地域名服务器
3.获取并分析http报文:
(1)访问西南大学主页swu.edu.cn的第一个http报文
474554202f20485454502f312e310d0a4163636570743a202a2f2a0d0a4163636570742d4c616e67756167653a207a682d636e0d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a557365722d4167656e743a204d6f7a696c6c612f342e302028636f6d70617469626c653b204d53494520362e303b2057696e646f7773204e5420352e313b205356313b202e4e4554342e30453b202e4e455420434c5220322e302e35303732373b202e4e455420434c5220332e302e343530362e323135323b202e4e455420434c5220332e352e33303732393b202e4e4554342e3043290d0a486f73743a207777772e7377752e6564752e636e0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a0d0a
开始行:
请求方式:47 45 54
Request Method: GET
URL:2f
Request URI: /
HTTP版本:485454502f312e31
Request Version: HTTP/1.1
首部行:
Accept: */*\r\n
Accept-Language: zh-cn\r\n
Accept-Encoding: gzip, deflate\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)\r\n
Host: www.swu.edu.cn\r\n
Connection: Keep-Alive\r\n
实体主体:无
(2)访问西南大学主页swu.edu.cn的第二个http报文
485454502f312e3120323030204f4b0d0a5365727665723a204170616368652d436f796f74652f312e310d0a5365742d436f6f6b69653a204a53455353494f4e49443d35353539383137314532323535414635344345304232313033463834393432323b20506174683d2f0d0a436f6e74656e742d547970653a20746578742f68746d6c3b636861727365743d6762323331320d0a5472616e736665722d456e636f64696e673a206368756e6b65640d0a446174653a205765642c203131204e6f7620323031352030323a35323a323820474d540d0a0d0a
开始行:
HTTP版本:485454502f312e31
Request Version: HTTP/1.1
状态码:32 30 30
Status Code: 200
解释字符串:4f 4b
Response Phrase: OK
首部行:
Server: Apache-Coyote/1.1\r\n
Set-Cookie: JSESSIONID=55598171E2255AF54CE0B2103F849422; Path=/\r\n
Content-Type: text/html;charset=gb2312\r\n
Transfer-Encoding: chunked\r\n
Date: Wed, 11 Nov 2015 02:52:28 GMT\r\n
实体主体:
Line-based text data: text/html
(3)访问西南大学主页swu.edu.cn的第三个http报文(请求css文件)
474554202f737461746963732f6373732f72657365742e63737320485454502f312e310d0a4163636570743a202a2f2a0d0a526566657265723a20687474703a2f2f7777772e7377752e6564752e636e2f0d0a4163636570742d4c616e67756167653a207a682d636e0d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a49662d4d6f6469666965642d53696e63653a2053756e2c2030372041707220323031332030393a30343a323420474d540d0a49662d4e6f6e652d4d617463683a20572f22323839372d31333635333235343634303030220d0a557365722d4167656e743a204d6f7a696c6c612f342e302028636f6d70617469626c653b204d53494520362e303b2057696e646f7773204e5420352e313b205356313b202e4e4554342e30453b202e4e455420434c5220322e302e35303732373b202e4e455420434c5220332e302e343530362e323135323b202e4e455420434c5220332e352e33303732393b202e4e4554342e3043290d0a486f73743a207777772e7377752e6564752e636e0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6f6b69653a204a53455353494f4e49443d35353539383137314532323535414635344345304232313033463834393432320d0a0d0a
开始行:
Request Method: GET
Request URI: /statics/css/reset.css
Request Version: HTTP/1.1
首部行:
Accept: */*\r\n
Referer: http://www.swu.edu.cn/\r\n
Accept-Language: zh-cn\r\n
Accept-Encoding: gzip, deflate\r\n
If-Modified-Since: Sun, 07 Apr 2013 09:04:24 GMT\r\n
If-None-Match: W/"2897-1365325464000"\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)\r\n
Host: www.swu.edu.cn\r\n
Connection: Keep-Alive\r\n
Cookie: JSESSIONID=55598171E2255AF54CE0B2103F849422\r\n
实体主体:
无
(4)访问西南大学主页swu.edu.cn的第四个http报文(css文件请求的应答)
485454502f312e3120333034204e6f74204d6f6469666965640d0a5365727665723a204170616368652d436f796f74652f312e310d0a455461673a20572f22323839372d31333635333235343634303030220d0a446174653a205765642c203131204e6f7620323031352030323a35323a333220474d540d0a0d0a
开始行:
Request Version: HTTP/1.1
Status Code: 304
Response Phrase: Not Modified
首部行:
Server: Apache-Coyote/1.1\r\n
ETag: W/"2897-1365325464000"\r\n
Date: Wed, 11 Nov 2015 02:52:32 GMT\r\n
实体主体:
无
(5)访问西南大学主页swu.edu.cn的第七个http报文(请求图片)
474554202f696d616765732f7877732e6a706720485454502f312e310d0a4163636570743a202a2f2a0d0a526566657265723a20687474703a2f2f7777772e7377752e6564752e636e2f0d0a4163636570742d4c616e67756167653a207a682d636e0d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174650d0a49662d4d6f6469666965642d53696e63653a204d6f6e2c203032204e6f7620323031352030303a30373a313520474d540d0a49662d4e6f6e652d4d617463683a20572f223134333930332d31343436343232383335303030220d0a557365722d4167656e743a204d6f7a696c6c612f342e302028636f6d70617469626c653b204d53494520362e303b2057696e646f7773204e5420352e313b205356313b202e4e4554342e30453b202e4e455420434c5220322e302e35303732373b202e4e455420434c5220332e302e343530362e323135323b202e4e455420434c5220332e352e33303732393b202e4e4554342e3043290d0a486f73743a207777772e7377752e6564752e636e0d0a436f6e6e656374696f6e3a204b6565702d416c6976650d0a436f6f6b69653a204a53455353494f4e49443d35353539383137314532323535414635344345304232313033463834393432320d0a0d0a
开始行:
Request Method: GET
Request URI: /images/xws.jpg
Request Version: HTTP/1.1
首部行:
Accept: */*\r\n
Referer: http://www.swu.edu.cn/\r\n
Accept-Language: zh-cn\r\n
Accept-Encoding: gzip, deflate\r\n
If-Modified-Since: Mon, 02 Nov 2015 00:07:15 GMT\r\n
If-None-Match: W/"143903-1446422835000"\r\n
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C)\r\n
Host: www.swu.edu.cn\r\n
Connection: Keep-Alive\r\n
Cookie: JSESSIONID=55598171E2255AF54CE0B2103F849422\r\n
实体主体:
无
(6)访问西南大学主页swu.edu.cn的第八个http报文(图片请求的应答)
485454502f312e3120333034204e6f74204d6f6469666965640d0a5365727665723a204170616368652d436f796f74652f312e310d0a455461673a20572f223134333930332d31343436343232383335303030220d0a446174653a205765642c203131204e6f7620323031352030323a35323a333320474d540d0a0d0a
开始行:
Request Version: HTTP/1.1
Status Code: 304
Response Phrase: Not Modified
首部行:
Server: Apache-Coyote/1.1\r\n
ETag: W/"143903-1446422835000"\r\n
Date: Wed, 11 Nov 2015 02:52:33 GMT\r\n
实体主体:
无
HTTP请求/响应的过程为:
(1)客户端连接到Web服务器
一个HTTP客户端,通常是浏览器,与Web服务器的HTTP端口(默认为80)建立一个TCP套接字连接。
(2)发送HTTP请求
通过TCP套接字,客户端向Web服务器发送一个文本的请求报文,一个请求报文由请求行、请求头部、空行和请求数据4部分组成。
(3)服务器接受请求并返回HTTP响应
Web服务器解析请求,定位请求资源。服务器将资源复本写到TCP套接字,由客户端读取。一个响应由状态行、响应头部、空行和响应数据4部分组成。
(4)释放连接TCP连接
Web服务器主动关闭TCP套接字,释放TCP连接;客户端被动关闭TCP套接字,释放TCP连接。
(5)客户端浏览器解析HTML内容
客户端浏览器首先解析状态行,查看表明请求是否成功的状态代码。然后解析每一个响应头,响应头告知以下为若干字节的HTML文档和文档的字符集。客户端浏览器读取响应数据HTML,根据HTML的语法对其进行格式化,并在浏览器窗口中显示。
注意,当使用浏览器访问网址同时抓取报文的方式来获取报文的话,会获取到很多不是实验所需要的报文,要注意区别开来,找到实验需要的报文。
标签:
原文地址:http://www.cnblogs.com/leftshine/p/5698890.html