Man-in-the-Middle Attack for SSH with Scala and JSch

26
Scala と JSch を使った Man-in-the-Middle Attack の実演 ~SSHを安全に使うために~ ymnk 1回東北情報セキュリティ勉強会(2009/08/01)

Transcript of Man-in-the-Middle Attack for SSH with Scala and JSch

Page 1: Man-in-the-Middle Attack for SSH with Scala and JSch

Scala と JSch を使ったMan-in-the-Middle Attack の実演

~SSHを安全に使うために~

ymnk

第1回東北情報セキュリティ勉強会(2009/08/01)

Page 2: Man-in-the-Middle Attack for SSH with Scala and JSch

自己紹介(1)

• 山中淳彦(ymnk)

• 株式会社ジェイクラフト (JCraft,Inc.)

• Java

• 最近は、Scala

• Scala勉強会@東北

• Eclipse.org の Platform Project で committer

• でも、普段は emacs でプログラムを書いてます

Page 3: Man-in-the-Middle Attack for SSH with Scala and JSch

自己紹介(2)

• ymnkの書いたソフトがBoeing 787へ搭載• http://www.jcraft.com/news/06.18.2009pr.html

Page 4: Man-in-the-Middle Attack for SSH with Scala and JSch

内容

• 自己紹介

• SSHとは

• SSH2クライアント JSch

• Man-in-the-Middle Attack

• MITM Attack の実演

• まとめ

Page 5: Man-in-the-Middle Attack for SSH with Scala and JSch

SSH とは

Page 6: Man-in-the-Middle Attack for SSH with Scala and JSch

SSHとは(1)

• Secure Shell(secsh)

• Wikipedia: “Secure Shell” から

–暗号や認証の技術を利用して、安全にリモートコンピュータと通信するためのプロトコル。パスワードなどの認証部分を含むすべてのネットワーク上の通信が暗号化される。

• リモートログイン、scp、sftp、port-fowarding

• SSH1(脆弱性や制限あり)、SSH2

SSHは、SSH社の登録商標(米国)です

Page 7: Man-in-the-Middle Attack for SSH with Scala and JSch

SSHとは(2)

• 1995年、 Tatu Yl nen ö がフリーウェアとして第一版をリリース(SSH1)

• 瞬く間に世界中にひろまる

• 同年12月、 Yl nen ö がSSH社を設立

→ソースは非公開に

• 1996年、SSH社が SSH2を設計・実装

• 1999年、有志がフリーな頃のコードを元にfork

→のちの OpenSSH

• 2000年、OpenSSH が SSH2に対応

SSHは、SSH社の登録商標(米国)です

Page 8: Man-in-the-Middle Attack for SSH with Scala and JSch

SSHとは(3)

• RFC4250: Assigned Numbers• RFC4251: Protocol Architecture• RFC4252: Authentication Protocol• RFC4253: Transport Layer Protocol• RFC4254: Connection Protocol• RFC4256: Generic Message Exchange Auth• RFC4344: Transport Layer Encryption Modes• RFC4419: DH Group Exchange for Transport Layer• RFC4462: GSSAPI Authentication and Key Exchange• RFC4335 、RFC4716、RFC4819、RFC4255• DRAFT: SSH File Transfer Protocol

SSHは、SSH社の登録商標(米国)です

Page 9: Man-in-the-Middle Attack for SSH with Scala and JSch

SSHとは(4)

接続要求

バージョン番号通知

鍵交換, 暗号化情報の交換, ホスト認証

データ通信

セッション暗号化, ユーザー認証

SSH Client SSH Server

Page 10: Man-in-the-Middle Attack for SSH with Scala and JSch

SSH2クライアント JSch

Page 11: Man-in-the-Middle Attack for SSH with Scala and JSch

SSH2クライアント JSch (1)

• JSch(Java Secure Channel)

• JCraft,Inc. 単独で開発

• SSH2のクライアント側を実装

