- class libpastis.package.BinaryPackage(main_binary: Path)[source]
Binary Package representing a given target to fuzz along with its shared libraries and additional files required (cmplog, dictionnary etc.). This object is received by fuzzing agents as part of the START message.
- Parameters:
main_binary – main executable file path
- EXTENSION_BLACKLIST = ['.gt', '.Quokka', '.quokka', '.cmplog']
- property arch: Arch
Return the architecture of the binary package (main executable target).
- Returns:
architecture
- static auto(exe_file: Path | str) BinaryPackage | None [source]
Take a file and try creating a BinaryPackage with it. The exe_file is the main executable file. From that the function will look for quokka, cmplog, dictionary files (in the same directory).
- Parameters:
exe_file – main target executable file
- Returns:
a binary package if exe_file if applicable
- static auto_directory(exe_file: str | Path) BinaryPackage | None [source]
Create a BinaryPackage with all files it can find in the given directory. The difference with
BinaryPackage.auto()
is that all additional files in the directory will be added to the package.- Parameters:
exe_file – main executable in the directory
- Returns:
BinaryPackage if applicable
- property callgraph: Path | None
Path to the callgraph file if provided.
- Returns:
path of the quokka file
- property cmplog: Path | None
Path to the complog executable file if provided.
- Returns:
path to the complog file
- property dictionary: Path | None
Path the to dictionnary file if provided.
- Returns:
path to the dictionnary file
- static from_binary(name: str, binary: bytes, extract_dir: Path) BinaryPackage [source]
Convert the binary blob received as a BinaryPackage object. If its an archive, extract it and return the list of files. Files are extracted in /tmp. If directly an executable save it to a file and return its path. Also ensure the executable file is indeed executable in terms of permissions.
- Parameters:
name – name of executable, or executable name in archive
binary – content
extract_dir – Path: directory where files should be extracted
- Returns:
list of file paths
- Raises:
FileNotFoundError – if the mime type of the binary is not recognized
- is_cmplog() bool [source]
Check if the package contains a cmplog file.
- Returns:
True if contains cmplog
- is_dictionary() bool [source]
Check if the package contains a dictionnary.
- Returns:
True if contains a dictionnary
- is_quokka() bool [source]
Check if the package contains a quokka file.
- Returns:
True if contains a quokka file
- is_standalone() bool [source]
Indicates that this BinaryPackage only contains the program under test and no additional files such as a Quokka database or a cmplog instrumented binary. This is used in pastis-broker when sending the ‘start’ command to agents.
- make_package() Path [source]
Pack the BinaryPackage in a zip file.
- Returns:
Path to a .zip file containing the whole package