2013年3月23日土曜日

Network Forensics #2 Puzzle 4 解説

手早く問題を解く場合は、 NetworkMiner を使う。ただし、2 については NetworkMiner で解くのは難しい。

1. X 氏のスキャナーのIPアドレスはなんですか?

予想として、キャプチャしたデータの中で一番出現率が高いのがスキャナーの IP アドレスのはずと仮説を立てて、Wireshark の機能を使って推測する。
Wireshark のツールバーから statistics -> IP address を選択。


IP を指定するポップアップが出てくるが、何も指定せずに Create start を押すと下記のように統計データを出してくれる。


通信の約半分に 10.42.42.253 が関係しているため、これがスキャナーの送信元と推測できる。
答えも 10.42.42.253 となる。

2. X 氏が行った最初のポートスキャンはどのタイプですか?

まず問題文に示されているポートスキャンタイプの復習。nmap の解説サイトが詳しい。

  • TCP SYN
    • SYN だけ送って、open していたらすぐに RST を返す。ハーフオープンスキャンとも呼ばれる。 セッションを確立しないためログに残りづらく比較的秘匿性がある。
  • TCP ACK
    •  ファイアウォールのルールを確認するために使用される。いきなり ACK を送ると通常のサーバは RST を返すが、ファイアウォールがある場合は何も返さない。そのため応答がないポートはファイアウォールでフィルタされていると判断できる。
  • UDP
    • UDP パケットを使ったスキャン
  • TCP Connect
    •  connect() を使用してスキャンする。セッションが確立するのでログには残るが、通信自体は正常なものなので、SYN スキャンなどを防御するIPSでも通過する可能性が高い。
  • TCP XMAS
    • FIN、PSH、URG のフラグをすべて設定したパケットを送信する、クリスマスツリースキャン。 最大の利点は、特定のステートレスなファイアウォールやパケットフィルタリング・ルータをすり抜けることができる点であるが最近のものだと特定される場合がある。
  • TCP RST
    • RST フラグを使用したスキャン。
これらのフラグの状態は wireshark の tcp.flags でフィルタができる。主なフラグは下記のとおり。

  • SYN flags : tcp.flags == 0x02
  • RST flags : tcp.flags == 0x04
  • ACK flags : tcp.flags == 0x10
  • FIN/ACK flags : tcp.flags == 0x11
  • SYN/ACK flags : tcp.flags == 0x12
  • RST/ACK flags : tcp.flags == 0x14
  • PSH/ACK flags : tcp.flags == 0x18
  • XMAS flags : tcp.flags == 0x31 (間違い)
  • XMAS flags : tcp.flags == 0x29

まずはSYNスキャンを見てみる。フィルタは tcp.flags == 0x02 で指定できる。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x02" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -r evidence04.pcap | more

Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)      10.42.42.253    10.42.42.50     80      0x0002
Frame 3: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)      10.42.42.253    10.42.42.56     80      0x0002
Frame 4: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)      10.42.42.253    10.42.42.25     80      0x0002
Frame 7: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)      10.42.42.253    10.42.42.50     554     0x0002
Frame 8: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)      10.42.42.253    10.42.42.56     554     0x0002
Frame 10: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)     10.42.42.253    10.42.42.25     554     0x0002

wc -l で確認すると7414行あったため、SYNスキャンの可能性はある。ただし、スキャン対象のポートが閉じていてもこの状態になるためこの時点ではまだ確定できない。

次に ACK スキャンを確認する。フィルタは tcp.flags == 0x10 で指定できる。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x10" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -r evidence04.pcap | more

Frame 791: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)    10.42.42.253    10.42.42.50     139     0x0010
Frame 4389: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)   10.42.42.253    10.42.42.50     135     0x0010
Frame 13531: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010
Frame 13532: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     139     0x0010
Frame 13543: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010
Frame 13547: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010
Frame 13593: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010
Frame 13594: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.25     1       0x0010
Frame 13606: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     135     0x0010
Frame 13610: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     1       0x0010
Frame 13622: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010

全部でこれだけ。11行のみ。
ポートスキャンにしてはログが少なすぎるため、可能性が非常に低いと考えられる。

続いて、UDPをカウントしてみる。フィルタは単純に udp を指定するだけ。

tshark -R "ip.src == 10.42.42.253 && udp" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -r evidence04.pcap 

Frame 13580: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits)      10.42.42.253    10.42.42.56
Frame 13581: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits)      10.42.42.253    10.42.42.25
Frame 13582: 370 bytes on wire (2960 bits), 370 bytes captured (2960 bits)      10.42.42.56,10.42.42.253        10.42.42.253,10.42.42.56
Frame 13583: 70 bytes on wire (560 bits), 70 bytes captured (560 bits)  10.42.42.25,10.42.42.253        10.42.42.253,10.42.42.25
Frame 13584: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits)      10.42.42.253    10.42.42.50
Frame 13585: 190 bytes on wire (1520 bits), 190 bytes captured (1520 bits)      10.42.42.50,10.42.42.253        10.42.42.253,10.42.42.50
Frame 13618: 342 bytes on wire (2736 bits), 342 bytes captured (2736 bits)      10.42.42.253    10.42.42.56
Frame 13619: 370 bytes on wire (2960 bits), 370 bytes captured (2960 bits)      10.42.42.56,10.42.42.253        10.42.42.253,10.42.42.56

