summaryrefslogblamecommitdiffstats
path: root/sploit/rev/ldd.py
blob: 60306f1840e29c763795fa527914a01e4d7642b0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                                                                    
import re
from subprocess import run
from collections import namedtuple as nt

def get_libraries(elf):
    out = run(['ldd',elf],capture_output=True).stdout.decode('utf-8').split('\n')[:-1]
    out = [re.split(r'\s+',lib)[1:] for lib in out]
    Lib = nt("Lib", "name path addr")
    out = {l[0]:Lib(l[0],l[0] if l[0][0]=='/' else l[2] if l[1]=='=>' else None,l[-1]) for l in out}
    return out