– shell, exec, scp, sftp, port-forwarding

• J2SE(1.4以降)、J2ME CDC・CLDC(MIDP2.0)

• 修正BSDライセンス

• Eclipse(3.0以降), NetBeans(5.0以降)に同梱

• http://www.apache.org/licenses/exports/

Page 12: Man-in-the-Middle Attack for SSH with Scala and JSch

SSH2クライアント JSch (2)

• 開発開始: 2003年1月

• 関連する自製ソフトウェア

– JZlib

– JCTerm

– JCTerm Plug-in for Eclipse

– SFtp Plug-in for Eclipse

– CVS-SSH2 Plug-in for Eclipse

Page 13: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack

Page 14: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack (1)

• 中間者攻撃, bucket-bridge attack, MITM

• 暗号通信を盗聴したり介入したりする手法

• 攻撃者が犠牲者と独立した通信経路を確立

• 犠牲者間のメッセージを中継

• 犠牲者に直接対話していると思わせる

• 犠牲者の間のメッセージを横取り(盗聴)• 別のメッセージを差し挟む (改竄)• HTTPS, SSH, IPSEC, PPTP

Page 15: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack (2)

Authentication

Transport

Connection

SSH Client

Authentication

Transport

Connection

SSH Server

TCP/IPTCP/IP

Normal SSH Session

Page 16: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack (3)

Authentication

Transport

Connection

SSH Client

Authentication

Transport

Connection

TCP/IP

SSH Session with an Active Man-in-the-Middle Attack

Transport

MITM

Transport

Authentication

Connection

Authentication

Connection

TCP/IP TCP/IPTCP/IP

SSH Server

Page 17: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack (4)

LOCAL AREA NETWORK:

– ARP poisoning, DNS spoofing

– STP mangling, Port stealing

FROM LOCAL TO REMOTE (through a gateway)

– ARP poisoning, DNS spoofing, DHCP spoofing

– ICMP redirection, IRDP spoofing, route mangling

REMOTE:

– DNS poisoning, traffic tunneling, route mangling

WIRERESS:

– Access Point Reassociation

中間者になる為の手法

Page 18: Man-in-the-Middle Attack for SSH with Scala and JSch

Man-in-the-Middle Attack (5)

• Injection

• Key Manipulation

• Downgrade attack

中間者になった後の攻撃手法

Page 19: Man-in-the-Middle Attack for SSH with Scala and JSch

MITM Attack の実演

Page 20: Man-in-the-Middle Attack for SSH with Scala and JSch

MITM Attack の実演(1)

• JSchをSSHサーバーとして振舞えるように改造

• プログラムは Scala で記述• http://github.com/ymnk/man-in-the-middle-attack/tree/master• 攻撃者は中間者の位置にいることを仮定

• ホスト認証をないがしろにすると通信の盗聴、改竄が成功すること等を確認

Page 21: Man-in-the-Middle Attack for SSH with Scala and JSch

MITM Attack の実演(2)

接続要求

バージョン番号通知

データ通信

セッション暗号化, ユーザー認証

Client Server接続要求

バージョン番号通知

鍵交換, 暗号化情報の交換ホスト認証

データ通信

セッション暗号化, ユーザー認証平文

MITM

鍵交換, 暗号化情報の交換ホスト認証

Page 22: Man-in-the-Middle Attack for SSH with Scala and JSch

実演

Page 23: Man-in-the-Middle Attack for SSH with Scala and JSch

まとめ

Page 24: Man-in-the-Middle Attack for SSH with Scala and JSch

まとめ

• ホスト鍵を受け入れるときは慎重に

• パスワード認証はさける

• 公開鍵認証を使う

• SSH1プロトコルは設定で使えないようにする

Page 25: Man-in-the-Middle Attack for SSH with Scala and JSch

ありがとうございました

Page 26: Man-in-the-Middle Attack for SSH with Scala and JSch

Q&A