PowerShell 5.0 & Security

36
PowerShell 5.0 & Security Interact x Cloud Samurai 2016 Summer (2016.06.25) Kazuki Takai

Transcript of PowerShell 5.0 & Security

Page 1: PowerShell 5.0 & Security

PowerShell 5.0 & SecurityInteract x Cloud Samurai 2016 Summer (2016.06.25)

Kazuki Takai

Page 2: PowerShell 5.0 & Security

自己紹介

高井一輝 (Takai Kazuki)

某ISP勤務

クラウドサービスの開発、設計、設備維持

Windows Server / System Center / Linux / etc…

System Center User Group Japan (SCUGJ)

Twitter : @zhuky7 / Facebook : kazuki.takai

Blog : http://operationslab.wordpress.com/

2

Page 3: PowerShell 5.0 & Security

お話すること・お話しないこと

お話すること

PowerShell 5.0 おさらい

PowerShell 5.0 と Audit

JEA と PAM

Nano Server の Security と PowerShell

お話しないこと

(上記以外の)Windows Server 2016 の新機能に関する PowerShell

個々のコマンドレットの説明

Step-by-Step での構成手順

3

Page 4: PowerShell 5.0 & Security

セッションのゴール

PowerShell 5.0 の新機能について、概要がイメージできる

PowerShell のセキュリティに関連したいくつかの機能について概要を把握し、必要な際に利用を検討できる

JEAや PAMを試してみたくなる(もしくは、試したくなくなる?)

4

Page 5: PowerShell 5.0 & Security

はじめる前に

本資料の内容は個人的な検証結果に基づきます

所属する会社や組織、マイクロソフト社の公式な見解を記載するものではありません

表記や内容に誤りがあるなど、お気づきの点があれば、facebook等でご連絡いただけると幸いです

この資料では Preview 版の製品、テクノロジーについて記載しています

2016/06 時点の情報をベースにしています

今後のリリースで機能や動作が変更、削除される可能性があります

ご利用は自己責任で!!

5

Page 6: PowerShell 5.0 & Security

WMF 5.0 RTM is available !!

Windows Management Framework (WMF) 5.0 / PowerShell 5.0

2015/12/16 に RTM (KB3094174 - KB3094176)

2016/02/24 に RTM (Republishd) (KB3134758 - KB3134760)

2016/03/21 にはMicrosoft Update Catalog で配信開始

Prerequisites

.NET Framework 4.5

WMF 4.0

Incompatible

Exchange Server 2013 / 2010 SP3, Skype for Business (Lync) Server 2015 / 2013 / 2010

System Center 2012 R2 Service Management Automation

6

Page 7: PowerShell 5.0 & Security

WMF 5.1

Windows Management Framework (WMF) 5.1 / PowerShell 5.1

Windows Server 2016 の RTMに Built-inされる予定のバージョン

Windows Server 2016 と同時期にWMF としてもリリースされる予定

7

Page 8: PowerShell 5.0 & Security

既にWMF 5.0 を展開済みの方は…

おめでとうございます

WMF 5.0 がサポートするシステム(OS)はWMF 5.1 でサポートされます

WMF 5.0 の環境へ、ダイレクトにインストールできます※WMF5.0 に上書きされます(多分)

WMF 5 系のサポートは、WMF 5.1 の更新として提供される予定です

WMF 5.0 はWMF 5.1 のリリース後、4か月間のみサポートされます※critical security issuesについてのみのサポートとなります

WMF5.1 のリリース後、4か月以内にアップデートしてください!!

https://blogs.msdn.microsoft.com/powershell/2016/04/06/windows-management-framework-5-0-updates-and-wmf-5-1/

8

Page 9: PowerShell 5.0 & Security

ちなみに…

PowerShell のバージョンについては…

$PSVersionTable

PSVersion Module (PowerShell Gallery)

https://www.powershellgallery.com/packages/PSVersion/1.5

9

Page 10: PowerShell 5.0 & Security

PowerShell 5.0 の新機能

Just Enough Administration (JEA)

クラスを使用したカスタムタイプの作成

スクリプトのデバッグに関する様々な改善

Desired State Configuration (DSC)のエンハンス

監査向けの機能改善(Transcript、Logging、メッセージ暗号化)

ソフトウェア・パッケージ管理

モジュールやスクリプトの取得と管理

Information Stream, ODATA Endpoint の作成、スイッチ管理、SIL

その他、様々なコマンドレットの改善

10

Page 11: PowerShell 5.0 & Security

Transcriptの改善

PowerShell console host 外の出力も取得可能

PowerShell ISE

PowerShell コンソールから呼び出した外部コマンド

ネスト対応

メタデータ(実行時刻など)の付与

出力先のフォルダー指定が可能

グループポリシーによる設定が可能

Administrative Templates -> Windows Components -> Windows PowerShell ->

Turn on PowerShell Transcription

11

