0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Kali Linux2022.1 でハッキングラボをつくってみる7 Metasploitable2をハッキングする おまけ HackerJapanのやられOSを攻撃する

Posted at

はじめに

以前、Metasloitable2へのハッキングの検証・学習してきた。同OSはあえて脆弱にしてあるLinuxディストロなので、同じような「やられOS」なら、学んだ手法を応用できるのではないだろうか?
というわけで、雑誌HackerJapan2013年5月号に掲載されているやられサーバーへのハッキングを行ってみる。

HackerJapanはすでに休刊しており、附属DVDで用意されているOSも古いものが多い。しかも、原因がよくわからないが、用意されている3つのやられOS(ちなみに、サーバー用OS)は、1番目のものがnmap -sn xxx.xxx.xxx.xxxで認識しなかった。(pingを返さない設定?)なので、2番目と3番目に対してのみ、ハッキングを行う。

注意事項
記事で紹介されている行為を他人や団体、インフラなどの許可を得ずに行った場合、犯罪となる可能性が有ります。
あくまでも、記事の内容は情報セキュリティの学習です。読者様の所有・管理の機器、システムでのみ実行してください。
また、読者さまのシステムにトラブルが起きたとしても、私は責任を負いかねます。

1番目のやられOSのハッキング

前述の通り、やってません。

2番目のやられOSのハッキング

ルート権限奪取を目標とする。

pingによりIPアドレス特定

基本的に、ハッキングは同誌の手法に沿って進める。

まずは、それぞれのIPアドレスを調べないことには、話が始まらない。
KaliLinuxのものはifconfigip addrで調べられる。
やられOSのものはnmap -sn 192.168.56.0/24コマンドで、ネットワーク全体のホストへのpingスキャンをすることで、おおよそ絞りをつけることができる。
結果

OS ローカルIPアドレス
KaliLinux 192.168.56.2
やられOS 192.168.56.64

ネットワークはホストオンリーアダプタ。やられOSのIPアドレスは,DHCPで割り当てられた。

ポートスキャン

TCPスキャン

sudo nmap -sS -p- 192.168.56.63

結果

Nmap scan report for 192.168.56.57
Host is up (0.000067s latency).
Not shown: 65530 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
111/tcp open rpcbind
113/tcp open ident
39428/tcp open unknown

80/tcpが開いているので、Firefoxで"http://192.168.56.57.victim.html"とアクセスすると、入力フォームに行き着いた。
画像

UDPスキャン
時間がかかる。

sudo nmap -v -sU -p 0-1024 192.168.56.57

あまりにもかかるため、-vで進捗状況を表示するようにして、0から1024に検査するポート数を絞った。
結果

Nmap scan report for 192.168.56.57
Host is up (0.00095s latency).
Not shown: 1020 closed udp ports (port-unreach)
PORT STATE SERVICE
53/udp open domain
68/udp open|filtered dhcpc
111/udp open rpcbind
612/udp open|filtered hmmp-ind
631/udp open|filtered ipp

包括的なスキャン
-Aオプションを使うことで、逆引きDNS名、OSの推測、デバイスの種類、MACアドレスなどの、調査対象に関するさらに詳細な情報を探索できる。

sudo nmap -A 192.168.56.57

結果

