『ssh_scan』でリモートサーバのsshdの状態をスキャンする

調べ物中、リモートサーバのsshdの設定情報をスキャンする『ssh_scan』なるツールについて見かけたので、試してみることにした。
以下のコマンドでインストールできる。

sudo gem install ssh_scan

 

オプション等はこんな感じ。

blacknon@BS-PUB-DEVELOP:~$ sudo ssh_scan --help
ssh_scan v0.0.19 (https://github.com/mozilla/ssh_scan)
Usage: ssh_scan [options]
-t, --target [IP/Range/Hostname] IP/Ranges/Hostname to scan
-f, --file [FilePath]            File Path of the file containing IP/Range/Hostnames to scan
-T, --timeout [seconds]          Timeout per connect after which ssh_scan gives up on the host
-L, --logger [Log File Path]     Enable logger
-O, --from_json [FilePath]       File to read JSON output from
-o, --output [FilePath]          File to write JSON output to
-p, --port [PORT]                Port (Default: 22)
-P, --policy [FILE]              Custom policy file (Default: Mozilla Modern)
--threads [NUMBER]           Number of worker threads (Default: 5)
--fingerprint-db [FILE]      File location of fingerprint database (Default: ./fingerprints.db)
--suppress-update-status     Do not check for updates
-u, --unit-test [FILE]           Throw appropriate exit codes based on compliance status
-V [STD_LOGGING_LEVEL],
--verbosity
-v, --version                    Display just version info
-h, --help                       Show this message
Examples:
ssh_scan -t 192.168.1.1
ssh_scan -t server.example.com
ssh_scan -t ::1
ssh_scan -t ::1 -T 5
ssh_scan -f hosts.txt
ssh_scan -o output.json
ssh_scan -O output.json -o rescan_output.json
ssh_scan -t 192.168.1.1 -p 22222
ssh_scan -t 192.168.1.1 -p 22222 -L output.log -V INFO
ssh_scan -t 192.168.1.1 -P custom_policy.yml
ssh_scan -t 192.168.1.1 --unit-test -P custom_policy.yml
Sponsored Links

とりあえず、以下のように「-t」オプションを付与してスキャン対象のIPアドレスやホスト名を指定してコマンドを実行してやれば、sshの設定についてスキャンを実施できる。
スキャン結果は、以下のようにJSON形式で返ってくる。

sudo ssh_scan -t IPアドレス
blacknon@BS-PUB-DEVELOP:~$ sudo ssh_scan -t 172.20.XXX.XXX
[sudo] blacknon のパスワード:
I, [2017-04-21T07:50:42.069285 #31650]  INFO -- : You're using the latest version of ssh_scan 0.0.19
[
{
"ssh_scan_version": "0.0.19",
"ip": "172.20.XXX.XXX",
"port": 22,
"server_banner": "SSH-2.0-OpenSSH_6.6.1",
"ssh_version": 2.0,
"os": "unknown",
"os_cpe": "o:unknown",
"ssh_lib": "openssh",
"ssh_lib_cpe": "a:openssh:openssh:6.6.1",
"cookie": "855e7a15ae96eb8f7f2c50b2aa1ba980",
"key_algorithms": [
"curve25519-sha256@libssh.org",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group-exchange-sha1",
"diffie-hellman-group14-sha1",
"diffie-hellman-group1-sha1"
],
"server_host_key_algorithms": [
"ssh-rsa",
"ecdsa-sha2-nistp256",
"ssh-ed25519"
],
"encryption_algorithms_client_to_server": [
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"arcfour256",
"arcfour128",
"aes128-gcm@openssh.com",
"aes256-gcm@openssh.com",
"chacha20-poly1305@openssh.com",
"aes128-cbc",
"3des-cbc",
"blowfish-cbc",
"cast128-cbc",
"aes192-cbc",
"aes256-cbc",
"arcfour",
"rijndael-cbc@lysator.liu.se"
],
"encryption_algorithms_server_to_client": [
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"arcfour256",
"arcfour128",
"aes128-gcm@openssh.com",
"aes256-gcm@openssh.com",
"chacha20-poly1305@openssh.com",
"aes128-cbc",
"3des-cbc",
"blowfish-cbc",
"cast128-cbc",
"aes192-cbc",
"aes256-cbc",
"arcfour",
"rijndael-cbc@lysator.liu.se"
],
"mac_algorithms_client_to_server": [
"hmac-md5-etm@openssh.com",
"hmac-sha1-etm@openssh.com",
"umac-64-etm@openssh.com",
"umac-128-etm@openssh.com",
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-512-etm@openssh.com",
"hmac-ripemd160-etm@openssh.com",
"hmac-sha1-96-etm@openssh.com",
"hmac-md5-96-etm@openssh.com",
"hmac-md5",
"hmac-sha1",
"umac-64@openssh.com",
"umac-128@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-ripemd160",
"hmac-ripemd160@openssh.com",
"hmac-sha1-96",
"hmac-md5-96"
],
"mac_algorithms_server_to_client": [
"hmac-md5-etm@openssh.com",
"hmac-sha1-etm@openssh.com",
"umac-64-etm@openssh.com",
"umac-128-etm@openssh.com",
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-512-etm@openssh.com",
"hmac-ripemd160-etm@openssh.com",
"hmac-sha1-96-etm@openssh.com",
"hmac-md5-96-etm@openssh.com",
"hmac-md5",
"hmac-sha1",
"umac-64@openssh.com",
"umac-128@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-ripemd160",
"hmac-ripemd160@openssh.com",
"hmac-sha1-96",
"hmac-md5-96"
],
"compression_algorithms_client_to_server": [
"none",
"zlib@openssh.com"
],
"compression_algorithms_server_to_client": [
"none",
"zlib@openssh.com"
],
"languages_client_to_server": [
],
"languages_server_to_client": [
],
"hostname": "",
"auth_methods": [
"publickey",
"gssapi-keyex",
"gssapi-with-mic",
"password"
],
"fingerprints": {
"rsa": {
"known_bad": "false",
"md5": "bd:63:c3:f3:df:6e:fc:e7:cf:d9:ef:d7:92:98:a0:06",
"sha1": "4c:49:90:17:68:3a:ac:3a:55:d2:8a:66:98:7a:bc:31:76:60:20:d2",
"sha256": "21:8e:20:74:57:f9:e2:76:b7:43:69:e5:81:55:04:33:40:58:81:be:ce:04:77:b1:97:b3:7f:c5:3c:25:2d:3a"
}
},
"start_time": "2017-04-21 07:50:42 +0900",
"end_time": "2017-04-21 07:50:42 +0900",
"scan_duration_seconds": 0.192282261,
"duplicate_host_key_ips": [
],
"compliance": {
"policy": "Mozilla Modern",
"compliant": false,
"recommendations": [
"Remove these Key Exchange Algos: diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1",
"Remove these MAC Algos: hmac-md5-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64-etm@openssh.com, hmac-ripemd160-etm@openssh.com, hmac-sha1-96-etm@openssh.com, hmac-md5-96-etm@openssh.com, hmac-md5, hmac-sha1, umac-64@openssh.com, hmac-ripemd160, hmac-ripemd160@openssh.com, hmac-sha1-96, hmac-md5-96",
"Remove these Encryption Ciphers: arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, rijndael-cbc@lysator.liu.se",
"Remove these Authentication Methods: gssapi-keyex, gssapi-with-mic, password"
],
"references": [
"https://wiki.mozilla.org/Security/Guidelines/OpenSSH"
]
}
}
]

 


Written by blacknon

インフラ系のSE。一時期はプログラマ。 仮想化とオープンソースに興味あり。一日中寝てたい今日このごろ。 スペインとかで働きたいなぁ…(シエスタがあるので)

Leave a Comment

メールアドレスが公開されることはありません。

*