angr.state_plugins.filesystem¶
- class angr.state_plugins.filesystem.Stat¶
Bases:
tupleStat(st_dev, st_ino, st_nlink, st_mode, st_uid, st_gid, st_rdev, st_size, st_blksize, st_blocks, st_atime, st_atimensec, st_mtime, st_mtimensec, st_ctime, st_ctimensec)
- static __new__(_cls, st_dev, st_ino, st_nlink, st_mode, st_uid, st_gid, st_rdev, st_size, st_blksize, st_blocks, st_atime, st_atimensec, st_mtime, st_mtimensec, st_ctime, st_ctimensec)
Create new instance of Stat(st_dev, st_ino, st_nlink, st_mode, st_uid, st_gid, st_rdev, st_size, st_blksize, st_blocks, st_atime, st_atimensec, st_mtime, st_mtimensec, st_ctime, st_ctimensec)
- st_atime
Alias for field number 10
- st_atimensec
Alias for field number 11
- st_blksize
Alias for field number 8
- st_blocks
Alias for field number 9
- st_ctime
Alias for field number 14
- st_ctimensec
Alias for field number 15
- st_dev
Alias for field number 0
- st_gid
Alias for field number 5
- st_ino
Alias for field number 1
- st_mode
Alias for field number 3
- st_mtime
Alias for field number 12
- st_mtimensec
Alias for field number 13
- st_nlink
Alias for field number 2
- st_rdev
Alias for field number 6
- st_size
Alias for field number 7
- st_uid
Alias for field number 4
- class angr.state_plugins.filesystem.SimFilesystem¶
Bases:
SimStatePluginangr’s emulated filesystem. Available as state.fs. When constructing, all parameters are optional.
- Parameters:
files – A mapping from filepath to SimFile
pathsep – The character used to separate path elements, default forward slash.
cwd – The path of the current working directory to use
mountpoints – A mapping from filepath to SimMountpoint
- Variables:
pathsep – The current pathsep
cwd – The current working directory
unlinks – A list of unlink operations, tuples of filename and simfile. Be careful, this list is shallow-copied from successor to successor, so don’t mutate anything in it without copying.
- __init__(files=None, pathsep=None, cwd=None, mountpoints=None)¶
- property unlinks¶
- chdir(path)¶
Changes the current directory to the given path
- get(path)¶
Get a file from the filesystem. Returns a SimFile or None.
- insert(path, simfile)¶
Insert a file into the filesystem. Returns whether the operation was successful.
- delete(path)¶
Remove a file from the filesystem. Returns whether the operation was successful.
This will add a
fs_unlinkevent with the path of the file and also the index into the unlinks list.
- mount(path, mount)¶
Add a mountpoint to the filesystem.
- unmount(path)¶
Remove a mountpoint from the filesystem.
- get_mountpoint(path)¶
Look up the mountpoint servicing the given path.
- Returns:
A tuple of the mount and a list of path elements traversing from the mountpoint to the specified file.
- class angr.state_plugins.filesystem.SimMount¶
Bases:
SimStatePluginThis is the base class for “mount points” in angr’s simulated filesystem. Subclass this class and give it to the filesystem to intercept all file creations and opens below the mountpoint. Since this a SimStatePlugin you may also want to implement set_state, copy, merge, etc.
- get(path_elements)¶
Implement this function to instrument file lookups.
- Parameters:
path_elements – A list of path elements traversing from the mountpoint to the file
- Returns:
A SimFile, or None
- insert(path_elements, simfile)¶
Implement this function to instrument file creation.
- Parameters:
path_elements – A list of path elements traversing from the mountpoint to the file
simfile – The file to insert
- Returns:
A bool indicating whether the insert occurred
- delete(path_elements)¶
Implement this function to instrument file deletion.
- Parameters:
path_elements – A list of path elements traversing from the mountpoint to the file
- Returns:
A bool indicating whether the delete occurred
- lookup(sim_file)¶
Look up the path of a SimFile in the mountpoint
- Parameters:
sim_file – A SimFile object needs to be looked up
- Returns:
A string representing the path of the file in the mountpoint Or None if the SimFile does not exist in the mountpoint
- class angr.state_plugins.filesystem.SimConcreteFilesystem¶
Bases:
SimMountAbstract SimMount allowing the user to import files from some external source into the guest
- Parameters:
pathsep (str) – The host path separator character, default os.path.sep
- __init__(pathsep='/')¶
- class angr.state_plugins.filesystem.SimHostFilesystem¶
Bases:
SimConcreteFilesystemSimulated mount that makes some piece from the host filesystem available to the guest.
- Parameters:
- __init__(host_path=None, **kwargs)¶