Nmap scan report for 192.168.56.57
Host is up (0.00022s latency).
Not shown: 995 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.3p2 Debian 9etch2 (protocol 2.0)
|auth-owners: root
| ssh-hostkey:
| 1024 d5:b6:19:cb:29:82:b5:3a:2b:0c:34:fb:fc:1d:e0:a8 (DSA)
|
2048 3b:8f:11:7b:8f:7b:c2:24:e5:0f:a7:51:37:aa:b9:30 (RSA)
53/tcp open domain ISC BIND 8.4.7-REL-NOESW
|auth-owners: root
| dns-nsid:
|
bind.version: 8.4.7-REL-NOESW
80/tcp open http Apache httpd 2.2.3 ((Debian) mod_python/3.2.10 Python/2.4.4 PHP/5.2.0-8+etch11 mod_perl/2.0.2 Perl/v5.8.8)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
|_http-server-header: Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4 PHP/5.2.0-8+etch11 mod_perl/2.0.2 Perl/v5.8.8
111/tcp open rpcbind 2 (RPC #100000)
|auth-owners: daemon
| rpcinfo:
| program version port/proto service
| 100000 2 111/tcp rpcbind
| 100000 2 111/udp rpcbind
| 100024 1 32772/udp status
|
100024 1 39428/tcp status
113/tcp open ident
|_auth-owners: identd
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

sshやhttpをメインに攻撃を仕掛ければ良いのか?

謎のMessage Form

httpが開いているから、ブラウザから"http://192.168.56.63"へアクセスする。
message.png

message2.png

同誌によれば、htmlをhtmに書き換えると、apacheサーバーのバージョンが確認できるとのこと。

message_error.png

exploit-dbで"apache 2.2.3"で調べてみると、TAKESHI TERADAという人物が作ったexploitがひっかかる。同誌の記事の執筆者か?
exploitをダウンロードして、書いてあることを試行錯誤するも、うまく行かず・・・。別の方法を試す。

sshから攻める

exploit-dbで、OpenSSH 4.3p2に対しての良さげなexploitは見つからなかった。
適当なユーザ名でやられサーバーのsshにアクセスする。実際、同誌では、この方法でうまくいっている。(たまたまだが)
kaliLinuxでssh -l root 192.168.56.63を実行すると、

Unable to negotiate with 192.168.56.63 port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

Unable to negotiate with 192.168.56.63 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

というエラーが出た。やられOSで利用しているsshの鍵アルゴリズムが古いために起きるらしい。
ファイル"~/.ssh/config"を作成した後、次の内容を記述することで解決できた。

~/.ssh/config
Host 192.168.56.*
KexAlgorithms +diffie-hellman-group-exchange-sha1
KexAlgorithms +diffie-hellman-group14-sha1
KexAlgorithms +diffie-hellman-group1-sha1

HostKeyAlgorithms ssh-dss,ssh-rsa

確かに、ユーザー名:root、パスワード:rootでログインできた。
sshlogin1.png

hydraで、辞書攻撃も行ってみた。
hydra -L user.lst -P pass.lst -t 4 192.168.56.63 ssh
→root,rootのペアがヒット。
hydra -L rockyou.txt -P rockyou.txt -t 4 192.168.56.63 ssh
rockyouを使っての辞書攻撃は、非常に時間がかかるので、10分メドにして途中終了。
→何もヒットしなかった。

他、シェルコマンドインジェクションやオーバーフローを用いた攻略法が掲載されている。自身の未熟な手腕だと、sshに向けて辞書攻撃なり、ブルートフォースしていく方法があっている。(というよりも、それしかまだ理解できない・・・。)

3番目のやられOSのハッキング

ルート権限奪取を目標とする。

ポートスキャン

  • sudo nmap -sn 192.168.56.0/24
    192.168.56.61というホストが見つかった。
  • sudo nmap -sS -p- 192.168.56.61
    結果は以下の通り

PORT STATE SERVICE
199/tcp open smux
55555/tcp open unknown

  • sudo nmap -sU -v -p0-1024 192.168.56.61
    結果は以下の通り

PORT STATE SERVICE
68/udp open|filtered dhcpc
161/udp open snmp

  • sudo nmap -A 192.168.56.61
    結果は以下の通り

Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
199/tcp open smux Linux SNMP multiplexer
55555/tcp open ssh OpenSSH 4.2p1 Debian 7ubuntu3.5 (protocol 2.0)
| ssh-hostkey:
|_ 2048 fe:52:fd:f6:a9: ab :94:c7:23:57:fc:cb:21:4c:b0:09 (RSA)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

sshとsnmpを攻めれば良さそうなことがわかる。

sshから攻める

ssh -l root 192.168.56.61
適当なパスワードを入れてみたが、ダメだった。
hydra -L user.lst -P pass.lst -t 4 192.168.56.61 ssh -s 55555
hydra -L ./Desktop/sf_shareDir/rockyou.txt -P ./Desktop/sf_shareDir/rockyou.txt -t 4 192.168.56.61 ssh -s 55555
ダメだった。
Exploit-dbで、OpenSSH 4.2p1の脆弱性を突くExploitを調べたが、何も見つからなかった。

snmpから攻める

同誌にあるとおり、snmpの出力情報から何か手探りを探ってみる。
snmpwalk 192.168.56.61 -v 1 -c public . | less
snmpwalk 192.168.56.61 -v 1 -c private . | less
"user"というワードで調べてみると、ユーザー一覧らしきものを発見。
snmpuser.png

ユーザー一覧とやられOSに事前に設定したパスワードをuser.lstとpass.lstに追記して、hydraでの辞書攻撃sshへの攻撃を試してみる。
・・・と思ったら、やられOSがホストオンリーネットワークに接続しなくなった。原因は不明。
残念ながら、ここで終了。

おわりに

なかなか独自の手法で攻略するのは難しい。
参考にしたもの
「Hacker Japan2013年5月号」
「ハッキング・ラボのつくりかた」

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?