Change loader for programs
Hello world,
I would like to ask a rookie question about the possibility to reassign
by substitution a new loader (/lib/ld-linux.so.2 or alike) to each program.
In fact, I know that it's possible to launch it for example echo by
using /new/path/lib/ld-2.3.2 /new/path/bin/echo but I would like to do
it without specifiing boot loader.
I've investigate in elf tools and I've found objdump and objcopy.
I discover by objdump that the loader is specified in .interp section.
So I try the following commands
cd /tmp
objcopy --remove-section=.interp /bin/echo /tmp/echo
echo -n "/lib/ld-linux.so.2" > foo
objcopy --add-section .interp=foo /tmp/echo /tmp/echo.new
and, unfortunately:
./echo.new
bash: ./echo.new: cannot execute binary file
With objdump, here are my output :
$ objdump -Sl -j .interp /tmp/echo.new
/tmp/echo.new: format de fichier elf32-i386
Déassemblage de la section .interp:
00000000 <opterr-0x804c460>:
0: 2f das
1: 6c insb (%dx),%es:(%edi)
2: 69 62 2f 6c 64 2d 6c imul $0x6c2d646c,0x2f(%edx),%esp
9: 69 6e 75 78 2e 73 6f imul $0x6f732e78,0x75(%esi),%ebp
10: 2e cs
11: 32 .byte 0x32
$ objdump -Sl -j .interp /bin/echo
/bin/echo: format de fichier elf32-i386
Déassemblage de la section .interp:
08048114 <.interp>:
8048114: 2f das
8048115: 6c insb (%dx),%es:(%edi)
8048116: 69 62 2f 6c 64 2d 6c imul $0x6c2d646c,0x2f(%edx),%esp
804811d: 69 6e 75 78 2e 73 6f imul $0x6f732e78,0x75(%esi),%ebp
8048124: 2e 32 00 xor %cs:(%eax),%al
This changing loader property would help me to have an operational
Debian system on a user (non chroot account).
Thanks for answer
EQ
Reply to: