Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Powershell のセキュリティ (大都会ver)
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tsuda.a
May 16, 2015
Programming
0
54
Powershell のセキュリティ (大都会ver)
Powershell のセキュリティ
tsuda.a
May 16, 2015
Tweet
Share
More Decks by tsuda.a
See All by tsuda.a
マジカルインクリメントと指数表記
tsudaahr
0
220
バックアップしていますか?
tsudaahr
0
130
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
140
NPUわからん
tsudaahr
0
190
計算量オーダーの話
tsudaahr
1
420
クラウド初学者が抱える不安について
tsudaahr
0
300
キューとは何か
tsudaahr
0
260
等幅は死んだ(ぇ
tsudaahr
0
110
いくら眺めてもエラーの理由がわからないコードについて
tsudaahr
0
200
Other Decks in Programming
See All in Programming
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
140
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
610
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
210
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
750
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
1
120
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
220
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
480
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
990
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
230
Featured
See All Featured
BBQ
matthewcrist
89
10k
[SF Ruby Conf 2025] Rails X
palkan
1
760
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Marketing to machines
jonoalderson
1
4.6k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
79
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
67
Embracing the Ebb and Flow
colly
88
5k
We Have a Design System, Now What?
morganepeng
54
8k
Transcript
Powershell のセキュリティ @tsuda_ahr 2015/5/16 の懇親会
自己紹介
NemCa はこんな感じ 合点がいかない! この人のせい!!
バズったコンテンツ
そして #ハレ婚 の日にこんな記事が出ていてびびる http://internet.watch.impress.co.jp/docs/special/20150307_691658.html
インターネット怖い! ガクガクブルブル (((( ;゚Д゚))
ちなみに私のブログで参照された記事の上位…(汗
さて本題
約半年前、こんな会議が大都会でありました
そこで聞いた Powershell 話。 • ほとんど忘れましたけど。
簡単に言うと • 個人PCのセキュリティが厳しくなりました。 • Windows 7 で UAC で縛り。 しかし
Admin 権限がないので、解除できず。 • UAC を操作するには上司の立ち合いが必要。 • IDE とか入れられないのでプログラム組めない。 • ファイルのコピーすら満足に自動化できんじゃん? • そうだ、Windows なら Powershell があるんじゃね? という流れだった気がする。
やってみよう
.¥test.ps1 を実行
拒否られる
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
やっぱり拒否られる
要するにファイル指定で スクリプト実行するためには 管理者権限を強いられる!
オワタ \(^o^)/
ここまでが、忘年会議での話。
しかし、手入力する分には 実行できるよね?
そう、手入力はOKなわけです。
ということは ファイル指定で実行しなければ いける!
しかし毎度コマンドを 入力するのは面倒すぎる
そこで Function の活用ですよ!
こんな風にスクリプトを function にまとめておく function test() { Get-Process } function test2($a)
{ Write-Host "hello $a!" } test.ps1
Powershell を起動したときにコピペ!
あとは function を実行すれば繰り返しいける!
権限の範囲で 楽しい スクリプトライフを!
・・・
そうじゃない!
やっぱりファイル単位で整理して、 ファイル単位で指定したい!
たとえばこんなスクリプトファイルがある $a = $args[0] Get-Process | ? { $_.CPU -ge
$a } | select Cpu, ProcessName, MainWindowTitle, Path | sort cpu -Descending | ogv getHeavtProcess.ps1 ここがコマンドラインパラメーター
こうあってほしいが・・・
当然、現実はこう (汗
そこでこんなバッチファイルを作る powershell -command "$a=gc -raw %1; $a='{'+$a+"'}'; $b=Invoke-Expression $a; $b.Invoke(%2);
pause;" psexec.bat
するとこう! コマンドプロンプト
バッチファイル経由で Powershell Script が 起動できた!
バッチファイルでやっていること。 Powershell ① -command ② " $a=gc -raw %1; ③
$a='{'+$a+'}'; ④ $b=Invoke-Expression $a;⑤ $b.Invoke(%2); ⑥ pause; ⑦ " ①Powershellを起動する ②-command オプションで Scriptを 渡す。 ③第一引数に指定したファイルをテ キストで読み込む。 ④スクリプトブロックにするので { } で囲む。 ⑤文字列をスクリプトブロックとし て評価する。 ⑥スクリプトブロックの実行。 %2 をパラメーターとして渡す。 ⑦確認待ち。
結果、生成・実行される 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
セキュリティとは 一体なんだったのか!
権限の範囲で 楽しい スクリプトライフを!
ここまでが、LT駆動 #10 (2015/1) での話。
ここから OSO 2015 懇親会ver の懇親会
powershell -ExecutionPolicy RemoteSigned そもそも、そんな謎な事しなくても・・・ Powershell の起動オプションを指定でいけるよ!
普通に使える!
いままでの苦労はなんだったのか _| ̄|◦
しかも、3年前にヒーロー島でその話聞いてた(汗 https://twitter.com/tsuda_ahr/status/183366319545131008
結論 みんな Powershell を使おう!
ご清聴ありがとうございました