上記8行のみのため、こちらも可能性は低いと考えられる。

次は TCP connect で tcp.flags == 0x10 と -e tcp.stream でフィルタする。0x10 は ACK のため単体では ACK スキャンの結果と同じになる。tcp.stream をつけることで 3way handshake が行われたかを確認できる。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x10" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -e tcp.stream -r evidence04.pcap | more

Frame 791: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)    10.42.42.253    10.42.42.50     139     0x0010  390
Frame 4389: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)   10.42.42.253    10.42.42.50     135     0x0010  2235
Frame 13531: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7413
Frame 13532: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     139     0x0010  7414
Frame 13543: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7415
Frame 13547: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7415
Frame 13593: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010  7425
Frame 13594: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.25     1       0x0010  7426
Frame 13606: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     135     0x0010  7431
Frame 13610: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     1       0x0010  7433
Frame 13622: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010  7425

結果は上記11行となる。この結果は ACK スキャンと同じ。ということは ACK スキャンのパケットはすべて connect していることになり、この時点で ACK スキャンは行われていなかったという結論になる。
上記の結果を眺めると、ポート139と135に対して connect できているように見える。また通常はスキャンを実行した後にオープンしているポートを調査するため、最初のストリーム番号 390 と 2235 あたりがスキャンの実行ログと考えられる。その二つを詳しく確認する。

for i in 390 2235; do tshark -R "tcp.stream eq $i" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -e tcp.stream -r evidence04.pcap; done

Frame 779: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)    10.42.42.253    10.42.42.50     139     0x0002  390
Frame 786: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)    10.42.42.50     10.42.42.253    56257   0x0012  390
Frame 791: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)    10.42.42.253    10.42.42.50     139     0x0010  390
Frame 821: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)    10.42.42.253    10.42.42.50     139     0x0014  390

Frame 4381: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)   10.42.42.253    10.42.42.50     135     0x0002  2235
Frame 4383: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)   10.42.42.50     10.42.42.253    42214   0x0012  2235
Frame 4389: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)   10.42.42.253    10.42.42.50     135     0x0010  2235
Frame 4394: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)   10.42.42.253    10.42.42.50     135     0x0014  2235

二つの通信ともに syn -> syn/ack -> ack と 3way になっており、普通ならここからデータ通信が始まるが、この二つはいきなり 0x14 RSR/ACK で終わっている。この状況から connect スキャンの可能性がかなり高くなる。

次に XMAS を調べる。こちらは tcp.flags ==0x29 でフィルタできる。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x29" -Tfields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -r evidence04.pcap                                           
                                      
Frame 13599: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1    0x0029
Frame 13600: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.25     1    0x0029
Frame 13612: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     1    0x0029
Frame 13624: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1    0x0029


結果は4件となる。スキャンとして使った可能性は高いが、パケット数が少ないため最初に実施する広範囲のスキャンとは考えづらい。

最後に RST スキャンを調べてみる。RST フラグは 0x04 でフィルタできる。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x04" -Tfields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -r evidence04.pcap

Frame 6978: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)   10.42.42.253    10.42.42.50     139     0x0004
Frame 8763: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)   10.42.42.253    10.42.42.50     135     0x0004
Frame 13552: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13555: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13558: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13561: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13564: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13567: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13592: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004
Frame 13605: 60 bytes on wire (480 bits), 60 bytes captured (480 bits)  10.42.42.253    10.42.42.50     135     0x0004

11個のパケットが出てきたが、スキャンとしてはホストが固定されている、ポートも固定されていることからスキャン後の調査の可能性が高いと考えられる。

結論として、TCP connect スキャンが実施され、クローズているポートへのスキャンが syn パケットとして大量に検知され、135 と 139 を検出したと推測できる。
答えは TCP connect となる。

3. X 氏はどんなIPアドレスを見つけましたか?

1 の結果から下記のアドレスを発見している。
  • 10.42.42.50
  • 10.42.42.56
  • 10.42.42.25

4. 彼が見つけたApple製品の MAC アドレスはなんですか?

3のアドレスを送信元とするパケットを検索して MAC アドレスを確認する。
  • 10.42.42.50 Address: CompalIn_51:d7:b2 (70:5a:b6:51:d7:b2)
  • 10.42.42.56 Address: CompalIn_cb:1e:79 (00:26:22:cb:1e:79)
  • 10.42.42.25 Address: AppleCom_92:6e:dc (00:16:cb:92:6e:dc)

5. 彼が見つけたWindowsのIPアドレスはなんですか?

スキャンの結果見つかった IP アドレスで OS が不明なのは
  • 10.42.42.50
  • 10.42.42.56
