
Linuxカーネル向けの潜在的エクスプロイトをExploitDBからダウンロードし、自動的にコンパイルするスクリプト
Linuxカーネル向けの可能性のあるエクスプロイトをexploitdbからダウンロードし、自動的にコンパイルする自動化スクリプト
このスクリプトはHackademicsに触発されて作成されました。そのカーネルバージョンには多数の可能性のあるエクスプロイトがありますが、OSCPの初心者として正しいエクスプロイトを見つけられず、また一つ一つテストするのが面倒だったため、このスクリプトが将来役立つことを願っています。
まず、searchsploitを使用してローカルディレクトリ内のexploitdbからLinuxの特権昇格を検索します。
最初のパラメータとしてカーネルバージョンを渡すと、可能性のあるエクスプロイトを一覧表示し、ローカルディレクトリからコピーするかどうかを尋ねます。
その後、ダウンロードしたCファイルをコンパイルするかどうかを尋ねます。
次に、ディレクトリのtarボールを作成するかどうかを尋ねます。
そして、ダウンロードしたファイルのサマリーを表示します。
スクリプト環境: Kali 3.18.0 kali2
Kali 4.0でのテスト結果はこのスクリプトでは否定的でした。アーキテクチャを再設計する必要があり、おそらくPythonの方がこの自動化に適しているため、再検討が必要です。
2025年3月16日: このアイデアのPython版で更新。異なるKali環境により適応しやすくなり、コードの変更も容易になりました。
2030年4月16日: OSCPのすべてのボックスをほぼ終えた後、ラボ時間中にこのスクリプトを一度も使用しなかったことを認めざるを得ません。ラボから学んだことの一つは、エクスプロイトを盲目的に実行してはいけないということです。エクスプロイトはシステムをクラッシュさせたり、想像もしない方法で痕跡を残したりする可能性があります。常に十分に列挙し、入手可能なすべての情報を収集してから昇格を試みてください。エクスプロイトが何をするのか理解せずに盲目的に実行してはいけません。
root@workstation:~/utilities# ./auto_priv_exploit.sh
[*] Usage: ./auto_priv_exploit.sh VERSION_OF_KERNEL
root@workstation:~/utilities# ls
auto_priv_exploit.sh
root@workstation:~/utilities# ./auto_priv_exploit.sh 2.6
[*] Possible Exploit
Linux Kernel 2.4.x / 2.6.x - uselib() Local Privilege Escalation Exploit | /linux/local/895.c
Linux Kernel 2.4 / 2.6 - bluez Local Root Privilege Escalation Exploit (3) | /linux/local/926.c
Postfix <= 2.6-20080814 - (symlink) Local Privilege Escalation Exploit | /linux/local/6337.sh
Linux Kernel < 2.6.29 - exit_notify() Local Privilege Escalation Exploit | /linux/local/8369.sh
Linux Kernel 2.6 - UDEV Local Privilege Escalation Exploit | /linux/local/8478.sh
Linux Kernel 2.6 UDEV < 141 - Local Privilege Escalation Exploit | /linux/local/8572.c
Linux Kernel 2.6.x - ptrace_attach Local Privilege Escalation Exploit | /linux/local/8673.c
Linux Kernel <= 2.6.34-rc3 ReiserFS xattr - Privilege Escalation | /linux/local/12130.py
Linux Kernel < 2.6.36-rc1 CAN BCM - Privilege Escalation Exploit | /linux/local/14814.c
Linux Kernel < 2.6.36-rc4-git2 - x86_64 ia32syscall Emulation Privilege Escalation | /linux/local/15023.c
Linux Kernel <= 2.6.36-rc8 - RDS Protocol Local Privilege Escalation | /linux/local/15285.c
Linux Kernel <= 2.6.37 - Local Privilege Escalation | /linux/local/15704.c
Linux Kernel < 2.6.37-rc2 - ACPI custom_method Privilege Escalation | /linux/local/15774.c
Linux Kernel 2.6.34 - CAP_SYS_ADMIN x86 - Local Privilege Escalation Exploit | /linux/local/15916.c
Linux Kernel < 2.6.34 - CAP_SYS_ADMIN x86 & x64 - Local Privilege Escalation Exploit (2) | /linux/local/15944.c
Linux Kernel < 2.6.36.2 - Econet Privilege Escalation Exploit | /linux/local/17787.c
Linux Kernel 2.6.17 - Sys_Tee Local Privilege Escalation Vulnerability | /linux/local/29714.txt
Linux Kernel 2.6.x - Ptrace Local Privilege Escalation Vulnerability | /linux/local/30604.c
Linux Kernel 2.6.x - 'pipe.c' Local Privilege Escalation Vulnerability (1) | /linux/local/33321.c
Linux Kernel 2.6.x - pipe.c Local Privilege Escalation Vulnerability (2) | /linux/local/33322.c
Linux Kernel 2.6.x - Ext4 - 'move extents' ioctl Local Privilege Escalation Vulnerability | /linux/local/33395.txt
Linux Kernel 2.6.x - 'fasync_helper()' Local Privilege Escalation Vulnerability | /linux/local/33523.c
[*] Do you wish to download all the exploit script to current directory and compile if possible?
1) Yes
2) No
#? 1
[*] The base directory is /usr/share/exploitdb/platforms
[*] Do you wish to compile all the exploit script written in C?
1) Yes
2) No
#? 1
**************************************************
[*] Successfully Compiled 9 executable located in linux_2.6
[*] Do you want to make a tar ball of the linux_2.6? (For convinient file transfer)
1) Yes
2) No
#? 1
[*] Auto Privilege Exploit Summary
C file in /root/utilities/linux_2.6 has 16 files
Python file in /root/utilities/linux_2.6 has 1 files
Perl file in /root/utilities/linux_2.6 has 0 files
Ruby file in /root/utilities/linux_2.6 has 0 files
TXT file in /root/utilities/linux_2.6 has 2 files