summaryrefslogtreecommitdiffstats
path: root/sploit/rev/ldd.py
blob: b5bc56413da666fa31f1d072c6d93826e1e0e1ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
from sploit.util.cmd import run_cmd_cached
from sploit.log import ilog

import re
from collections import namedtuple as nt

def get_libraries(elf):
    ilog(f'Retrieving linked libraries of {elf} with ldd...')
    out = run_cmd_cached(['ldd',elf])
    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