Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Powershell のセキュリティ (大都会ver)

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Powershell のセキュリティ (大都会ver)

Powershell のセキュリティ

Avatar for tsuda.a

tsuda.a

May 16, 2015
Tweet

More Decks by tsuda.a

Other Decks in Programming

Transcript

  1. 簡単に言うと • 個人PCのセキュリティが厳しくなりました。 • Windows 7 で UAC で縛り。 しかし

    Admin 権限がないので、解除できず。 • UAC を操作するには上司の立ち合いが必要。 • IDE とか入れられないのでプログラム組めない。 • ファイルのコピーすら満足に自動化できんじゃん? • そうだ、Windows なら Powershell があるんじゃね? という流れだった気がする。
  2. たとえばこんなスクリプトファイルがある $a = $args[0] Get-Process | ? { $_.CPU -ge

    $a } | select Cpu, ProcessName, MainWindowTitle, Path | sort cpu -Descending | ogv getHeavtProcess.ps1 ここがコマンドラインパラメーター
  3. バッチファイルでやっていること。 Powershell ① -command ② " $a=gc -raw %1; ③

    $a='{'+$a+'}'; ④ $b=Invoke-Expression $a;⑤ $b.Invoke(%2); ⑥ pause; ⑦ " ①Powershellを起動する ②-command オプションで Scriptを 渡す。 ③第一引数に指定したファイルをテ キストで読み込む。 ④スクリプトブロックにするので { } で囲む。 ⑤文字列をスクリプトブロックとし て評価する。 ⑥スクリプトブロックの実行。 %2 をパラメーターとして渡す。 ⑦確認待ち。
  4. 結果、生成・実行される Powershell Script $a='{$a = $args[0] Get-Process | ? {

    $_.CPU -ge $a } | select Cpu, ProcessName, MainWindowTitle, Path | sort cpu -Descending | ogv}'; $b=Invoke-Expression $a; $b.Invoke(10); pause; いわゆる eval