Binmap: scanning file systems with Binmap
2016 RMLL Security Track
Serge Guelton
Sébastien Renaud
2016 RMLL Security Track
Serge Guelton
Sébastien Renaud
Needs to audit a smartphone, where to start?
$ find / -name '*.so' | \
while read so; do \
nm -CD "$so" | grep strcpy && echo $so ; \
done
Similar commands to find libraries with:
strcpy
, system
)In the end we may want to build:
A Simple Tool that:
Nothing more :-)
https://github.com/quarkslab/binmap
Tested on Linux & Windows
Supported Binary Formats:
- ELF
- PE
$ binmap scan /usr/local -o local.dat
or
$ ./binmap scan --chroot ./extracted_fs -o image.dat
The graph + metadata is represented as serialized C++ data structure, NoDB™
$ ./binmap view -i local.dat -o local.dot
Python binding:
>>> import blobmap
Load the db:
>>> blobs = blobmap.BlobMap('local.dat')
And the last scan result:
>>> blob = blobs.last()
Inspect nodes:
>>> clang_metadata = blob['/usr/local/bin/clang']
>>> str(clang_metadata)
clang: 8fcffc4a97cd4aaa1a32938a9e95d3b253476121(13223 exported symbols)(1303 imported symbols)(1 hardening features)
>>> clang_metadata.hash
8fcffc4a97cd4aaa1a32938a9e95d3b253476121
>>> clang_metadata.hardening_features
{'fortified'}
⇒ regexp on .rodata
:-/
Find binary that may be interesting:
>>> max(blob.items(), key=lambda item: score(item[1]))
Using:
>>> LOOKATME = 'strcpy', 'system'
>>> def score(node):
return (len(s.imported_symbols.intersection(LOOKATME)) -
len(s.hardening_features))
Find all binaries that load a given shared library
Using:
>>> [n.name for n in b.induced_predecessors('/lib32/libc.so.6')]
Compare two snapshots of a system
>>> blob0, blob1 = list(blobs.values())[-2:]
>>> diff = blob00.diff(blob1)
>>> diff.added
{'/.../libmy1.so'}
>>> diff.removed
{'/.../libmy0.so'}
>>> diff.updated
{'/.../myprog'}
:'(
) + OpenMP (optional)Boost.Python
sqlite
as a backendhttps://github.com/quarkslab/binmap