Page 12: PowerShell 5.0 & Security

Loggingの改善

スクリプトブロックのトレースログ取得が可能

グループポリシーで設定

Administrative Templates -> Windows Components -> Windows PowerShell ->

Turn on PowerShell Script Block Logging

例えば

エンコードされた文字列を、Expression として実行した場合に、デコード後の実際に実行する(Invokeされる)スクリプトブロックもロギング可能

12

Page 13: PowerShell 5.0 & Security

DemoTranscripts

Logging Script Block

13

dc01

srv01 nano01

WS2016 TP5 / AD DS

WS2016 TP5 WS2016 TP5 Nano

Page 14: PowerShell 5.0 & Security

CMSコマンドレットの追加

Cryptographic Message Syntax (CMS) cmdlets

RFC5652ベースのメッセージ暗号化、復号化が可能

頑張って .NET Object を生成して操作しなくてもよい

14

Page 15: PowerShell 5.0 & Security

Just Enough Administration (JEA)

操作 (Operation) に関する、セキュリティレベルを向上させるための機能

管理者権限を持つユーザーが多すぎるのでは?

必要十分な権限で管理を行う

PowerShell をベーステクノロジーとして利用

PowerShell Remoting

PowerShell Session Configuration / Endpoint

Command visibility & Proxy command

15

Page 16: PowerShell 5.0 & Security

JEA と PAM (JIT Admin) の違い

Just Enough Administration (JEA)

管理者が実行可能な操作、範囲を制限する

できることを制限する

Base Technology - PowerShell

Privileged Access Management (Just-in-Time Administration (JIT Admin))

管理者権限に有効期限を設定し、必要なときに(のみ)権限を付与する

できる時間を制限する

Base Technology – Active Directory + MIM 2016 ( + PowerShell )

16

Page 17: PowerShell 5.0 & Security

JEA の構成要素

Endpoint (Session Configuration)

PS Remoting の受け口

誰が接続できるのか、接続した後どのような権限で実行するのか、などを定義

実行ユーザー(の所属グループ)を定義しない場合、デフォルトでは Administrators (Domain Admins) グループのメンバーとして実行

Role Capability

Endpointに紐づけられた、具体的な役割(に応じた実行内容)

何ができるのか(何を実行してよいのか)を定義

17

Page 18: PowerShell 5.0 & Security

JEA の仕組み18

Operator

PowerShell Client

Target Server

Active Directory

Domain ServicePS Remoting

Endpoint

ACL (Permission)

RunAsUser

Role Capability

Cmdlets

External cmds

Authentication / Authorization

Page 19: PowerShell 5.0 & Security

(参考)JEA の構成

現時点 (2015/12/19 時点) では、2種類の方法が利用可能

xJEAモジュールを使用して構成

超簡単!(5分で構成可能)

Windows Server 2016 TP2 の頃から存在する方法(今後は推奨されないかも)

WorkGroup環境でも利用可能(現時点では)

RoleCapabilityと SessionConfiguration を使用して構成

xJEAモジュールを使用する方法より、若干ステップ数が多い

Windows Server 2016 TP4 (PP1) or Windows Server 2012 R2 + WMF 5.0 RTM が必要

xJEAモジュールで実現していたいくつかの機能が PowerShell Core に取り込まれたことにより、xJEAモジュールに依存せず構成可能(今後推奨となる可能性が高い)

19

TP5はこちらの方法(今後はこちら)

Page 20: PowerShell 5.0 & Security

RoleCapabilityと SessionConfiguration

による構成

Target Server をドメインに参加

PS Remoting の有効化

ACL 用のユーザー、グループを構成、(必要があれば)実行ユーザーの作成

Role Capability の記述

New-PSRoleCapabilityFile

Session Configurationの記述

New-PSSessionConfigurationFile

記述した Session Configuration を Endpoint として登録

Register-PSSessionConfiguration

20

Page 21: PowerShell 5.0 & Security

JEA Helper Tool

PowerShell ベースの GUIツール

Role Capabilityや Session Configurationを GUIで編集、登録

https://blogs.technet.microsoft.com/privatecloud/2015/12/20/introducing

-the-updated-jea-helper-tool/

21

Page 22: PowerShell 5.0 & Security

DemoJust Enough Administration

22

Page 23: PowerShell 5.0 & Security

Privileged Access Management

Privileged Access Management for Active Directory Domain Services

Just-in-Time Administration (JIT Admin)と呼ばれていたもの

操作 (Operation) に関する、セキュリティレベルを向上させるための機能

普段から(恒常的に)管理者権限を持つ必要はないのでは?

特権アクセスが可能な時間(時間範囲)を制限することで、リスクを低減する

23

Page 24: PowerShell 5.0 & Security

PAM動作イメージ

Privileged Access Management for Active Directory Domain Servicesサイトより引用

https://docs.microsoft.com/en-us/microsoft-identity-manager/pam/privileged-identity-management-for-active-directory-domain-services

