简体   繁体   English

bash:./<filename> 无此文件或目录</filename>

[英]bash: ./<filename> No such file or directory

I'm trying to run a binary.我正在尝试运行二进制文件。 But when I'm trying to run the file I'm facing the following error.但是当我尝试运行该文件时,我遇到了以下错误。

`pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ ./house_of_force 
bash: ./house_of_force: No such file or directory`

`pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ ldd ./house_of_force 
    linux-vdso.so.1 (0x00007fff7c6da000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3f879bd000)
    ../.glibc/glibc_2.28_no-tcache/ld.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f3f87bf9000)
`

` `

pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ file ./house_of_force 
./house_of_force: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter ../.glibc/glibc_2.28_no-tcache/ld.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=278a2aec8b352ea120c49321ed3254eb15ca8ef5, with debug_info, not stripped`

pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ readelf -l house_of_force 

Elf file type is EXEC (Executable file)
Entry point 0x400730
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R      0x8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x0000000000000027 0x0000000000000027  R      0x1
      [Requesting program interpreter: ../.glibc/glibc_2.28_no-tcache/ld.so.2]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x0000000000000d88 0x0000000000000d88  R E    0x200000
  LOAD           0x0000000000001d70 0x0000000000601d70 0x0000000000601d70
                 0x00000000000002c0 0x00000000000002c8  RW     0x200000
  DYNAMIC        0x0000000000001d80 0x0000000000601d80 0x0000000000601d80
                 0x0000000000000200 0x0000000000000200  RW     0x8
  NOTE           0x0000000000000260 0x0000000000400260 0x0000000000400260
                 0x0000000000000044 0x0000000000000044  R      0x4
  GNU_EH_FRAME   0x0000000000000c04 0x0000000000400c04 0x0000000000400c04
                 0x000000000000004c 0x000000000000004c  R      0x4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10
  GNU_RELRO      0x0000000000001d70 0x0000000000601d70 0x0000000000601d70
                 0x0000000000000290 0x0000000000000290  R      0x1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .plt.got .text .fini .rodata .eh_frame_hdr .eh_frame 
   03     .init_array .fini_array .dynamic .got .data .bss 
   04     .dynamic 
   05     .note.ABI-tag .note.gnu.build-id 
   06     .eh_frame_hdr 
   07     
   08     .init_array .fini_array .dynamic .got 

My System Details:我的系统详细信息:

pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ uname -a
Linux pegasus 5.15.0-58-generic #64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

pegasus@pegasus:~/Documents/Courses/heaplab-main/house_of_force$ lsb_release -a
LSB Version:    core-11.1.0ubuntu4-noarch:printing-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy

I've already done chmod a+x house_of_force What I'm suspecting some shared object or the interpreter is broken.我已经完成了chmod a+x house_of_force我怀疑某些共享 object 或解释器已损坏。 I'm unable to link them properly.我无法正确链接它们。

Help me running the file properly using ./house_of_force帮助我使用./house_of_force正确运行文件

I'm facing the following error我面临以下错误

The problem is that your binary is linked in a very weird way.问题是您的二进制文件以一种非常奇怪的方式链接。

In particular, its interpreter is set to ../.glibc/glibc_2.28_no-tcache/ld.so.2 , and this binary will run only when invoked from a directory in which ../.glibc/glibc_2.28_no-tcache/ld.so.2 exists.特别是,它的解释器设置为../.glibc/glibc_2.28_no-tcache/ld.so.2 ,并且这个二进制文件只有在从../.glibc/glibc_2.28_no-tcache/ld.so.2的目录调用时才会运行../.glibc/glibc_2.28_no-tcache/ld.so.2存在。

Invoking this binary from any other directory will fail with ENOENT .从任何其他目录调用此二进制文件将失败并显示ENOENT

It is unlikely that that's what you want this binary to do.这不太可能是您希望此二进制文件执行的操作。 You'll need to fix your link line -- usually the interpreter is set to the absolute path to ld.so .您需要修复您的链接行——通常解释器设置为ld.so绝对路径。

PS You probably want to link with this custom GLIBC build in order to solve some problem. PS 你可能想链接这个自定义 GLIBC 构建以解决一些问题。 But it's unlikely that linking with custom GLIBC is the right solution to whatever that problem is.但是与自定义 GLIBC 链接不太可能是解决该问题的正确方法。 See http://xyproblem.info .请参阅http://xyproblem.info

Update:更新:

It was a file given in linux heap exploitation course.这是 linux 堆利用课程中给出的文件。

You should have explained this in your question.你应该在你的问题中解释这一点。

Like the answer says, this binary will only run in a directory in which ../.glibc exists.就像答案所说的那样,这个二进制文件只会../.glibc存在的目录中运行。 If you have .glibc/ directory (containing glibc_2.28_no-tcache/ld.so.2 ), then do this:如果您有.glibc/目录(包含glibc_2.28_no-tcache/ld.so.2 ),则执行以下操作:

cd .glibc
mkdir foo
mv /path/to/house_of_force foo
cd foo
./house_of_force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 `bash: ./a.out: 在运行由 `ld` 生成的可执行文件时没有这样的文件或目录 - `bash: ./a.out: No such file or directory` on running executable produced by `ld` 链接错误:<filename> .asm:错误的 object 文件</filename> - tlink error: <filename>.asm : bad object file 打开失败:没有这样的文件或目录 - open failed: No such file or directory .so 文件,没有这样的文件或目录,C++ - .so file, No Such File or directory, C++ vs 2017静态库“无此类文件或目录” - vs 2017 static library “No Such File or Directory” 如何在我的机器上没有重复的自定义 bash 脚本目录并将其添加为使用 PATH 获取的链接? - How do I not have a duplicated custom bash script directory on my machine and add it as a link that is picked up with PATH? 从另一个目录中的源文件调用方法 - Call method from source file in another directory 从 html 中的目录链接 pdf 文件 - Linking pdf file from directory in html Visual Studio无法打开包含文件;不能打开包含文件。 没有相应的文件和目录 - Visual Studio Cannot open include file; No such file or directory 如何调试“无法打开共享 object 文件:没有这样的文件或目录”? - How to debug "cannot open shared object file: No such file or directory"?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM