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:
SimStatePlugin,SupportsMergeangr’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, relative to the current root
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¶
- property root¶
The current root directory, as an absolute path in the filesystem’s original namespace, i.e. the one paths were resolved in before any chroot.
- chdir(path)¶
Changes the current directory to the given path
- chroot(path)¶
Changes the root directory to the given path, which is interpreted relative to the current root.
This only ever narrows what is reachable: the new root is resolved inside this filesystem, and paths (including “..”) are resolved under it from then on. Contrary to Linux, where the current directory is left where it was and can therefore point outside the new root, the current directory is re-anchored inside the new root, since keeping it outside would defeat the point.
- 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. If no mountpoint services the path, the list traverses from the real root instead.
- class angr.state_plugins.filesystem.SimMount¶
Bases:
SimStatePlugin,SupportsMergeThis 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)¶