niklasb / libc-database

Build a database of libc offsets to simplify exploitation
https://libc.rip/
MIT License
1.71k stars 192 forks source link

make identify position independent #31

Closed 152334H closed 4 years ago

152334H commented 4 years ago

Ideally, if identify is executed in directory /different/path, a relative path/to/libc.so should be sourced from /different/path.

Current behaviour:

/different/path$ /path/to/libc-database/identify ./libc.so.6
Usage: /path/to/libc-database/identify path/to/libc.so
    OR /path/to/libc-database/identify bid=<BUILD_ID>
    OR /path/to/libc-database/identify md5=<MD5>
    OR /path/to/libc-database/identify sha1=<SHA1>
    OR /path/to/libc-database/identify sha256=<SHA256>

Expected & new behaviour:

/different/path$ /path/to/libc-database/identify ./libc.so.6
libc6_2.27-3ubuntu1.2_amd64

normal test cases to make sure nothing broke:

/path/to/libc-database$ ./identify db/libc6_2.27-3ubuntu1.2_amd64.so
libc6_2.27-3ubuntu1.2_amd64
/path/to/libc-database$ ./identify /path/to/libc-database/db/libc6_2.27-3ubuntu1.2_amd64.so
libc6_2.27-3ubuntu1.2_amd64
/different/path$ /path/to/libc-database/identify /different/path/libc.so.6
libc6_2.27-3ubuntu1.2_amd64
niklasb commented 4 years ago

LGTM, thanks a lot!