截包說明聯通劫持的工作原理。
比如請求
http://aliyun.youhuima.cc/c3pr90ntcsf0/wp-content/uploads/2015/12/500-300x218.jpg 這個地址,會被聯通強制轉到 http://120.52.72.78/
aliyun.youhuima.cc/c3pr90ntcsf0/c3pr90ntcsf0/wp-content/uploads/2015/12/500-300x218.jpg ,如下:
# curl -v
http://aliyun.youhuima.cc/c3pr90ntcsf0/wp-content/uploads/2015/12/500-300x218.jpg> GET /c3pr90ntcsf0/wp-content/uploads/2015/12/500-300x218.jpg HTTP/1.1
> User-Agent: curl/7.40.0
> Host:
aliyun.youhuima.cc> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Length: 0
< Cache-Control: no-cache
< Connection: close
< Location: http://120.52.72.78/
aliyun.youhuima.cc/c3pr90ntcsf0/c3pr90ntcsf0/wp-content/uploads/2015/12/500-300x218.jpg<
我們使用 tcpdump 抓包看一下:
$ tcpdump -i pppoe-wan -nnX port 80
16:07:10.894311 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [S], seq 2278317229, win 29040, options [mss 1452,sackOK,TS val 9058137 ecr 0,nop,wscale 4], length 0
0x0000: 4500 003c 6bf4 4000 4006 906a dddf 2b02 E..<k.@
[email protected]..+.
0x0010: 2d20 085c 9be9 0050 87cc 5cad 0000 0000 -..\...P..\.....
0x0020: a002 7170 dfa6 0000 0204 05ac 0402 080a ..qp............
0x0030: 008a 3759 0000 0000 0103 0304 ..7Y........
16:07:11.013830 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [S.], seq 3253278268, ack 2278317230, win 14480, options [mss 1460,sackOK,TS val 3300505934 ecr 9058137,nop,wscale 6], length 0
0x0000: 4500 003c 0000 4000 3506 075f 2d20 085c E..<
[email protected].._-..\
0x0010: dddf 2b02 0050 9be9 c1e9 163c 87cc 5cae ..+..P.....<..\.
0x0020: a012 3890 c23d 0000 0204 05b4 0402 080a ..8..=..........
0x0030: c4b9 b94e 008a 3759 0103 0306 ...N..7Y....
16:07:11.014093 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [.], ack 1, win 1815, options [nop,nop,TS val 9058149 ecr 3300505934], length 0
0x0000: 4500 0034 6bf5 4000 4006 9071 dddf 2b02 E..4k.@
[email protected]..+.
0x0010: 2d20 085c 9be9 0050 87cc 5cae c1e9 163d -..\...P..\....=
0x0020: 8010 0717 2276 0000 0101 080a 008a 3765 ...."v........7e
0x0030: c4b9 b94e ...N
16:07:11.014499 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [P.], seq 1:138, ack 1, win 1815, options [nop,nop,TS val 9058149 ecr 3300505934], length 137
0x0000: 4500 00bd 6bf6 4000 4006 8fe7 dddf 2b02 E...k.@.@.....+.
0x0010: 2d20 085c 9be9 0050 87cc 5cae c1e9 163d -..\...P..\....=
0x0020: 8018 0717 2966 0000 0101 080a 008a 3765 ....)f........7e
0x0030: c4b9 b94e 4745 5420 2f63 3370 7239 306e ...NGET./c3pr90n
0x0040: 7463 7366 302f 7770 2d63 6f6e 7465 6e74 tcsf0/wp-content
0x0050: 2f75 706c 6f61 6473 2f32 3031 352f 3132 /uploads/2015/12
0x0060: 2f35 3030 2d33 3030 7832 3138 2e6a 7067 /500-300x218.jpg
0x0070: 2048 5454 502f 312e 310d 0a55 7365 722d .HTTP/1.1..User-
0x0080: 4167 656e 743a 2063 7572 6c2f 372e 3430 Agent:.curl/7.40
0x0090: 2e30 0d0a 486f 7374 3a20 616c 6979 756e .0..Host:.aliyun
0x00a0: 2e79 6f75 6875 696d 612e 6363 0d0a 4163 .youhuima.cc..Ac
0x00b0: 6365 7074 3a20 2a2f 2a0d 0a0d 0a cept:.*/*....
16:07:11.116935 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [.], ack 138, win 256, length 0
0x0000: 4500 0028 118a 4000 3806 f2e8 2d20 085c E..(
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 163d 87cc 5d37 ..+..P.....=..]7
0x0020: 5010 0100 1713 0000 P.......
16:07:11.117054 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [P.], seq 1:205, ack 138, win 256, length 204
0x0000: 4500 00f4 118b 4000 3806 f21b 2d20 085c
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 163d 87cc 5d37 ..+..P.....=..]7
0x0020: 5018 0100 7f43 0000 4854 5450 2f31 2e31 P....C..HTTP/1.1
0x0030: 2033 3032 2046 6f75 6e64 0d0a 436f 6e74 .302.Found..Cont
0x0040: 656e 742d 4c65 6e67 7468 3a20 300d 0a43 ent-Length:.0..C
0x0050: 6163 6865 2d43 6f6e 7472 6f6c 3a20 6e6f ache-Control:.no
0x0060: 2d63 6163 6865 0d0a 436f 6e6e 6563 7469 -cache..Connecti
0x0070: 6f6e 3a20 636c 6f73 650d 0a4c 6f63 6174 on:.close..Locat
0x0080: 696f 6e3a 2068 7474 703a 2f2f 3132 302e ion:.http://120.
0x0090: 3532 2e37 322e 3738 2f61 6c69 7975 6e2e 52.72.78/aliyun.
0x00a0: 796f 7568 7569 6d61 2e63 632f 6333 7072
youhuima.cc/c3pr 0x00b0: 3930 6e74 6373 6630 2f63 3370 7239 306e 90ntcsf0/c3pr90n
0x00c0: 7463 7366 302f 7770 2d63 6f6e 7465 6e74 tcsf0/wp-content
0x00d0: 2f75 706c 6f61 6473 2f32 3031 352f 3132 /uploads/2015/12
0x00e0: 2f35 3030 2d33 3030 7832 3138 2e6a 7067 /500-300x218.jpg
0x00f0: 0d0a 0d0a ....
16:07:11.117185 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [.], ack 205, win 1882, options [nop,nop,TS val 9058159 ecr 3300505934], length 0
0x0000: 4500 0034 6bf7 4000 4006 906f dddf 2b02 E..4k.@
[email protected]..+.
0x0010: 2d20 085c 9be9 0050 87cc 5d37 c1e9 1709 -..\...P..]7....
0x0020: 8010 075a 20d4 0000 0101 080a 008a 376f ...Z..........7o
0x0030: c4b9 b94e ...N
16:07:11.117234 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [F.], seq 205, ack 138, win 256, length 0
0x0000: 4500 0028 118c 4000 3806 f2e6 2d20 085c E..(
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 1709 87cc 5d37 ..+..P........]7
0x0020: 5011 0100 1646 0000 P....F..
16:07:11.123536 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [F.], seq 138, ack 206, win 1882, options [nop,nop,TS val 9058160 ecr 3300505934], length 0
0x0000: 4500 0034 6bf8 4000 4006 906e dddf 2b02 E..4k.@
[email protected]..+.
0x0010: 2d20 085c 9be9 0050 87cc 5d37 c1e9 170a -..\...P..]7....
0x0020: 8011 075a 20d1 0000 0101 080a 008a 3770 ...Z..........7p
0x0030: c4b9 b94e ...N
16:07:11.134815 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [.], ack 138, win 243, options [nop,nop,TS val 3300506053 ecr 9058149], length 0
0x0000: 4500 0034 aff8 4000 3506 576e 2d20 085c
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 163d 87cc 5d37 ..+..P.....=..]7
0x0020: 8010 00f3 279a 0000 0101 080a c4b9 b9c5 ....'...........
0x0030: 008a 3765 ..7e
16:07:11.135011 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [.], ack 206, win 1882, options [nop,nop,TS val 9058161 ecr 3300505934], length 0
0x0000: 4500 0034 6bf9 4000 4006 906d dddf 2b02 E..4k.@
[email protected]..+.
0x0010: 2d20 085c 9be9 0050 87cc 5d38 c1e9 170a -..\...P..]8....
0x0020: 8010 075a 20d0 0000 0101 080a 008a 3771 ...Z..........7q
0x0030: c4b9 b94e ...N
16:07:11.135065 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [P.], seq 1:311, ack 138, win 243, options [nop,nop,TS val 3300506053 ecr 9058149], length 310
0x0000: 4500 016a aff9 4000 3506 5637 2d20 085c
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 163d 87cc 5d37 ..+..P.....=..]7
0x0020: 8018 00f3 d075 0000 0101 080a c4b9 b9c5 .....u..........
0x0030: 008a 3765 4854 5450 2f31 2e31 2034 3034 ..7eHTTP/1.1.404
0x0040: 204e 6f74 2046 6f75 6e64 0d0a 5365 7276 .Not.Found..Serv
0x0050: 6572 3a20 6e67 696e 780d 0a44 6174 653a er:.nginx..Date:
0x0060: 204d 6f6e 2c20 3138 204a 616e 2032 3031 .Mon,.18.Jan.201
0x0070: 3620 3038 3a30 373a 3131 2047 4d54 0d0a 6.08:07:11.GMT..
0x0080: 436f 6e74 656e 742d 5479 7065 3a20 7465 Content-Type:.te
0x0090: 7874 2f68 746d 6c0d 0a43 6f6e 7465 6e74 xt/html..Content
0x00a0: 2d4c 656e 6774 683a 2031 3632 0d0a 436f -Length:.162..Co
0x00b0: 6e6e 6563 7469 6f6e 3a20 6b65 6570 2d61 nnection:.keep-a
0x00c0: 6c69 7665 0d0a 0d0a 3c68 746d 6c3e 0d0a live....<html>..
0x00d0: 3c68 6561 643e 3c74 6974 6c65 3e34 3034 <head><title>404
0x00e0: 204e 6f74 2046 6f75 6e64 3c2f 7469 746c .Not.Found</titl
0x00f0: 653e 3c2f 6865 6164 3e0d 0a3c 626f 6479 e></head>..<body
0x0100: 2062 6763 6f6c 6f72 3d22 7768 6974 6522 .bgcolor="white"
0x0110: 3e0d 0a3c 6365 6e74 6572 3e3c 6831 3e34 >..<center><h1>4
0x0120: 3034 204e 6f74 2046 6f75 6e64 3c2f 6831 04.Not.Found</h1
0x0130: 3e3c 2f63 656e 7465 723e 0d0a 3c68 723e ></center>..<hr>
0x0140: 3c63 656e 7465 723e 6e67 696e 783c 2f63 <center>nginx</c
0x0150: 656e 7465 723e 0d0a 3c2f 626f 6479 3e0d enter>..</body>.
0x0160: 0a3c 2f68 746d 6c3e 0d0a .</html>..
16:07:11.135211 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [R], seq 2278317367, win 0, length 0
0x0000: 4500 0028 857d 4000 4006 76f5 dddf 2b02 E..(.}@
[email protected]...+.
0x0010: 2d20 085c 9be9 0050 87cc 5d37 0000 0000 -..\...P..]7....
0x0020: 5004 0000 f045 0000 P....E..
16:07:11.248505 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [F.], seq 311, ack 139, win 243, options [nop,nop,TS val 3300506166 ecr 9058160], length 0
0x0000: 4500 0034 affa 4000 3506 576c 2d20 085c
[email protected]..\
0x0010: dddf 2b02 0050 9be9 c1e9 1773 87cc 5d38 ..+..P.....s..]8
0x0020: 8011 00f3 25e6 0000 0101 080a c4b9 ba36 ....%..........6
0x0030: 008a 3770 ..7p
16:07:11.248700 IP 221.223.X.X.39913 > 45.32.8.92.80: Flags [R], seq 2278317368, win 0, length 0
0x0000: 4500 0028 8583 4000 4006 76ef dddf 2b02 E..(..@
[email protected]...+.
0x0010: 2d20 085c 9be9 0050 87cc 5d38 0000 0000 -..\...P..]8....
0x0020: 5004 0000 f044 0000 P....D..
^C
1264 packets captured
1264 packets received by filter
0 packets dropped by kernel
可以發現聯通的服務器搶答了數據包。上述 `16:07:11.117054 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [P.], seq 1:205, ack 138, win 256, length 204`是偽造的,而`16:07:11.135065 IP 45.32.8.92.80 > 221.223.X.X.39913: Flags [P.], seq 1:311, ack 138, win 243, options [nop,nop,TS val 3300506053 ecr 9058149], length 310`才是真正從服務器返回的數據包。
我已將 10 進制的 IP 隱去,有人之人依然可以通過計算十六進制得到我的真實 IP 。