の二つ。
これらの OS を特定するために p0f の -A オプションと -R オプションを使う。 -A は SYN + ACK の OS による特性を調べるオプションで、-R は RST の特性を調べるが若干不安定とのこと。そのため複数のオプションを使い OS を推測する。

まずは -A オプションの結果。

p0f -A -l -s evidence04.pcap | grep "10.42.42.50:" | more
p0f - passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski , W. Stearns 
p0f: listening (SYN+ACK) on 'evidence04.pcap', 61 sigs (1 generic, cksum B253FA88), rule: 'all'.
[+] End of input file.
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.253:56257 (distance 0, link: ethernet/modem)
10.42.42.50:135 - Windows 2000 SP4 -> 10.42.42.253:42214 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49260 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49261 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49262 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49263 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49264 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 SP4 -> 10.42.42.25:49265 (distance 0, link: ethernet/modem)
10.42.42.50:139 - Windows 2000 (1) -> 10.42.42.253:36020 (distance 0, link: ethernet/modem)
10.42.42.50:135 - Windows 2000 (1) -> 10.42.42.253:36020 (distance 0, link: ethernet/modem)

p0f -A -l -s evidence04.pcap | grep "10.42.42.56:" | more
p0f - passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski , W. Stearns 
p0f: listening (SYN+ACK) on 'evidence04.pcap', 61 sigs (1 generic, cksum B253FA88), rule: 'all'.
[+] End of input file.

次は -R の結果。

p0f -R -l -s evidence04.pcap | grep "10.42.42.50:" | more
p0f - passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski , W. Stearns 
p0f: listening (RST+) on 'evidence04.pcap', 46 sigs (3 generic, cksum 1AE3081F), rule: 'all'.
10.42.42.50:80 - Windows XP/2000 (refused) -> 10.42.42.253:46104 (distance 0, link: unspecified)
10.42.42.50:554 - Windows XP/2000 (refused) -> 10.42.42.253:38232 (distance 0, link: unspecified)
10.42.42.50:389 - Windows XP/2000 (refused) -> 10.42.42.253:35168 (distance 0, link: unspecified)
10.42.42.50:256 - Windows XP/2000 (refused) -> 10.42.42.253:37066 (distance 0, link: unspecified)
10.42.42.50:23 - Windows XP/2000 (refused) -> 10.42.42.253:39682 (distance 0, link: unspecified)

p0f -R -l -s evidence04.pcap | grep "10.42.42.56:" | more
p0f - passive os fingerprinting utility, version 2.0.8
(C) M. Zalewski , W. Stearns 
p0f: listening (RST+) on 'evidence04.pcap', 46 sigs (3 generic, cksum 1AE3081F), rule: 'all'.
10.42.42.56:80 - Linux recent 2.4 (refused) -> 10.42.42.253:59856 (distance 0, link: unspecified)
10.42.42.56:554 - Linux recent 2.4 (refused) -> 10.42.42.253:43771 (distance 0, link: unspecified)
10.42.42.56:389 - Linux recent 2.4 (refused) -> 10.42.42.253:43514 (distance 0, link: unspecified)
10.42.42.56:256 - Linux recent 2.4 (refused) -> 10.42.42.253:33239 (distance 0, link: unspecified)
10.42.42.56:23 - Linux recent 2.4 (refused) -> 10.42.42.253:60559 (distance 0, link: unspecified)
10.42.42.56:80 - Linux recent 2.4 (refused) -> 10.42.42.253:59941 (distance 0, link: unspecified)
10.42.42.56:22 - Linux recent 2.4 (refused) -> 10.42.42.253:50953 (distance 0, link: unspecified)

上記の結果から 10.42.42.50 が Windows と推測できる。
また 10.42.42.50 はポートスキャンの結果から 135 と 139 のポートがオープンになっているため、Windows と考えられる。
また、TTL の値が Windows なら 128 で Linux なら 64 が一般的。今回は同一サブネットなので、TTL も判断材料として使える。

答えは 10.42.42.50 となる。

6. Windows システムで使用可能なTCPポートはなんですか?

10.42.42.50 のポートスキャンで TCP connect となっているものが答え。

tshark -R "ip.src == 10.42.42.253 && tcp.flags == 0x10" -T fields -e frame -e ip.src -e ip.dst -e tcp.dstport -e tcp.flags -e tcp.stream -r evidence04.pcap

Frame 791: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)    10.42.42.253    10.42.42.50     139     0x0010  390
Frame 4389: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)   10.42.42.253    10.42.42.50     135     0x0010  2235
Frame 13531: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7413
Frame 13532: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     139     0x0010  7414
Frame 13543: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7415
Frame 13547: 66 bytes on wire (528 bits), 66 bytes captured (528 bits)  10.42.42.253    10.42.42.50     135     0x0010  7415
Frame 13593: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010  7425
Frame 13594: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.25     1       0x0010  7426
Frame 13606: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     135     0x0010  7431
Frame 13610: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.50     1       0x0010  7433
Frame 13622: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)  10.42.42.253    10.42.42.56     1       0x0010  7425

答えは 135 と 139 となる。

0 件のコメント:

コメントを投稿