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
Re: SQLiから始めるRCE生活 / RCE via SQLi
Search
tkito
July 21, 2023
Technology
380
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Re: SQLiから始めるRCE生活 / RCE via SQLi
2023/07/21に開催されたOSCP勉強会のLT資料(軽量版)です。
https://off-sec-lab.connpass.com/event/286439/
tkito
July 21, 2023
More Decks by tkito
See All by tkito
あの頃(2000年頃)のインターネット / The Internet in the early 2000s
tkito
1
180
Boot2Rootをやろう / Let's play Boot2Root
tkito
0
1.2k
権限昇格がんばるぞい LinPEAS編 / Privilege escalation using LinPEAS
tkito
2
3.9k
Linuxでの権限昇格 / Privilege Escalation in Linux
tkito
0
1.1k
SOC-IRとOSCP / SOC-IR and OSCP
tkito
0
180
Other Decks in Technology
See All in Technology
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
3
1.2k
IR Today: Theory, Practice, and Agents
dtunkelang
0
350
全人類(ほぼ)AWS Organizations の上でAWSを利用している、その世界を知る話
htan
0
120
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
210
おそらく日本で唯一のDevRelインターン生として
husengs7
0
170
今こそ知りたいAmplifyGen2
mkdev10
2
150
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
860
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
150
雪かき部 #7 もう怖くない!SELECT文!
foursue
0
280
LLM機能を自作して分かるSnowflake Cortex AIの強み
nayuts
0
310
Kernel testing frameworks
ennael
PRO
0
110
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
140
Featured
See All Featured
Building AI with AI
inesmontani
PRO
1
1.3k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Tell your own story through comics
letsgokoyo
1
1.1k
Docker and Python
trallard
47
4.2k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Evolving SEO for Evolving Search Engines
ryanjones
0
310
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Leo the Paperboy
mayatellez
10
2.3k
How to train your dragon (web standard)
notwaldorf
96
6.9k
WENDY [Excerpt]
tessaabrams
14
40k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
510
Building an army of robots
kneath
307
47k
Transcript
Re: SQLiから始めるRCE生活 2023/07/21 OSCP勉強会 #3 きとう
自己紹介 なまえ • きとう、てきとう、tkito • Twitter: @tkito しゅみ • ゲームしたり海に潜ったり徳を積んだり
2 おしごと • 企業でSOCの中の人とかIRとか Re: SQLiから始めるRCE生活
おことわり Re: SQLiから始めるRCE生活 3 今回はたぶん小ネタです
あらすじ Re: SQLiから始めるRCE生活 4 リモートコード実行したい! 楽してシェル取りたい!
シェルが取れるまで Re: SQLiから始めるRCE生活 5 Reconで空いてるポートを探す Webサーバが立ってる SQLインジェクションできる データを抜き出す シェルゲット! 別の攻略ポイントを探す
くじけずに頑張る データを使って試行錯誤
シェルが取れるまで Re: SQLiから始めるRCE生活 6 Reconで空いてるポートを探す Webサーバが立ってる SQLインジェクションできる データを抜き出す シェルゲット! 別の攻略ポイントを探す
くじけずに頑張る データを使って試行錯誤 めんどい!
シェルが取れるまで Re: SQLiから始めるRCE生活 7 Reconで空いてるポートを探す Webサーバが立ってる SQLインジェクションできる データを抜き出す シェルゲット! 別の攻略ポイントを探す
くじけずに頑張る データを使って試行錯誤 ショートカットしたい!
そんなんできるの? できる。そう、Microsoft SQL Serverならね。 Re: SQLiから始めるRCE生活 8 xp_cmdshellっていう すごいやつがいるんだ
xp_cmdshell • Microsoft SQL Serverにある機能 • https://learn.microsoft.com/ja-jp/sql/relational-databases/system-stored-procedures/xp-cmdshell- transact-sql?view=sql-server-ver16 Re: SQLiから始めるRCE生活
9 正気か!?
xp_cmdshell • こんな感じで実行できる Re: SQLiから始めるRCE生活 10
xp_cmdshell • PowerShellも実行できる Re: SQLiから始めるRCE生活 11
そんなやばいもの放置していていいの????? • 安心してください、デフォルトでは無効です • https://learn.microsoft.com/ja-jp/sql/database-engine/configure-windows/xp-cmdshell-server- configuration-option?view=sql-server-ver16 Re: SQLiから始めるRCE生活 12
ほっと一安心…? …その場で設定変更して実行できちゃう Re: SQLiから始めるRCE生活 13
攻撃が成功する条件 • WebアプリにSQLインジェクションの脆弱性がある • DBのユーザがSysAdmin権限である • 設定の変更にはSysAdmin権限が必要 • デフォルトではxp_cmdshellの実行にも管理者権限が必要 •
一般ユーザでも実行できるようにする設定は可能 Re: SQLiから始めるRCE生活 14
まとめ&おわりに • SQLiでもRCEしたい!(別のタイトル候補) • xp_cmdshellという最高のコマンド • デフォルトでは無効だけれどSQL文書いて有効にできる • SysAdmin権限が必要 •
Microsoft SQL Serverを使う際にはユーザの権限に気を付けましょう Re: SQLiから始めるRCE生活 15
おしまい きとう @tkito 16