24

Page 25: PowerShell 5.0 & Security

PAMの構成要素

運用ドメイン(通常・現在利用している Active Directory ドメイン)

ADDS (Domain Controller)

要塞ドメイン(PAMを管理・運用するための Active Directory ドメイン)

ADDS (Domain Controller)

PAM Service

Microsoft Identity Manager 2016

PAM Management Module

PowerShell - MIMPAM

25

Page 26: PowerShell 5.0 & Security

構成26

PRIVDC

WS2016 TP5

AD DS / DNS

CORPDC

WS2016 TP5

AD DS / DNS

PAMSRVSP

WS2012 R2SharePoint 2013

MIM 2016

CORPWKSTN

WS2016 TP5

PAMSRV

WS2016 TP5

SQL Server 2014

Domain joinDomain join

trust

contoso.localpriv.contoso.local

Page 27: PowerShell 5.0 & Security

構成手順(概要)

運用ドメインの構成

要塞ドメインの構成

MIM事前要件の構成(SQL Server, SharePoint)

MIMサービスとポータルの構成(MIM 2016)

ドメイン間の信頼関係の設定

PAM用のアカウント、グループを構成

運用ドメイン側でアカウントを構成した後、要塞ドメインへアカウントをコピー

特権取得リクエストを生成して、必要な期間のみ特権を付与

27

Page 28: PowerShell 5.0 & Security

構成手順

完全手動で構成

Configuring the MIM Environment for Privileged Access Management

https://docs.microsoft.com/en-us/microsoft-identity-manager/pam/configuring-mim-environment-for-pam

基本的には手順通り実施すれば構成可能(かなり面倒ではあるが…)

公式の手順は、WS2012 R2ベース(WS2016 TP5 の場合は若干読み替えが必要)

スクリプトを使用して構成

MIM 2016 June CTP(Microsoft Connect から取得)を使用

基本的には設定ファイルを書いてスクリプトを実行するだけ

CTPに添付のドキュメント通りには構成できないところもあるので、随時修正が必要

28

Page 29: PowerShell 5.0 & Security

試したい…でもハマりたくない!

MIM 2016 June CTP のスクリプトを使用して、以下のバージョンで構成するとハマりポイントが少ない(はず)

CORPDC – WS2016 TP5 with Desktop EN-US

Forest & Domain functional level – Windows Server 2016 TP

PRIVDC – WS2016 TP5 with Desktop EN-US

Forest & Domain functional level – Windows Server 2016 TP

PAMSVR – WS2012 R2 Full EN-US

SQL Server 2014 Enterprise EN-US

SharePoint 2013 Foundation SP1 EN-US

MIM 2016 June CTP

CORPWKSTN – Windows 8.1 Enterprise EN-US

MIM 2016 June CTP Add-ins and extensions

29

2016/06/25 時点

Page 30: PowerShell 5.0 & Security

DemoPrivileged Access

Management

30

Page 31: PowerShell 5.0 & Security

Nano Server のセキュリティ

Nano Server はフットプリントを削減、最小のサービスのみ起動

セキュリティリスク削減

Nano Server もドメイン参加可能

アカウント、認証の一元化

Nano Server には gpsvc (Group Policy Client) が無い!

グループポリシーは適用されない!!

31

Page 32: PowerShell 5.0 & Security

Nano Server のセキュリティ

Security Cmdlets in Nano Server

セキュリティポリシーおよび監査ポリシーを Nano Server上でリストア

Restore-SecurityPolicy

Restore-AuditPolicy

SecEdit.exe や AuditPol.exeでファイルを生成、または Backup-* を使用

Policy Cmdlets for Nano Server

コンピューターポリシーのインポートとエクスポートが可能

Import-GPRegistryPolicy / Export-GPRegistryPolicy

32

Page 33: PowerShell 5.0 & Security

DemoPolicy Cmdlets for

Nano Server

33

dc01

srv01 nano01

WS2016 TP5 / AD DS

WS2016 TP5 WS2016 TP5 Nano

Page 34: PowerShell 5.0 & Security

(おまけ)Package Provider

公式の Package Provider が増加

PowerShellGet

NuGet

ContainerImage

NanoServerPackage

WSAProvider

Nano Server の Package 追加やコンテナイメージ(ベースイメージ)の取得に利用可能

34

Page 35: PowerShell 5.0 & Security

まとめ

PowerShell 5.0 (5.1) ではセキュリティ関連の機能も追加

Nano Server の主たる管理方法となるなど、重要性は増大

必要なものをピックアップして試しに利用してみる

自環境に適用可能か、有効かは動かしてみないとわからない部分も多い

35

Page 36: PowerShell 5.0 & Security

参考資料

Windows Management Framework (WMF) 5.0 RTM Release Notes

Overview

https://msdn.microsoft.com/en-us/powershell/wmf/releasenotes

36