picoCTF2021のBinaryExploitation「Here's a libc」の問題を解こうとしたら以下のようにエラーが発生:
shoebill@pwner:~/pico$ ls
libc.so.6 vuln
shoebill@pwner:~/pico$ ./vuln
Inconsistency detected by ld.so: dl-call-libc-early-init.c: 37: _dl_call_libc_early_init: Assertion `sym != NULL' failed!
リンカのバージョンと与えられたlibcのバージョンの違いによるエラーと考えられる。
これを行なっているUbuntuの情報:
shoebill@pwner:~$ uname -a
Linux pwner 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
pwninitで解決
ここから直接バイナリをダウンロードしました。
pkg-config
が必要になるので事前にインストールしておきます:
sudo apt install pkg-config
目的の実行ファイルとlibc.so
のある場所でpwninit
を実行します:
shoebill@pwner:~/pico$ ls
libc.so.6 pwninit vuln
shoebill@pwner:~/pico$ ./pwninit
bin: ./vuln
libc: ./libc.so.6
fetching linker
https://launchpad.net/ubuntu/+archive/primary/+files//libc6_2.27-3ubuntu1.2_amd64.deb
unstripping libc
https://launchpad.net/ubuntu/+archive/primary/+files//libc6-dbg_2.27-3ubuntu1.2_amd64.deb
warning: failed unstripping libc: failed running eu-unstrip, please install elfutils: No such file or directory (os error 2)
setting ./ld-2.27.so executable
copying ./vuln to ./vuln_patched
running patchelf on ./vuln_patched
writing solve.py stub
shoebill@pwner:~/pico$ ls
ld-2.27.so libc.so.6 pwninit solve.py vuln vuln_patched
shoebill@pwner:~/pico$ ./vuln_patched
WeLcOmE To mY EcHo sErVeR!
無事実行できるようになりました。
こちらも参考:
https://sh0ebill.hatenablog.com/entry/2022/09/28/215346