change file permissions in Kali Linux

-2

1

How to change file permissions to execute a binary executable ELF file in Kali Linux? I have been trying chmod +x <filename> and then running it with ./filename but all I get is Error: No file found. Any other ideas? I even tried chmod 777 <filename>. I am wondering if there is anything I am missing?

Edit:

Output of file <filename>:

root@swat:~/Downloads# file talisman 
talisman: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, 
BuildID[sha1]=2b131df906087adf163f8cba1967b3d2766e639d, not stripped

Output of ldd <filename>:

root@swat:~/Downloads# ldd ./talisman 
not a dynamic executable

Output of ls /lib:

root@swat:~# ls /lib
console-setup  init                                  startpar
cpp            klibc-k3La8MUnuzHQ0_kG8hokcGAC0PA.so  systemd
crda           ld-linux.so.2                         terminfo
cryptsetup     live                                  udev
firmware       lsb                                   x86_64-linux-gnu
hdparm         modprobe.d
ifupdown       modules

warfreak92

Posted 2017-11-07T06:18:12.670

Reputation: 9

1That error message means that it's not a permissions issue, but perhaps a missing dependency, e.g. a shared library. Edit your post, and add the output from shell commands file <filename>, ldd <filename>, and ls /lib. – sawdust – 2017-11-07T06:59:03.170

This is likely a dup of https://superuser.com/a/375290/112397

– Employed Russian – 2017-11-08T04:06:16.553

@sawdust, edited the question with the output as requested. sorry took me time to get back. – warfreak92 – 2017-11-19T16:20:31.347

Answers

0

This solves it.

root@swat:~/Downloads# readelf -l ./talisman | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.2]

Then I looked for the missing libraries by issuing this command:

root@swat:~/Downloads# ldd /bin/ls
linux-vdso.so.1 (0x00007ffe9a971000)
libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 
(0x00007fe90a8a7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe90a50a000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe90a297000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe90a093000)
/lib64/ld-linux-x86-64.so.2 (0x000056083d3b2000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007fe909e76000)

This confirms it that I do not have broken symbolic links for that library and that library (/lib/ld-linux.so.2) it is loading is not found in /bin/ls.

Issuing this fixes the problem:

sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1

warfreak92

Posted 2017-11-07T06:18:12.670

Reputation: 9

1

There are several cases where you can get the message “No such file or directory”:

  • The file doesn't exist. This is not the case here.

  • There is a file by that name, but it's a dangling symbolic link. The chmod +x ./filename would have printed an error if that was the case.

  • The file is a dynamically linked ELF file, and the program interpreter that is required to run it does not exist.

    Use readelf -l filename | grep interpreter to find out which program interpreter is required, and verify that it exists and has correct permissions.

  • The file exists, and you can even read it but when you try to execute it you are told that it doesn't exist.

The file -L filename command will tell you just what this binary is.

I can't find any example 32-bit Linux executable to try this with, but maybe you can just run the file command and verify whether the file is 32-bit or 64-bit. You might have a 32-bit binary on a 64-bit system that doesn't have 32-bit support installed (this is special case of "program interpreter is missing").

Niklas

Posted 2017-11-07T06:18:12.670

Reputation: 753