-lcrypt 交叉编译 64 到 32 时出错

-lcrypt 交叉编译 64 到 32 时出错

我正在尝试编译 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

加密错误

我已经用这个命令安装了 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 来编译它?

答案1

您需要安装libc6-dev:i386,它是包含/usr/lib/i386-linux-gnu/libcrypt.so(这是链接器需要的)的包:

sudo apt install libc6-dev:i386

相关内容