目次
偵察
実行スクリプト
パラメータ設定
FILE=
スクリプト作成
tee main.py <<EOF
from pwn import *
context.log_level = 'debug'
# Settings
FILE = sys.argv[1]
# context(arch='powerpc')
# elf
elf = ELF(FILE)
EOF
実行
file $FILE
python main.py $FILE
checksec --file=$FILE --format=json | jq
{
"sp33d1": {
"relro": "partial",
"canary": "yes",
"nx": "yes",
"pie": "no",
"rpath": "no",
"runpath": "no",
"symbols": "yes",
"fortify_source": "no",
"fortified": "0",
"fortify-able": "0"
}
}
出力例
$ file $FILE
python main.py $FILE
file_name: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=xxx, for GNU/Linux 3.2.0, not stripped
[*] '/path/to/elf'
Arch: amd64-64-little
RELRO: Full RELRO
Stack: Canary found
NX: NX enabled
PIE: PIE enabled
FORTIFY: Enabled
SHSTK: Enabled
IBT: Enabled
Stripped: No
checksec --file=$FILE --format=json | jq
{
"file_name": {
"relro": "partial",
"canary": "yes",
"nx": "yes",
"pie": "no",
"rpath": "no",
"runpath": "no",
"symbols": "yes",
"fortify_source": "no",
"fortified": "0",
"fortify-able": "0"
}
}
制御機構 | 値 | pwntools | checksec | 意味 |
---|---|---|---|---|
RELRO (RELocation Read Only) | No/Partial/Full | x | x | 書き込み禁止 |
STACK CANARY | Yes/No | x | x | 開始時にスタックにランダム値(カナリヤ)を格納 |
NX (No eXecute) | Yes/No | x | x | スタック領域のコード実行禁止 |
PIE (Position Independent Executable) | Yes/No | x | x | 実行ファイル配置アドレスをランダム化 |
RPATH | Yes/No | - | x | 実行ファイル共有ライブラリのサーチリストを格納 |
RUNPATH | Yes/No | - | x | RPATH + LD_LIBRALY_PATH優先 |
FORTIFY | Yes/No | - | x | GCC、GLIBC のセキュリティ機能 |
SHSTK (Shadow Stack) | x | - | リターンアドレス監視 (Intel) | |
IBT (Indirect BranchTracking) | x | - | 不正間接分岐監視 (Intel) | |
Stripped | Yes/No | x | - |