Debian

-lcrypt 錯誤交叉編譯 64 到 32

  • February 15, 2021

我正在嘗試編譯可在此處找到的dirtycow 漏洞利用文件。

gcc -pthread dirty.c -o dirty -m32 -lcrypt

因為我的目標是 32 位,所以我編譯它-m32-lycrypt確保它按預期工作。但是編譯時出現錯誤,

/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libcrypt.so when searching for -lcrypt
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libcrypt.a when searching for -lcrypt
/usr/bin/ld: cannot find -lcrypt
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libcrypt.so when searching for -lcrypt
collect2: error: ld returned 1 exit status

lcrypt 錯誤

我已經用這個命令安裝了 multilib 和 i386

sudo apt-get install gcc-multilib libc6-dev-i386

但它仍然無法正常工作。

這是我設備中的 libcrypt 列表:

$ locate libcrypt
/usr/i686-w64-mingw32/lib/libcrypt32.a
/usr/i686-w64-mingw32/lib/libcryptnet.a
/usr/i686-w64-mingw32/lib/libcryptsp.a
/usr/i686-w64-mingw32/lib/libcryptxml.a
/usr/lib/i386-linux-gnu/libcrypt.so.1
/usr/lib/i386-linux-gnu/libcrypt.so.1.1.0
/usr/lib/nsight-compute/host/linux-desktop-glibc_2_11_3-x64/libcrypto.so.1.0.0
/usr/lib/nsight-systems/host-linux-x64/libcrypto.so.1.0.0
/usr/lib/x86_64-linux-gnu/libcrypt.a
/usr/lib/x86_64-linux-gnu/libcrypt.so
/usr/lib/x86_64-linux-gnu/libcrypt.so.1
/usr/lib/x86_64-linux-gnu/libcrypt.so.1.1.0
/usr/lib/x86_64-linux-gnu/libcrypto.a
/usr/lib/x86_64-linux-gnu/libcrypto.so
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
/usr/lib/x86_64-linux-gnu/libcryptsetup.so.12
/usr/lib/x86_64-linux-gnu/libcryptsetup.so.12.6.0
/usr/lib/x86_64-linux-gnu/pkgconfig/libcrypt.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/libcrypto.pc
/usr/share/bug/libcryptsetup12
/usr/share/doc/libcrypt-dev
/usr/share/doc/libcrypt1
/usr/share/doc/libcryptsetup12
/usr/share/doc/libcrypt1/README.md.gz
/usr/share/doc/libcrypt1/TODO.md.gz
/usr/share/doc/libcrypt1/changelog.Debian.gz
/usr/share/doc/libcrypt1/changelog.gz
/usr/share/doc/libcrypt1/copyright
/usr/share/doc/libcryptsetup12/changelog.Debian.gz
/usr/share/doc/libcryptsetup12/changelog.gz
/usr/share/doc/libcryptsetup12/copyright
/usr/x86_64-w64-mingw32/lib/libcrypt32.a
/usr/x86_64-w64-mingw32/lib/libcryptdlg.a
/usr/x86_64-w64-mingw32/lib/libcryptdll.a
/usr/x86_64-w64-mingw32/lib/libcryptext.a
/usr/x86_64-w64-mingw32/lib/libcryptnet.a
/usr/x86_64-w64-mingw32/lib/libcryptsp.a
/usr/x86_64-w64-mingw32/lib/libcryptsvc.a
/usr/x86_64-w64-mingw32/lib/libcryptui.a
/usr/x86_64-w64-mingw32/lib/libcryptxml.a
/var/cache/apt/archives/libcrypt-dev_1%3a4.4.17-1_amd64.deb
/var/cache/apt/archives/libcrypt1_1%3a4.4.17-1_amd64.deb
/var/cache/apt/archives/libcrypt1_1%3a4.4.17-1_i386.deb
/var/lib/dpkg/info/libcrypt-dev:amd64.list
/var/lib/dpkg/info/libcrypt-dev:amd64.md5sums
/var/lib/dpkg/info/libcrypt1:amd64.list
/var/lib/dpkg/info/libcrypt1:amd64.md5sums
/var/lib/dpkg/info/libcrypt1:amd64.shlibs
/var/lib/dpkg/info/libcrypt1:amd64.symbols
/var/lib/dpkg/info/libcrypt1:amd64.triggers
/var/lib/dpkg/info/libcrypt1:i386.list
/var/lib/dpkg/info/libcrypt1:i386.md5sums
/var/lib/dpkg/info/libcrypt1:i386.shlibs
/var/lib/dpkg/info/libcrypt1:i386.symbols
/var/lib/dpkg/info/libcrypt1:i386.triggers
/var/lib/dpkg/info/libcryptsetup12:amd64.list
/var/lib/dpkg/info/libcryptsetup12:amd64.md5sums
/var/lib/dpkg/info/libcryptsetup12:amd64.shlibs
/var/lib/dpkg/info/libcryptsetup12:amd64.symbols
/var/lib/dpkg/info/libcryptsetup12:amd64.triggers

有沒有辦法解決它?還是我應該製作一個 32 位 VM 來編譯它?

您需要 install libc6-dev:i386,這是包含的包/usr/lib/i386-linux-gnu/libcrypt.so(這是連結器需要的):

sudo apt install libc6-dev:i386

引用自:https://unix.stackexchange.com/questions/612985