Code: Select all
edbarx@sid-inst:~$ apt-cache depends medit
medit
Depends: libatk1.0-0
Depends: libc6
Depends: libcairo2
Depends: libgcc1
Depends: libgdk-pixbuf2.0-0
Depends: libglib2.0-0
Depends: libgtk2.0-0
Depends: libice6
Depends: libpango-1.0-0
Depends: libpangocairo-1.0-0
Depends: libpython2.7
Depends: libsm6
Depends: libstdc++6
Depends: libx11-6
Depends: libxml2
Depends: python
Depends: python-support
Code: Select all
ldd /path/to/executable/file
Code: Select all
edbarx@sid-inst:~$ ldd /lib/x86_64-linux-gnu/libsystemd.so.0
linux-vdso.so.1 (0x00007fff6f9fc000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f056976a000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f0569547000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f0569265000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f056904e000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0568e4a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0568c2c000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0568883000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0569ba2000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f0568671000)
Code: Select all
nm -D /path/to/executable/file | grep " U "
Code: Select all
edbarx@sid-inst:~$ nm -D /bin/ls | grep " U "
U abort
U acl_extended_file
U acl_get_entry
U acl_get_tag_type
U __assert_fail
U bindtextdomain
U calloc
U clock_gettime
U close
U closedir
[.....]
U stpcpy
U stpncpy
U strchr
U strcmp
U strcoll
U strcpy
U strftime
U strlen
U strncmp
U strrchr
U strstr
U strtoul
[....]
Code: Select all
edbarx@sid-inst:~$ nm -D /lib/x86_64-linux-gnu/librt.so.1 | grep " U "
U __assert_fail
U calloc
U __clock_getcpuclockid
U __clock_getres
U __clock_gettime
U __clock_nanosleep
U __clock_settime
U __endmntent
U errno
U fcntl
U fdatasync
U __fortify_fail
U free
U fsync
U __getmntent_r
U getpid
U gettimeofday
U getuid
[.....]
Example: Let us list what libc.so.6 exports:
Code: Select all
edbarx@sid-inst:~$ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep " T "
0000000000041bc0 T a64l
00000000000363a0 T abort
0000000000038200 T abs
00000000000e70d0 T accept4
00000000000df050 T acct
00000000000438b0 T addseverity
00000000000e60c0 T __adjtimex
00000000000b72d0 T alarm
00000000000b39a0 T alphasort
00000000000e6020 T __arch_prctl
000000000008c890 T __argz_count
000000000008cad0 T argz_delete
000000000008ca80 T __argz_next
000000000008cca0 T __argz_stringify
00000000000a7de0 T asctime
[.....] ( there are many more exported functions )
Code: Select all
edbarx@sid-inst:~$ nm -D /bin/mount | grep " T "
0000000000405c1c T _fini
0000000000402a28 T _init
By inspecting what libraries an executable file (program) uses, and what functions a program imports, it is possible to port it to your distribution of choice.