Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Powershell のセキュリティ (大都会ver)
Search
tsuda.a
May 16, 2015
Programming
66
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Powershell のセキュリティ (大都会ver)
Powershell のセキュリティ
tsuda.a
May 16, 2015
More Decks by tsuda.a
See All by tsuda.a
Git を GUI で使う話
tsudaahr
0
140
マジカルインクリメントと指数表記
tsudaahr
0
300
バックアップしていますか?
tsudaahr
0
170
RDB以前のファイル設計の話でもしようか(ぇ
tsudaahr
0
180
NPUわからん
tsudaahr
0
230
計算量オーダーの話
tsudaahr
1
490
クラウド初学者が抱える不安について
tsudaahr
0
470
キューとは何か
tsudaahr
0
310
等幅は死んだ(ぇ
tsudaahr
0
160
Other Decks in Programming
See All in Programming
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
3.8k
カツオ、ご期待ください
suneo3476
0
190
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
610
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
960
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
ジョジョの世界をXRで再現する
mofurune
0
170
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
sbt 2.0: takeoff
eed3si9n
0
160
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
280
How to train your dragon (web standard)
notwaldorf
96
6.9k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
410
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
59k
Building AI with AI
inesmontani
PRO
1
1.3k
BBQ
matthewcrist
90
10k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Prompt Engineering for Job Search
mfonobong
0
520
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
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 を使おう!
ご清聴ありがとうございました