elfcall package

Submodules

elfcall.client module

elfcall.client.get_parser()[source]
elfcall.client.run_client()[source]

elfcall.logger module

elfcall.version module

elfcall.main.client module

class elfcall.main.client.BinaryInterface(binary=None, quiet=False, skipdirs=None)[source]

Bases: object

Parse binaries to determine symbols needed and interfaces

check()[source]

Ensure that each binary exists, and we have a fullpath

find_library(name, paths, match_to=None, use_versions=False)[source]

Given a listing of paths, look for a library by name

gen(binary=None, fmt=None, secure=False, no_default_libs=False)[source]

Generate a graph of symbols (e.g., where everything is found)

gen_output(binary=None, secure=False, no_default_libs=False, ld_library_paths=None, use_versions=False)[source]

Generate a graph of symbols (e.g., where everything is found)

get_search_paths(e)[source]

Based on existence of RPATH and RUNTIME path, return ELF search path

library_tree(results)[source]

Generate the library tree

parse_binary(binary, return_missing=False, use_versions=False)[source]

Given a binary, figure out how the linker would find symbols

parse_dir(path)[source]

Given a directory path, get all files (fullpaths) in it

recursive_find(lib, original, root=None, needed_search=None, seen=None, level=0, use_versions=False)[source]

recursively find needed paths, keep track of hierarchy

reset(skipdirs=None)[source]

Reset or init attributes

tree(binary=None, secure=False, no_default_libs=False, use_versions=False)[source]

Generate a library tree

elfcall.main.ld module

class elfcall.main.ld.LibraryParser[source]

Bases: object

property default_paths
find_source(name)[source]

Given a source directory (usually something from ld paths) return source

in_default_path(path)[source]

In secure mode, we only allow a path from ld preload given that it’s in a default path.

property ld_preload

Parse LD_PRELOAD from the environment and (rarely) a system file

parse(secure=False, no_default_libs=False)[source]

Parse paths. We define secure and no default libs here, and arguably could support defining it in the init instead.

parse_ld_library_path(secure=False)[source]

Get LD_LIBRARY_PATH from the environment

parse_ld_so_conf()[source]
prepend_ld_library_paths(paths)[source]

Prepend ld library paths we are emulating to be in the environment.

set_default_paths()[source]

Add to sources, but don’t add to paths list, because default paths come after the DT_RUNTIME and/or DT_RPATH.

elfcall.main.elf module

class elfcall.main.elf.ElfFile(realpath, fullpath=None, use_versions=False)[source]

Bases: object

property arch
property elfcls
property endian
get_exported_symbols()[source]
get_imported_symbols()[source]

Look for .gnu_debuglink

property is_stripped

Guess if an ELF is stripped based on missing DT_NEEDED and symbols.

iter_symbols()[source]

Expose non weak and local symbols

matches(libelf)[source]

Compare an elf to another lib’s elf type, arch, and header metadata. Return True if they match, False otherwise.

property needed
property operating_system
property rpath
property runpath
property soname
yield_tag(name)[source]

elfcall.main.graph.text module

class elfcall.main.graph.text.Console(target, results, outfile=None)[source]

Bases: GraphBase

generate()[source]
class elfcall.main.graph.text.Text(target, results, outfile=None)[source]

Bases: GraphBase

generate(include_singles=False)[source]

elfcall.main.graph.cypher module

class elfcall.main.graph.cypher.Cypher(target, results, outfile=None)[source]

Bases: GraphBase

generate()[source]

elfcall.main.graph.gexf module

class elfcall.main.graph.gexf.Gexf(target, results, outfile=None)[source]

Bases: GraphBase

generate()[source]

elfcall.main.graph.dot module

class elfcall.main.graph.dot.Dot(target, results, outfile=None)[source]

Bases: GraphBase

The dot format is for graphviz

generate(graphname=None, fontname='Arial')[source]

elfcall.utils.terminal module

elfcall.utils.terminal.colify(listing)[source]
elfcall.utils.terminal.confirm_action(question, force=False)[source]

confirm if the user wants to perform a certain action

Parameters:
  • question (the question that will be asked) –

  • force (if the user wants to skip the prompt) –

elfcall.utils.terminal.get_installdir()[source]

get_installdir returns the installation directory of the application

elfcall.utils.terminal.iter_splitpath(path)[source]

Given a path (e.g., LD_LIBRARY_PATH or DT_RPATH or DT_RUNPATH split into individual paths

elfcall.utils.terminal.run_command(cmd, sudo=False, stream=False)[source]

run_command uses subprocess to send a command to the terminal.

Parameters:
  • cmd (the command to send, should be a list for subprocess) –

  • error_message (the error message to give to user if fails,) –

  • failed. (if none specified, will alert that command) –

elfcall.utils.terminal.which(software, strip_newline=True)[source]

get_install will return the path to where Singularity (or another executable) is installed.

elfcall.utils.fileio module

elfcall.utils.fileio.copyfile(source, destination, force=True)[source]

Copy a file from a source to its destination.

elfcall.utils.fileio.get_file_hash(image_path, algorithm='sha256')[source]

Return an sha256 hash of the file based on a criteria level.

elfcall.utils.fileio.get_tmpdir(tmpdir=None, prefix='', create=True)[source]

Get a temporary directory for an operation.

elfcall.utils.fileio.get_tmpfile(tmpdir=None, prefix='', suffix=None)[source]

Get a temporary file with an optional prefix.

elfcall.utils.fileio.mkdir_p(path)[source]

mkdir_p attempts to get the same functionality as mkdir -p :param path: the path to create.

elfcall.utils.fileio.mkdirp(dirnames)[source]

Create one or more directories

elfcall.utils.fileio.print_json(json_obj)[source]

Print json pretty

elfcall.utils.fileio.read_file(filename, mode='r')[source]

Read a file.

elfcall.utils.fileio.read_json(filename, mode='r')[source]

Read a json file to a dictionary.

elfcall.utils.fileio.recursive_find(base, pattern=None)[source]

Find filenames that match a particular pattern, and yield them.

elfcall.utils.fileio.write_file(filename, content, mode='w')[source]

Write content to a filename

elfcall.utils.fileio.write_json(json_obj, filename, mode='w', print_pretty=True)[source]

Write json to a filename